Ansible
Installation
SKILL.md
YAML Syntax Traps
- Jinja2 in value needs quotes —
"{{ variable }}"not{{ variable }} :in string needs quotes —msg: "Note: this works"notmsg: Note: this- Boolean strings:
yes,no,true,falseparsed as bool — quote if literal string - Indentation must be consistent — 2 spaces standard, tabs forbidden
Variable Precedence
- Extra vars (
-e) override everything — highest precedence - Host vars beat group vars — more specific wins
vars:in playbook beats inventory vars — order: inventory < playbook < extra vars- Undefined variable fails — use
{{ var | default('fallback') }}
Idempotence
command/shellmodules aren't idempotent — always "changed", usecreates:or specific module- Use
apt,yum,copyetc. — designed for idempotence changed_when: falsefor commands that don't change state — like queriescreates:/removes:for command idempotence — skips if file exists/doesn't