Update indentation used in the code examples, unify empty lines (#65874)

pull/65892/head
Wojciech Sciesinski 5 years ago committed by Alicia Cozine
parent 40fb46f1e8
commit aacc2d1a18

@ -27,11 +27,12 @@ Rolling Update Batch Size
By default, Ansible will try to manage all of the machines referenced in a play in parallel. For a rolling update use case, you can define how many hosts Ansible should manage at a single time by using the ``serial`` keyword:: By default, Ansible will try to manage all of the machines referenced in a play in parallel. For a rolling update use case, you can define how many hosts Ansible should manage at a single time by using the ``serial`` keyword::
---
- name: test play - name: test play
hosts: webservers hosts: webservers
serial: 2 serial: 2
gather_facts: False gather_facts: False
tasks: tasks:
- name: task one - name: task one
command: hostname command: hostname
@ -72,6 +73,7 @@ would complete the play completely before moving on to the next 2 hosts::
The ``serial`` keyword can also be specified as a percentage, which will be applied to the total number of hosts in a The ``serial`` keyword can also be specified as a percentage, which will be applied to the total number of hosts in a
play, in order to determine the number of hosts per pass:: play, in order to determine the number of hosts per pass::
---
- name: test play - name: test play
hosts: webservers hosts: webservers
serial: "30%" serial: "30%"
@ -80,6 +82,7 @@ If the number of hosts does not divide equally into the number of passes, the fi
As of Ansible 2.2, the batch sizes can be specified as a list, as follows:: As of Ansible 2.2, the batch sizes can be specified as a list, as follows::
---
- name: test play - name: test play
hosts: webservers hosts: webservers
serial: serial:
@ -92,6 +95,7 @@ every following batch would contain 10 hosts until all available hosts are used.
It is also possible to list multiple batch sizes as percentages:: It is also possible to list multiple batch sizes as percentages::
---
- name: test play - name: test play
hosts: webservers hosts: webservers
serial: serial:
@ -101,6 +105,7 @@ It is also possible to list multiple batch sizes as percentages::
You can also mix and match the values:: You can also mix and match the values::
---
- name: test play - name: test play
hosts: webservers hosts: webservers
serial: serial:
@ -122,6 +127,7 @@ In some situations, such as with the rolling updates described above, it may be
certain threshold of failures have been reached. To achieve this, you can set a maximum failure certain threshold of failures have been reached. To achieve this, you can set a maximum failure
percentage on a play as follows:: percentage on a play as follows::
---
- hosts: webservers - hosts: webservers
max_fail_percentage: 30 max_fail_percentage: 30
serial: 10 serial: 10
@ -147,12 +153,10 @@ Be aware that it does not make sense to delegate all tasks, debug, add_host, inc
Using this with the 'serial' keyword to control the number of hosts executing at one time is also a good idea:: Using this with the 'serial' keyword to control the number of hosts executing at one time is also a good idea::
--- ---
- hosts: webservers - hosts: webservers
serial: 5 serial: 5
tasks: tasks:
- name: take out of load balancer pool - name: take out of load balancer pool
command: /usr/bin/take_out_of_pool {{ inventory_hostname }} command: /usr/bin/take_out_of_pool {{ inventory_hostname }}
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
@ -170,11 +174,9 @@ Using this with the 'serial' keyword to control the number of hosts executing at
These commands will run on 127.0.0.1, which is the machine running Ansible. There is also a shorthand syntax that you can use on a per-task basis: 'local_action'. Here is the same playbook as above, but using the shorthand syntax for delegating to 127.0.0.1:: These commands will run on 127.0.0.1, which is the machine running Ansible. There is also a shorthand syntax that you can use on a per-task basis: 'local_action'. Here is the same playbook as above, but using the shorthand syntax for delegating to 127.0.0.1::
--- ---
# ... # ...
tasks: tasks:
- name: take out of load balancer pool - name: take out of load balancer pool
local_action: command /usr/bin/take_out_of_pool {{ inventory_hostname }} local_action: command /usr/bin/take_out_of_pool {{ inventory_hostname }}
@ -188,8 +190,8 @@ Here is an example::
--- ---
# ... # ...
tasks:
tasks:
- name: recursively copy files from management server to target - name: recursively copy files from management server to target
local_action: command rsync -a /path/to/files {{ inventory_hostname }}:/path/to/target/ local_action: command rsync -a /path/to/files {{ inventory_hostname }}:/path/to/target/
@ -200,8 +202,8 @@ In case you have to specify more arguments you can use the following syntax::
--- ---
# ... # ...
tasks:
tasks:
- name: Send summary mail - name: Send summary mail
local_action: local_action:
module: mail module: mail
@ -220,8 +222,9 @@ Delegated facts
By default, any fact gathered by a delegated task are assigned to the `inventory_hostname` (the current host) instead of the host which actually produced the facts (the delegated to host). By default, any fact gathered by a delegated task are assigned to the `inventory_hostname` (the current host) instead of the host which actually produced the facts (the delegated to host).
The directive `delegate_facts` may be set to `True` to assign the task's gathered facts to the delegated host instead of the current one.:: The directive `delegate_facts` may be set to `True` to assign the task's gathered facts to the delegated host instead of the current one.::
---
- hosts: app_servers - hosts: app_servers
tasks: tasks:
- name: gather facts from db servers - name: gather facts from db servers
setup: setup:
@ -297,6 +300,7 @@ To run an entire playbook locally, just set the "hosts:" line to "hosts: 127.0.0
Alternatively, a local connection can be used in a single playbook play, even if other plays in the playbook Alternatively, a local connection can be used in a single playbook play, even if other plays in the playbook
use the default remote connection type:: use the default remote connection type::
---
- hosts: 127.0.0.1 - hosts: 127.0.0.1
connection: local connection: local
@ -330,11 +334,13 @@ For datacenter "A", the playbook can be written this way::
--- ---
- hosts: load_balancers_dc_a - hosts: load_balancers_dc_a
any_errors_fatal: True any_errors_fatal: True
tasks: tasks:
- name: 'shutting down datacenter [ A ]' - name: 'shutting down datacenter [ A ]'
command: /usr/bin/disable-dc command: /usr/bin/disable-dc
- hosts: frontends_dc_a - hosts: frontends_dc_a
tasks: tasks:
- name: 'stopping service' - name: 'stopping service'
command: /usr/bin/stop-software command: /usr/bin/stop-software
@ -342,6 +348,7 @@ For datacenter "A", the playbook can be written this way::
command: /usr/bin/upgrade-software command: /usr/bin/upgrade-software
- hosts: load_balancers_dc_a - hosts: load_balancers_dc_a
tasks: tasks:
- name: 'Starting datacenter [ A ]' - name: 'Starting datacenter [ A ]'
command: /usr/bin/enable-dc command: /usr/bin/enable-dc

Loading…
Cancel
Save