Interview Prep/Ansible/Playbooks, Plays, Tasks and Handlers

What does `--diff` show and how does it combine with `--check`?

IntermediateConceptPlaybooks, Plays, Tasks and Handlers
Answer

--diff prints before/after content for modules that support it: template, copy, lineinfile, blockinfile, file attributes. With --check you get a preview of exactly what would change without writing anything.

ansible-playbook site.yml --check --diff --limit web1

Set diff: false on tasks that handle secrets, otherwise passwords from a template show in the output (and no_log: true also hides the diff).

All Ansible questions Roadmap: Ansible

More on Playbooks, Plays, Tasks and Handlers