Debian Codegraph @

test/integration/targets/hostname/tasks/test_check_mode.yml

raw
1 - name: Run hostname module in check_mode
2 hostname:
3 name: crocodile.ansible.test.doesthiswork.net.example.com
4 check_mode: true
5 register: hn1
6
7 - name: Get current hostname again
8 command: hostname
9 register: after_hn
10
11 - name: Ensure hostname changed properly
12 assert:
13 that:
14 - hn1 is changed
15 - original.stdout == after_hn.stdout
16
17 - when: _hostname_file is defined and _hostname_file is not none
18 block:
19 - name: See if current hostname file exists
20 stat:
21 path: "{{ _hostname_file }}"
22 register: hn_stat
23
24 - name: Move the current hostname file if it exists
25 command: mv {{ _hostname_file }} {{ _hostname_file }}.orig
26 when: hn_stat.stat.exists
27
28 - name: Run hostname module in check_mode
29 hostname:
30 name: crocodile.ansible.test.doesthiswork.net.example.com
31 check_mode: true
32 register: hn
33
34 - stat:
35 path: /etc/rc.conf.d/hostname
36 register: hn_stat_checkmode
37
38 - assert:
39 that:
40 # TODO: This is a legitimate bug and will be fixed in another PR.
41 # - not hn_stat_checkmode.stat.exists
42 - hn is changed
43
44 - name: Get hostname again
45 command: hostname
46 register: current_after_cm
47
48 - assert:
49 that:
50 - original.stdout == current_after_cm.stdout