summaryrefslogtreecommitdiffstats
path: root/test/using-bare-variables-failure.yml
blob: 865381bec56b8f095fa8c9b8b5ec3afd7e3b707b (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
- hosts: localhost
  become: no
  vars:
    my_list:
      - foo
      - bar

    my_list2:
      - 1
      - 2

    my_list_of_dicts:
      - foo: 1
        bar: 2
      - foo: 3
        bar: 4

    my_list_of_lists:
      - "{{ my_list }}"
      - "{{ my_list2 }}"

    my_filenames:
      - foo.txt
      - bar.txt

    my_dict:
      foo: bar

  tasks:
    - name: with_items loop using bare variable
      debug:
        msg: "{{ item }}"
      with_items: my_list

    - name: with_dict loop using bare variable
      debug:
        msg: "{{ item }}"
      with_dict: my_dict

    ### Testing with_dict with a default empty dictionary
    - name: with_dict loop using variable and default
      debug:
        msg: "{{ item.key }} - {{ item.value }}"
      with_dict: uwsgi_ini | default({})

    - name: with_nested loop using bare variable
      debug:
        msg: "{{ item.0 }} {{ item.1 }}"
      with_nested:
        - my_list
        - "{{ my_list2 }}"

    - name: with_file loop using bare variable
      debug:
        msg: "{{ item }}"
      with_file: my_list

    - name: with_fileglob loop using bare variable
      debug:
        msg: "{{ item }}"
      with_fileglob: my_list

    - name: with_filetree loop using bare variable
      debug:
        msg: "{{ item }}"
      with_filetree: my_list

    - name: with_together loop using bare variable
      debug:
        msg: "{{ item.0 }} {{ item.1 }}"
      with_together:
        - my_list
        - "{{ my_list2 }}"

    - name: with_subelements loop using bare variable
      debug:
        msg: "{{ item.0 }}"
      with_subelements:
        - my_list_of_dicts
        - bar

    - name: with_random_choice loop using bare variable
      debug:
        msg: "{{ item }}"
      with_random_choice: my_list

    - name: with_first_found loop using bare variable
      debug:
        msg: "{{ item }}"
      with_first_found: my_filenames

    - name: with_indexed_items loop
      debug:
        msg: "{{ item.0 }} {{ item.1 }}"
      with_indexed_items: my_list

    - name: with_flattened loop
      debug:
        msg: "{{ item }}"
      with_flattened:
        - my_list
        - my_list2

    - name: with_flattened loop with a variable
      debug:
        msg: "{{ item }}"
      with_flattened: my_list_of_lists