This post was originally published on the
XLAB Steampunk blog.
The IT industry has been increasing in complexity for quite some time now. Organizations have to find a way to manage an additional maintenance burden. Most of them are trying to solve the problem via automation. But this cultural shift towards the DevOps and site reliability engineering disciplines has one significant consequence for product owners: automation is becoming the preferred method for adopting new technologies.
High-quality Ansible Collection can help eliminate barriers to adoption and improve the reliability of onboarding new technology. But the benefits of offering customers a high-quality Ansible Collection extend beyond the day-1 operations. When appropriately designed, Ansible roles and modules can be of great help in day-2 operations.
Update (2020-11-12): It was nice talking to all of you during the AnsibleFest session. Stay safe during those strange times!
What makes an Ansible Collection high quality
A high-quality Ansible Collection puts the user experience above all else. Its two primary purposes are:
- Make it possible to write human-readable Ansible playbooks that describe the desired state.
- Enforce the desired state from the Ansible playbook safely and reliably.
Because Ansible Collections provide essential building blocks for Ansible playbooks (modules and roles), readability and robustness are highly dependent on the quality of the Ansible content.
State improves Ansible playbook’s readability
One of the more important traits of a high-quality Ansible Collection is its focus on the result. Let us look at the next playbook task:
- name: Rudimentary auto-remediation hook sensu.sensu_go.hook: name: restart_nginx command: sudo systemctl start nginx timeout: 60 stdin: false
Because the sensu.sensu_go.hook module is enforcing a state, the full description of the steps it takes when it executes the sample task would be:
- If the
restart_nginxhook does not exist, create it.
- For each task’s parameter, make sure current and desired values are synchronized.
- Report back if we changed anything.
Imagine what a mess our Ansible playbooks would be if we would need to add all that conditional logic to our task.
The focus on the desired state is also crucial for day-2 operations. The sensu.sensu_go.hook Ansible module will only update the hook if there is a change in the hook’s definition. And if all Ansible modules that we use in our Ansible playbook work this way, we can safely run the Ansible playbook multiple times without risking breaking our deploy.
We can also reuse the same Ansible playbook for detecting unauthorized configuration changes. Tracking down the rouge system administrator might be a bit harder, but that is another story ;)
But there is more
The above example demonstrates one property that each high-quality Ansible Collection should have. If you are interested in hearing more tips and tricks about designing, coding, testing, and maintaining a high-quality Ansible content, we are preparing an on-demand webinar Speed up the adoption of automation with high-quality Ansible Collections that will be available in December 2020 and it was also featured at this year’s AnsibleFest 2020. Register on the Steampunk site now.