ansible-playbook
AutomationPackage: ansible-core
Applies a playbook: each task compares the described state with the present one and acts only on the difference, then the recap counts what changed. --check --diff shows what a run would do without writing anything; it is the command to run before the first real run, and after every edit to the playbook.
What its options do in the lessons
From the same glossary the lessons render under their commands, so the two cannot disagree.
ansible-playbook --ask-vault-pass- Asks for the vault password at the keyboard, once per run: the choice for a machine where a password file would be worse than typing it.
ansible-playbook --check- Dry-runs the playbook: every module reports what it would change without writing anything to the machine.
ansible-playbook --diff- Shows, for every file a task changes, the difference between the present state and the described one — with
--check, what a run would do, line by line. ansible-playbook --force-handlers- Runs the notified handlers even when a later task in the play fails: without it, the play stops at the failure and an already changed file leaves the service on the old configuration.
ansible-playbook --list-tasks- Prints the tasks the playbook would run, play by play, without running anything — the list of what the playbook claims about the machine, with no
Gathering Factsand no handlers. ansible-playbook --syntax-check- Parses the playbook and the files it includes, then stops: the YAML is valid and every task names a module that exists. No host is contacted and nothing is run.
ansible-playbook --vault-password-file- Reads the vault password from that file, one line and nothing else, instead of asking for it. The file belongs outside the repository;
ansible.cfgcan name its path withvault_password_file. ansible-playbook -v- Prints the JSON result each task returns, not just
okorchanged— including the values a task handled, unless it carriesno_log: true.
Lessons that teach it
- A script you can run twice, made into a toolAnsible for one server: a description you can run
- Your first playbook, and the number it ends withAnsible for one server: a description you can run
- The restart at the end of the playbook, and the handler that replaces itAnsible for one server: a description you can run
- Reading the recap: what a green run provesAnsible for one server: a description you can run
- Encrypting a secret, and keeping the password elsewhereAnsible for one server: a description you can run
