summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/hostname/tasks/test_check_mode.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/hostname/tasks/test_check_mode.yml
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/hostname/tasks/test_check_mode.yml')
-rw-r--r--test/integration/targets/hostname/tasks/test_check_mode.yml50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/integration/targets/hostname/tasks/test_check_mode.yml b/test/integration/targets/hostname/tasks/test_check_mode.yml
new file mode 100644
index 0000000..9ba1d65
--- /dev/null
+++ b/test/integration/targets/hostname/tasks/test_check_mode.yml
@@ -0,0 +1,50 @@
+- name: Run hostname module in check_mode
+ hostname:
+ name: crocodile.ansible.test.doesthiswork.net.example.com
+ check_mode: true
+ register: hn1
+
+- name: Get current hostname again
+ command: hostname
+ register: after_hn
+
+- name: Ensure hostname changed properly
+ assert:
+ that:
+ - hn1 is changed
+ - original.stdout == after_hn.stdout
+
+- when: _hostname_file is defined and _hostname_file
+ block:
+ - name: See if current hostname file exists
+ stat:
+ path: "{{ _hostname_file }}"
+ register: hn_stat
+
+ - name: Move the current hostname file if it exists
+ command: mv {{ _hostname_file }} {{ _hostname_file }}.orig
+ when: hn_stat.stat.exists
+
+ - name: Run hostname module in check_mode
+ hostname:
+ name: crocodile.ansible.test.doesthiswork.net.example.com
+ check_mode: true
+ register: hn
+
+ - stat:
+ path: /etc/rc.conf.d/hostname
+ register: hn_stat_checkmode
+
+ - assert:
+ that:
+ # TODO: This is a legitimate bug and will be fixed in another PR.
+ # - not hn_stat_checkmode.stat.exists
+ - hn is changed
+
+ - name: Get hostname again
+ command: hostname
+ register: current_after_cm
+
+ - assert:
+ that:
+ - original.stdout == current_after_cm.stdout