Reputation: 11
This is the puppet code managing a service:
class fred::service {
service { 'bob':
enable => true,
ensure => 'running',
require => Package['bob-5.4']
}
}
My translation in Ansible role
---
- name: check bob
service:
name: bob
enabled: true
state: running
package:
name: bob-5.4
state: present
My question is:
package:
Upvotes: 1
Views: 188
Reputation: 2454
The order is incorrect. You should first attempt to install the package. It will automatically skip this (resulting in ok
) if the package is already present.
When checking if the service is running, state: running
is not valid in Ansible, it should be state: started
.
- name: Install package
apt:
name: bob-5.4
state: present
- name: Check if service is running
service:
name: bob
state: started
enabled: yes
Depending on what you install the package with, this may require a little modification (package
or yum
instead of apt
for example).
Upvotes: 2