Can a playbook have multiple plays? Why would you do that?
IntermediateConceptFundamentals and Architecture
Answer
Yes. A playbook is a list of plays, and each play maps a host pattern to tasks. Multiple plays let you orchestrate across tiers in one run: configure the database, then app servers, then the load balancer, each with its own hosts, become, variables and serial.
- hosts: db
roles: [postgres]
- hosts: app
roles: [app]
- hosts: lb
roles: [haproxy]
Plays run sequentially. Data can pass between them through hostvars or set_fact on the hosts.
More on Fundamentals and Architecture
What is Ansible and what problem does it solve?BeginnerWhat does "agentless" mean in Ansible?BeginnerWhat are the requirements for the control node?BeginnerWhat does a managed node need?BeginnerIs Ansible push-based or pull-based?BeginnerWalk through what happens when you run `ansible-playbook site.yml`.Intermediate