summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2023-03-08 15:40:01 -0500
committerGitHub <noreply@github.com>2023-03-08 15:40:01 -0500
commitb7a0e0d79278906c57c6dfc637d0e0b09b45db34 (patch)
tree5598844551a3421aa6b6615ab7e7f2f0f498edae /test
parentc564c6e21e4538b475df2ae4b3f66b73decff160 (diff)
downloadansible-b7a0e0d79278906c57c6dfc637d0e0b09b45db34.tar.gz
copy - fix check mode with remote_src=True (#78624)
* Don't create dest directory in check mode uncomment existing test Fix checking for file attribute changes in check mode and add a test
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/copy/tasks/check_mode.yml41
1 files changed, 39 insertions, 2 deletions
diff --git a/test/integration/targets/copy/tasks/check_mode.yml b/test/integration/targets/copy/tasks/check_mode.yml
index 5b405cc49a..9702e07089 100644
--- a/test/integration/targets/copy/tasks/check_mode.yml
+++ b/test/integration/targets/copy/tasks/check_mode.yml
@@ -113,8 +113,7 @@
- check_mode_subdir_first is changed
- check_mode_trailing_slash_first is changed
- # TODO: This is a legitimate bug
- #- not check_mode_trailing_slash_first_stat.stat.exists
+ - not check_mode_trailing_slash_first_stat.stat.exists
- check_mode_trailing_slash_real is changed
- check_mode_trailing_slash_real_stat.stat.exists
- check_mode_trailing_slash_second is not changed
@@ -124,3 +123,41 @@
- check_mode_foo_real is changed
- check_mode_foo_real_stat.stat.exists
- check_mode_foo_second is not changed
+
+ - name: check_mode - Do a basic copy to setup next test (without check mode)
+ copy:
+ src: foo.txt
+ dest: "{{ remote_dir }}/foo-check_mode.txt"
+ mode: 0444
+
+ - name: check_mode - Copy the same src with a different mode (check mode)
+ copy:
+ src: foo.txt
+ dest: "{{ remote_dir }}/foo-check_mode.txt"
+ mode: 0666
+ check_mode: True
+ register: check_mode_file_attribute
+
+ - name: stat the file to make sure the mode was not updated in check mode
+ stat:
+ path: "{{ remote_dir }}/foo-check_mode.txt"
+ register: check_mode_file_attribute_stat
+
+ - name: check_mode - Copy the same src with a different mode (without check mode)
+ copy:
+ src: foo.txt
+ dest: "{{ remote_dir }}/foo-check_mode.txt"
+ mode: 0666
+ register: real_file_attribute
+
+ - name: stat the file to make sure the mode was updated without check mode
+ stat:
+ path: "{{ remote_dir }}/foo-check_mode.txt"
+ register: real_file_attribute_stat
+
+ - assert:
+ that:
+ - check_mode_file_attribute is changed
+ - real_file_attribute is changed
+ - "check_mode_file_attribute_stat.stat.mode == '0444'"
+ - "real_file_attribute_stat.stat.mode == '0666'"