mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
add an example of multiple plays in a single playbook
This commit is contained in:
parent
e88a9e943c
commit
597d3a5eaa
1 changed files with 27 additions and 0 deletions
|
@ -106,6 +106,33 @@ YAML dictionaries to supply the modules with their key=value arguments.::
|
|||
name: httpd
|
||||
state: restarted
|
||||
|
||||
Playbooks can contain multiple plays. You may have a playbook that targets first
|
||||
the web servers, and then the database servers. For example::
|
||||
|
||||
---
|
||||
- hosts: webservers
|
||||
remote_user: root
|
||||
|
||||
tasks:
|
||||
- name: ensure apache is at the latest version
|
||||
yum: pkg=httpd state=latest
|
||||
- name: write the apache config file
|
||||
template: src=/srv/httpd.j2 dest=/etc/httpd.conf
|
||||
|
||||
- hosts: databases
|
||||
remote_user: root
|
||||
|
||||
tasks:
|
||||
- name: ensure postgresql is at the latest version
|
||||
yum: name=postgresql state=latest
|
||||
- name: ensure that postgresql is started
|
||||
service: name=postgresql state=running
|
||||
|
||||
You can use this method to switch between the host group you're targeting,
|
||||
the username logging into the remote servers, whether to sudo or not, and so
|
||||
forth. Plays, like tasks, run in the order specified in the playbook: top to
|
||||
bottom.
|
||||
|
||||
Below, we'll break down what the various features of the playbook language are.
|
||||
|
||||
.. _playbook_basics:
|
||||
|
|
Loading…
Reference in a new issue