Ansible coding rules
Par pepin le lundi, juillet 26 2021, 09:29 - Ansible - Lien permanent
- All YAML files named with .yml extension
- Use 2 (two) spaces for each indent
- Use spaces around jinja variables (eg.
var
, notvar
) - Variables that are internal to the role should be lowercase
- Keep roles self-contained. Roles should avoid including tasks from other roles whenever possible
- Plays should do nothing more than include a list of roles except where pre_tasks and post_tasks are required
- Use underscores as separators instead of dashes (e.g. my_role, not my-role)
- When defining paths (or concatenating them), do not include trailing slashes (e.g. my_path: /foo not my_path: /foo/, or
my_path
/bar notmy_path
bar) - For variables that don't need to change or be overridden by the user, put them in vars/. For variables that would likely be overriden, put them in defaults/.