This commit is contained in:
Hideki Saito 2022-03-13 01:45:04 +09:00
parent f976c994c7
commit 70b843ba43

View file

@ -30,10 +30,22 @@
with_items: with_items:
- foo.txt - foo.txt
- bar.txt - bar.txt
- name: copy file to new filename - name: synchronize file to new filename
copy: synchronize:
src: "{{ output_dir }}/foo.txt" src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result" dest: "{{ output_dir }}/foo.result"
register: sync_result
- assert:
that:
- '''changed'' in sync_result'
- sync_result.changed == true
- '''cmd'' in sync_result'
- '''rsync'' in sync_result.cmd'
- '''msg'' in sync_result'
- sync_result.msg.startswith('>f+')
- 'sync_result.msg.endswith(''+ foo.txt
'')'
when: when:
- ansible_facts.virtualization_type != 'docker' - ansible_facts.virtualization_type != 'docker'
@ -45,13 +57,23 @@
- foo.txt - foo.txt
- bar.txt - bar.txt
delegate_to: "{{ inventory_hostname }}" delegate_to: "{{ inventory_hostname }}"
delegate_facts: true - name: synchronize file to new filename
- name: copy file to new filename synchronize:
copy:
src: "{{ output_dir }}/foo.txt" src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result" dest: "{{ output_dir }}/foo.result"
register: sync_result
delegate_to: "{{ inventory_hostname }}" delegate_to: "{{ inventory_hostname }}"
delegate_facts: true - assert:
that:
- '''changed'' in sync_result'
- sync_result.changed == true
- '''cmd'' in sync_result'
- '''rsync'' in sync_result.cmd'
- '''msg'' in sync_result'
- sync_result.msg.startswith('>f+')
- 'sync_result.msg.endswith(''+ foo.txt
'')'
when: when:
- ansible_facts.virtualization_type == 'docker' - ansible_facts.virtualization_type == 'docker'