1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Don't pass mode from synchronize action plugin to the ansible module

Fixes https://github.com/ansible/ansible-modules-core/issues/1783
This commit is contained in:
Toshio Kuratomi 2015-07-23 00:39:15 -07:00
parent b678b9828c
commit b06353791c
2 changed files with 123 additions and 2 deletions

View file

@ -169,6 +169,11 @@ class ActionModule(ActionBase):
if use_ssh_args:
self._task.args['ssh_args'] = constants.ANSIBLE_SSH_ARGS
# Remove mode as it is handled purely in this action module
if 'mode' in self._task.args:
del self._task.args['mode']
# run the module and store the result
result = self._execute_module('synchronize', task_vars=task_vars)

View file

@ -40,6 +40,124 @@
- "sync_result.msg.startswith('>f+')"
- "sync_result.msg.endswith('+ foo.txt\n')"
- name: test that the file was really copied over
stat:
path: "{{ output_dir }}/foo.result"
register: stat_result
- assert:
that:
- "stat_result.stat.exists == True"
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
- name: test that the file is not copied a second time
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.result
register: sync_result
- assert:
that:
- "sync_result.changed == False"
- name: Cleanup
file:
state: absent
path: "{{output_dir}}/{{item}}"
with_items:
- foo.result
- bar.result
- name: Synchronize using the mode=push param
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: push
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\n')"
- name: test that the file was really copied over
stat:
path: "{{ output_dir }}/foo.result"
register: stat_result
- assert:
that:
- "stat_result.stat.exists == True"
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
- name: test that the file is not copied a second time
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: push
register: sync_result
- assert:
that:
- "sync_result.changed == False"
- name: Cleanup
file:
state: absent
path: "{{output_dir}}/{{item}}"
with_items:
- foo.result
- bar.result
- name: Synchronize using the mode=pull param
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: pull
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\n')"
- name: test that the file was really copied over
stat:
path: "{{ output_dir }}/foo.result"
register: stat_result
- assert:
that:
- "stat_result.stat.exists == True"
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
- name: test that the file is not copied a second time
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: pull
register: sync_result
- assert:
that:
- "sync_result.changed == False"
- name: Cleanup
file:
state: absent
path: "{{output_dir}}/{{item}}"
with_items:
- foo.result
- bar.result
- name: synchronize files using with_items (issue#5965)
synchronize: src={{output_dir}}/{{item}} dest={{output_dir}}/{{item}}.result
with_items:
@ -47,7 +165,6 @@
- bar.txt
register: sync_result
- debug: var=sync_result
- assert:
that:
- "sync_result.changed"
@ -61,7 +178,6 @@
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.rsync_path rsync_path="sudo rsync"
register: sync_result
- debug: var=sync_result
- assert:
that:
- "'changed' in sync_result"