|
|
|
@ -106,41 +106,22 @@
|
|
|
|
|
- '"Ansible managed" in diff_output.diff[0].after'
|
|
|
|
|
- '"file.txt" in diff_output.diff[0].after_header'
|
|
|
|
|
|
|
|
|
|
- name: create new directory
|
|
|
|
|
- name: create directory for multi diff test (empty directories not stored in git)
|
|
|
|
|
file:
|
|
|
|
|
path: "{{ role_path }}/files/two-file-diff-test.d"
|
|
|
|
|
path: "{{ role_path }}/files/multi-diff-test/dir"
|
|
|
|
|
state: directory
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
|
|
|
|
|
- name: create 2 files in directory, containing the text "foo" and "bar"
|
|
|
|
|
copy:
|
|
|
|
|
dest: "{{ role_path }}/files/two-file-diff-test.d/{{ item }}"
|
|
|
|
|
content: "{{ item }}"
|
|
|
|
|
loop:
|
|
|
|
|
- foo
|
|
|
|
|
- bar
|
|
|
|
|
|
|
|
|
|
- name: copy directory with 2 files in diff mode
|
|
|
|
|
- name: multi diff test
|
|
|
|
|
copy:
|
|
|
|
|
src: "{{ role_path }}/files/two-file-diff-test.d"
|
|
|
|
|
dest: "{{ local_temp_dir }}/two-file-diff-test.d"
|
|
|
|
|
register: two_file_diff_test
|
|
|
|
|
src: "{{ role_path }}/files/multi-diff-test"
|
|
|
|
|
dest: "{{ local_temp_dir }}/multi-diff-test"
|
|
|
|
|
register: multi_diff_test
|
|
|
|
|
diff: true
|
|
|
|
|
|
|
|
|
|
# right now it returns exactly 2, but if/when the copy module is updated to produce attribute
|
|
|
|
|
# diffs, there will be more.
|
|
|
|
|
- name: assert that at least 2 diffs returned when creating 2 files
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- two_file_diff_test.diff is not string and two_file_diff_test.diff is not mapping and two_file_diff_test.diff is iterable
|
|
|
|
|
- two_file_diff_test.diff | length >= 2
|
|
|
|
|
|
|
|
|
|
# right now they all show file contents, but if/when the copy module is updated to produce attribute
|
|
|
|
|
# diffs, that will not be the case.
|
|
|
|
|
- name: assert that exactly 2 diffs show file contents, which are "foo" and "bar"
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
# diff.after should be a dict if it's not file contents
|
|
|
|
|
- (two_file_diff_test.diff | selectattr('after', 'string') | map(attribute='after') | sort) == ["bar", "foo"]
|
|
|
|
|
- name: delme
|
|
|
|
|
debug:
|
|
|
|
|
var: multi_diff_test
|
|
|
|
|
|
|
|
|
|
- name: tests with remote_src and non files
|
|
|
|
|
import_tasks: src_remote_file_is_not_file.yml
|
|
|
|
|