* add note about named tasks in blocks
Signed-off-by: Adam Miller <admiller@redhat.com>
* adds names to tasks within example block, removes 2nd example
* removes traces of bad rebase
@ -6,22 +6,24 @@ Blocks allow for logical grouping of tasks and in play error handling. Most of w
..code-block:: YAML
..code-block:: YAML
:emphasize-lines:3
:emphasize-lines:3
:caption:Block example
:caption:Block example with named tasks inside the block
tasks:
tasks:
- name: Install Apache
- name: Install, configure, and start Apache
block:
block:
- yum:
- name: install httpd and memcached
yum:
name: "{{ item }}"
name: "{{ item }}"
state: installed
state: installed
loop:
loop:
- httpd
- httpd
- memcached
- memcached
- template:
- name: apply the foo config template
template:
src: templates/src.j2
src: templates/src.j2
dest: /etc/foo.conf
dest: /etc/foo.conf
- service:
- name: start service bar and enable it
service:
name: bar
name: bar
state: started
state: started
enabled: True
enabled: True
@ -33,9 +35,7 @@ In the example above, each of the 3 tasks will be executed after appending the `
and evaluating it in the task's context. Also they inherit the privilege escalation directives enabling "become to root"
and evaluating it in the task's context. Also they inherit the privilege escalation directives enabling "become to root"
for all the enclosed tasks.
for all the enclosed tasks.
..versionadded:: 2.3
Names for tasks within blocks have been available since Ansible 2.3. We recommend using names in all tasks, within blocks or elsewhere, for better visibility into the tasks being executed when you run the playbook.
The ``name:`` keyword for ``block:`` was added in Ansible 2.3.