Welcome to mirror list, hosted at ThFree Co, Russian Federation.

loop_nested.yml « language_features - github.com/ansible/ansible-examples.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2741ea5b55785d6ff112d12389cfccba8bdee980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
# this is a trivial example of how to do a nested loop.

- hosts: all
  tasks:
    - shell: echo "nested test a={{ item[0] }} b={{ item[1] }} c={{ item[2] }}"
      with_nested:
        - [ 'red', 'blue', 'green' ]
        - [ 1, 2, 3 ]
        - [ 'up', 'down', 'strange']

# you can reference a raw variable name without putting it in {{ brackets }}

- hosts: all
  vars:
    listvar1:
    - 'a'
    - 'b'
    - 'c'
  tasks:
    - shell: echo "nested test a={{ item[0] }} b={{ item[1] }}"
      with_nested:
        - listvar1
        - [ 1, 2, 3 ]