A collection of good and bad Ansible code examples.
- Name your tasks
- Use Modules before run-commands
- Use native yaml syntax
- Use the copy-module or template-module instead of lineinfile-module
- Avoid unintended side effects when running playbooks
- Turn off gather_facts if not needed
- Prefix your variables
If you want to contribute you can create a merge request so other colleagues will discuss the code with you. Make sure to add both a good and a bad practice to your code example.
Make sure that:
- your code won't contain credentials
- you've commented the code why it is a good or bad practice
- your code can be easily run, so please add a full playbook if possible
- be open to discuss with your colleagues