I have a ansible task like this in my playbook to be run against a centos server:
- name: Enable services for automatic start
action: command /sbin/chkconfig {{ item }} on
with_items:
- nginx
- postgresql
This task changes every time I run it. How do I make this task pass the idempotency test ?
The best option is to use the enabled=true
with service module:
- name: Enable services for automatic start
service:
name: "{{ item }}"
enabled: true
loop:
- nginx
- postgresql
Hope that help you.