• ansible,  Konzepte,  YAML

    Ansible Formatting Best Practices

    Readable and consistent Ansible code makes reviews easier, reduces errors, and helps linters such as yamllint and ansible-lint work reliably. The following conventions have proven useful in larger playbooks and roles. 1. Use folded scalars for long Jinja expressions Multiline Jinja expressions inside a quoted YAML scalar can confuse YAML parsers and linters. Avoid this: The expression is hard to read and may break YAML formatting checks. Use folded scalars instead: Advantages: 2. General YAML formatting Maintain a consistent layout across all playbooks. Recommended conventions: Example: This improves readability and keeps file structure consistent. 3. Always use Fully Qualified Collection Names (FQCN) Using FQCN avoids ambiguity and improves compatibility with…