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

Fixes https://github.com/ansible/ansible-modules-core/issues/1783
pull/11708/head
Toshio Kuratomi 9 years ago
parent b678b9828c
commit b06353791c

@ -169,6 +169,11 @@ class ActionModule(ActionBase):
if use_ssh_args: if use_ssh_args:
self._task.args['ssh_args'] = constants.ANSIBLE_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 # run the module and store the result
result = self._execute_module('synchronize', task_vars=task_vars) result = self._execute_module('synchronize', task_vars=task_vars)

@ -40,6 +40,124 @@
- "sync_result.msg.startswith('>f+')" - "sync_result.msg.startswith('>f+')"
- "sync_result.msg.endswith('+ foo.txt\n')" - "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) - name: synchronize files using with_items (issue#5965)
synchronize: src={{output_dir}}/{{item}} dest={{output_dir}}/{{item}}.result synchronize: src={{output_dir}}/{{item}} dest={{output_dir}}/{{item}}.result
with_items: with_items:
@ -47,7 +165,6 @@
- bar.txt - bar.txt
register: sync_result register: sync_result
- debug: var=sync_result
- assert: - assert:
that: that:
- "sync_result.changed" - "sync_result.changed"
@ -61,7 +178,6 @@
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.rsync_path rsync_path="sudo rsync" synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.rsync_path rsync_path="sudo rsync"
register: sync_result register: sync_result
- debug: var=sync_result
- assert: - assert:
that: that:
- "'changed' in sync_result" - "'changed' in sync_result"

Loading…
Cancel
Save