summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/transform-jinja.yml
blob: 4a4cd3212b4afe676c26f1eb984a02438f57c098 (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
---
- name: Fixture
  hosts: localhost
  vars:
    my_list:
      - foo
      - bar
  tasks:
    - name: A block used to check that we do not identify error at correct level
      block:
        - name: Foo # <-- this is valid jinja2
          ansible.builtin.debug:
            foo: "{{ 1  }}" # <-- jinja2[spacing]
            msg: "{{ 'a' b }}" # <-- jinja2[invalid]

    - name: A block used to check that we do not identify error at correct level
      block:
        - name: Foo # <-- this is valid jinja2
          ansible.builtin.debug:
            msg: "{{ item  }}" # <-- jinja2[spacing]
          with_items:
            - "{{ items  }}"

    - name: Confirm a deeply nested duplicate error is corrected
      ansible.builtin.set_fact:
        fact:
          dict:
            dict:
              list:
                - one
                - two
                - dict:
                    fix: "{{'VALUE_1'|lower}}" # <-- jinja2[spacing]
                - dict:
                    fix: "{{'VALUE_1'|lower}}" # <-- jinja2[spacing]
                - dict:
                    fix: "{{'VALUE_2'|lower}}" # <-- jinja2[spacing]

# It should be noted that even ansible --syntax-check fails to spot the jinja
# error above, but ansible will throw a runtime error when running