I am new to Ansible, and am trying to understand its best practices. My team uses Ansible for system setup and product deployment.
I am reading that idempotance is the foundational virtue, where playbook idempotence is defined as not doing any state changes on consecutive runs.
I am not sure I understand why.
The scenarios I am looking at:
A simple way to implement both scenarios in a single playbook:
The above implementation would require state changes on consecutive invocations.
For initial deployment, the first part is a no-change.
For system update, both parts play.
In order to implement these scenarios in a playbook that doesn’t do state changes on consecutive installations, the playbook would need to be aware of internal dependencies between things that can be in states {installed, uninstalled}, and things that can be in states { running, not running}
This approach makes Ansible playbook tightly coupled to system dependencies. Should these dependencies change, the playbook becomes yet another place that needs to be updated. Depending on the system implementation specifics, having dependencies specified incorrectly in Ansible playbook may cause a hard-to-reproduce bug.
Appreciate any thoughts on why avoiding state changes on consecutive playbook runs is preferred over simplicity and robustness in implementation.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGB%3D%3DuLXscYNsgqdYXq389XhjUAB3_vf0ErFfwiUek%3DAqBB_HQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGB%3D%3DuKFWXoZXnDsGB5Qqc7%2BOhvacxHqjpz_68x83BqQJuVkxA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGB%3D%3DuL3WoZQv%3DfCuA0s%2BWCqg5%2BOk7HEvF2cHjg%3DjqVEpzO2YQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGB%3D%3DuL3WoZQv%3DfCuA0s%2BWCqg5%2BOk7HEvF2cHjg%3DjqVEpzO2YQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGB%3D%3DuLUVrd6FJX60qS90p9ZQqC5U3eYZQB6J%2B%2Bz63s9utqpnA%40mail.gmail.com.
--- - name: Verify apache installation hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: Ensure apache is at the latest version ansible.builtin.yum: name: httpd state: latest - name: Write the apache config file ansible.builtin.template: src: /srv/httpd.j2 dest: /etc/httpd.conf notify: - Restart apache - name: Ensure apache is running ansible.builtin.service: name: httpd state: started handlers: - name: Restart apache ansible.builtin.service: name: httpd state: restarted
Note this part of the play:- name: Write the apache config file
When the config changes based on the template values then it will run the notify 'handler' which is located at Restart Apache. If there is no changes to the 'template' then it won't restart the service