Working with playbooks¶
Playbooks are Ansible’s configuration, deployment, and orchestration language. They can describe a policy you want your remote systems to enforce, or a set of steps in a general IT process.
If Ansible modules are the tools in your workshop, playbooks are your instruction manuals, and your inventory of hosts are your raw material.
At a basic level, playbooks can be used to manage configurations of and deployments to remote machines. At a more advanced level, they can sequence multi-tier rollouts involving rolling updates, and can delegate actions to other hosts, interacting with monitoring servers and load balancers along the way.
While there’s a lot of information here, there’s no need to learn everything at once. You can start small and pick up more features over time as you need them.
Playbooks are designed to be human-readable and are developed in a basic text language. There are multiple ways to organize playbooks and the files they include, and we’ll offer up some suggestions on that and making the most out of Ansible.
You should look at Example Playbooks while reading along with the playbook documentation. These illustrate best practices as well as how to put many of the various concepts together.
- Intro to Playbooks
- Tips and tricks
- Re-using Ansible artifacts
- Using Variables
- Creating valid variable names
- Simple variables
- When to quote variables (a YAML gotcha)
- Dictionary variables
- Registering variables
- Referencing nested variables
- Transforming variables with Jinja2 filters
- Where to set variables
- Variable precedence: Where should I put a variable?
- Using advanced variable syntax
- Discovering variables: facts and magic variables
- Templating (Jinja2)
- Advanced Playbooks Features
- Understanding privilege escalation: become
- Asynchronous actions and polling
- Validating tasks: check mode and diff mode
- Debugging tasks
- Controlling where tasks run: delegation and local actions
- Setting the remote environment
- Working with language-specific version managers
- Error handling in playbooks
- Advanced Syntax
- Data manipulation
- Working With Plugins
- Interactive input: prompts
- Encrypting content with Ansible Vault
- Executing playbooks for troubleshooting
- Playbook Keywords
- Module defaults
- Controlling playbook execution: strategies and more
- Playbook Example: Continuous Delivery and Rolling Upgrades