diff --git a/plugins/modules/synchronize.py b/plugins/modules/synchronize.py index df4d4ad..7e77b8f 100644 --- a/plugins/modules/synchronize.py +++ b/plugins/modules/synchronize.py @@ -27,8 +27,10 @@ options: description: - Path on the source host that will be synchronized to the destination. - The path can be absolute or relative. - type: path + - Support multi path + type: list required: true + elements: path dest: description: - Path on the destination host that will be synchronized from the source. @@ -414,7 +416,7 @@ def is_rsh_needed(source, dest): def main(): module = AnsibleModule( argument_spec=dict( - src=dict(type='list', required=True), + src=dict(type='list', elements='path', required=True), dest=dict(type='path', required=True), dest_port=dict(type='int'), delete=dict(type='bool', default=False), diff --git a/tests/integration/targets/synchronize/tasks/main.yml b/tests/integration/targets/synchronize/tasks/main.yml index 71c7694..ecbe596 100644 --- a/tests/integration/targets/synchronize/tasks/main.yml +++ b/tests/integration/targets/synchronize/tasks/main.yml @@ -369,7 +369,7 @@ - name: Setup - moved test file for save attr ansible.posix.synchronize: - src: "{{ output_dir }}/directory_a/data/foo.txt" + src: "{{ output_dir }}/directory_a/data/foo.txt" dest: "{{ output_dir }}/directory_b/data/foo.txt" delegate_to: "{{ inventory_hostname }}" register: sync_result @@ -380,6 +380,7 @@ src: "{{ output_dir }}/directory_a/data/foo.txt" dest: "{{ output_dir }}/directory_a/data_tmp/foo.txt" state: hard + mode: "0644" - name: Setup - get stat hardlink ansible.builtin.stat: @@ -411,12 +412,13 @@ - stat_result_b.stat.exists == True - stat_result_a.stat.checksum == stat_result_b.stat.checksum - stat_result_a.stat.nlink == stat_result_b.stat.nlink - - "'hf+++++++++ data_tmp/foo.txt => data/foo.txt' in sync_result.stdout_lines" - + - "'hf' in sync_result.msg" + - "'data_tmp/foo.txt => data/foo.txt' in sync_result.msg" + - name: Cleanup ansible.builtin.file: state: absent path: "{{ output_dir }}/{{ item }}" loop: - directory_a - - directory_b \ No newline at end of file + - directory_b diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic/meta.yaml index 28b7045..090595c 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic/meta.yaml @@ -14,5 +14,5 @@ asserts: - self._play_context.shell == 'sh' - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_become/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic_become/meta.yaml index 1eb0b92..6fe68d6 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic_become/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_become/meta.yaml @@ -28,7 +28,7 @@ asserts: # this is a crucial aspect of this scenario ... # note: become_user None -> root - self.final_module_args['rsync_path'] == 'sudo -u root rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' - self.task.become == True - self.task.become_user == None diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_become_cli/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic_become_cli/meta.yaml index 1bec3b4..04ad811 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic_become_cli/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_become_cli/meta.yaml @@ -28,7 +28,7 @@ asserts: # this is a crucial aspect of this scenario ... # note: become_user None -> root - self.final_module_args['rsync_path'] == 'sudo -u root rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' - self.task.become == None - self.task.become_user == None diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant/meta.yaml index 574ee6a..c265b95 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant/meta.yaml @@ -20,7 +20,7 @@ asserts: - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - self.final_module_args['dest_port'] == 2202 - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme' - self._play_context.shell == 'sh' - self._play_context.remote_addr == '127.0.0.1' diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_become_cli/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_become_cli/meta.yaml index eb0d5b1..1ac3b52 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_become_cli/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_become_cli/meta.yaml @@ -23,7 +23,7 @@ asserts: - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - self.final_module_args['dest_port'] == 2202 - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme' - self._play_context.shell == 'sh' - self._play_context.remote_addr == '127.0.0.1' diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_sudo/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_sudo/meta.yaml index 574ee6a..c265b95 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_sudo/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_vagrant_sudo/meta.yaml @@ -20,7 +20,7 @@ asserts: - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - self.final_module_args['dest_port'] == 2202 - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme' - self._play_context.shell == 'sh' - self._play_context.remote_addr == '127.0.0.1' diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/meta.yaml index 7405cb6..7f5546f 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/meta.yaml @@ -21,6 +21,6 @@ asserts: - self._play_context.shell == 'sh' - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' - self.final_module_args['private_key'] == '~/.ssh/id_rsa' diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote/meta.yaml index e943b79..3fbac10 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote/meta.yaml @@ -23,5 +23,5 @@ asserts: - self._play_context.shell == None - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/meta.yaml index 2d88e63..1d6d4cc 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/meta.yaml @@ -24,6 +24,6 @@ asserts: - self._play_context.shell == None - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' - self.final_module_args['private_key'] == '~/test.pem' diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_su/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_su/meta.yaml index 34df19d..3fe6432 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_su/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_su/meta.yaml @@ -30,5 +30,5 @@ asserts: - self._play_context.become_method == 'su' - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/meta.yaml b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/meta.yaml index 603a4cb..0cc99e0 100644 --- a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/meta.yaml +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/meta.yaml @@ -25,6 +25,6 @@ asserts: - self._play_context.shell == None - self.execute_called - self.final_module_args['_local_rsync_path'] == 'rsync' - - self.final_module_args['src'] == '/tmp/deleteme' + - self.final_module_args['src'] == ['/tmp/deleteme'] - self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme' - self.final_module_args['private_key'] == '~/.ssh/id_rsa'