Hi,
following CfgMgmtCamp 2026 conference and a presentation of various questions related to Ansible style:
Ansible Style Guide,presentation
Page of this talk on CfgMgmtCamp website
Survey, question on certain questions of code style for Ansible
As of February 2026 around 20 people answered each of the questions; both by people actively contributing to Ansible (core team members, maintainers, etc.) and by Ansible users.
Results
Questions with answers on which (almost) everyone agrees on
- Are the quotes necessary for all strings?
Community answer: no, it is not necessary to quote all strings
So below is just fine:
apache_package_name: httpd
- What is the preferred option when it comes to “external” quotes?
Community answer: Double quotes (")
- What is the preferred notation for lists and dictionaries?
Community answer: Block-style notation over flow-style
Block-style:
Example of a list:
tags:
- install
- configure
Example of a dictionary:
user:
name: Alice
age: 30
instead of
tags: [install,configure]
...
user: {name: Alice, age: 30}
Questions where overwhelming majority has chosen one option over ther other
- What is preferred inventory format?
Community answer: YAML
- What are the verb(s) that should be used within a task name, “Install, create, configure” or “Ensure”
Community answer: Prefer Install, Create, Configure, etc. etc. in task names over Ensure
Questions where majority chooses one option over the other one but it is (almost) a tie
- Is it good practice to prefix internal variables with double undescores (
__) and/or user_prefix for variables used inregistertask attribute?
Community answer: no, it is not necessary
- What is the preferred dictionary notation?
Community answer: Dot notation is preferred over bracket notation for dictionaries
{{ my_dictionary.mykey }} over {{ my_dictionary['mykey'] }}
Other notes:
-
meta/main.ymlfile inside of Ansible roles is used and maintained by people in Ansible community -
meta/argument_specs.ymlfile inside of Ansible roles is used and maintained by people in Ansible community