summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/omit/C75692.yml
blob: 6e1215fbb5be60096fcdf695de8df8be3f13ce22 (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
- hosts: localhost
  gather_facts: false
  tasks:
    - name: Make sure foo is gone
      file:
        path: foo
        state: absent
    - name: Create foo - should only be changed in first iteration
      copy:
        dest: foo
        content: foo
      check_mode: '{{ omit }}'
      register: cmode
      loop:
        - 1
        - 2

    - when: ansible_check_mode
      block:
      - name: stat foo
        stat: path=foo
        register: foo
        check_mode: off
      - debug: var=foo
      - name: validate expected outcomes when in check mode and file does not exist
        assert:
          that:
            - cmode['results'][0] is changed
            - cmode['results'][1] is changed
        when: not foo['stat']['exists']

      - name: validate expected outcomes when in check mode and file exists
        assert:
          that:
            - cmode['results'][0] is not changed
            - cmode['results'][1] is not changed
        when: foo['stat']['exists']

    - name: validate expected outcomes when not in check mode (file is always deleted)
      assert:
        that:
          - cmode['results'][0] is changed
          - cmode['results'][1] is not changed
      when: not ansible_check_mode