diff --git a/changelogs/fragments/82-private-key-override-fix.yml b/changelogs/fragments/82-private-key-override-fix.yml new file mode 100644 index 0000000..fabb66f --- /dev/null +++ b/changelogs/fragments/82-private-key-override-fix.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - synchronize - Fix for private_key overriding in synchronize module diff --git a/plugins/action/synchronize.py b/plugins/action/synchronize.py index dd1a219..9fa43e8 100644 --- a/plugins/action/synchronize.py +++ b/plugins/action/synchronize.py @@ -333,10 +333,8 @@ class ActionModule(ActionBase): user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user # Private key handling - private_key = self._play_context.private_key_file - - if private_key is not None: - _tmp_args['private_key'] = private_key + # Use the private_key parameter if passed else use context private_key_file + _tmp_args['private_key'] = _tmp_args.get('private_key', self._play_context.private_key_file) # use the mode to define src and dest's url if _tmp_args.get('mode', 'push') == 'pull': 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 new file mode 100644 index 0000000..9b227e0 --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/meta.yaml @@ -0,0 +1,25 @@ +fixtures: + taskvars_in: taskvars_in.json + taskvars_out: taskvars_out.json +connection: + transport: 'ssh' +hostvars: + '127.0.0.1': {} + '::1': {} + 'localhost': {} +_play_context: + private_key_file: ~/test.pem +task_args: + private_key: ~/.ssh/id_rsa + dest: /tmp/deleteme + src: /tmp/deleteme + +asserts: + - "hasattr(SAM._connection, 'ismock')" + - "SAM._connection.transport == 'local'" + - "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['dest'] == 'root@el6host:/tmp/deleteme'" + - "self.final_module_args['private_key'] == '~/.ssh/id_rsa'" diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/taskvars_in.json b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/taskvars_in.json new file mode 100644 index 0000000..9eb5d50 --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/taskvars_in.json @@ -0,0 +1,151 @@ +{ + "ansible_pipelining": false, + "ansible_docker_extra_args": "", + "ansible_scp_extra_args": "", + "ansible_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "ansible_connection": "smart", + "ansible_ssh_common_args": "", + "environment": [], + "inventory_hostname": "el6host", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "el6host", + "inventory_file": "inventory", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "role_names": [], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "play_hosts": [ + "el6host" + ], + "ansible_play_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host" + ], + "all": [ + "el6host" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "groups": { + "ungrouped": [ + "el6host" + ], + "all": [ + "el6host" + ] + }, + "group_names": [ + "ungrouped" + ], + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + }, + "ansible_accelerate_port": 5099, + "roledir": null, + "ansible_ssh_extra_args": "", + "ansible_ssh_host": "el6host", + "ansible_current_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host" + ], + "all": [ + "el6host" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "group_names": [ + "ungrouped" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_pipelining": false, + "inventory_file": "inventory", + "ansible_module_compression": "ZIP_DEFLATED", + "ansible_failed_hosts": [], + "ansible_check_mode": false, + "groups": { + "ungrouped": [ + "el6host" + ], + "all": [ + "el6host" + ] + }, + "ansible_host": "el6host", + "ansible_shell_executable": "/bin/sh", + "inventory_hostname_short": "el6host", + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "role_names": [], + "play_hosts": [ + "el6host" + ], + "ansible_sftp_extra_args": "" +} \ No newline at end of file diff --git a/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/taskvars_out.json b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/taskvars_out.json new file mode 100644 index 0000000..01ebee2 --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/basic_with_private_key/taskvars_out.json @@ -0,0 +1,156 @@ +{ + "ansible_pipelining": false, + "ansible_docker_extra_args": "", + "ansible_scp_extra_args": "", + "ansible_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "ansible_connection": "smart", + "ansible_ssh_common_args": "", + "environment": [], + "inventory_hostname": "el6host", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "el6host", + "inventory_file": "inventory", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "role_names": [], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "play_hosts": [ + "el6host" + ], + "ansible_play_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "::1" + ], + "all": [ + "el6host", + "::1" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "groups": { + "ungrouped": [ + "el6host" + ], + "all": [ + "el6host" + ] + }, + "group_names": [ + "ungrouped" + ], + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + }, + "ansible_accelerate_port": 5099, + "roledir": null, + "ansible_ssh_extra_args": "", + "ansible_ssh_host": "el6host", + "ansible_current_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "::1" + ], + "all": [ + "el6host", + "::1" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "group_names": [ + "ungrouped" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_pipelining": false, + "inventory_file": "inventory", + "ansible_module_compression": "ZIP_DEFLATED", + "ansible_failed_hosts": [], + "ansible_check_mode": false, + "groups": { + "ungrouped": [ + "el6host" + ], + "all": [ + "el6host" + ] + }, + "ansible_host": "el6host", + "ansible_shell_executable": "/bin/sh", + "inventory_hostname_short": "el6host", + "omit": "__omit_place_holder__03600813b83569c710bf5cb2a040d6e01da927c6", + "ansible_python_interpreter": "/usr/bin/python", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "role_names": [], + "play_hosts": [ + "el6host" + ], + "ansible_sftp_extra_args": "" +} \ No newline at end of file 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 new file mode 100644 index 0000000..31939ca --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/meta.yaml @@ -0,0 +1,28 @@ +fixtures: + taskvars_in: task_vars_in.json + taskvars_out: task_vars_out.json +task_args: + src: /tmp/deleteme + dest: /tmp/deleteme +_task: + delegate_to: u1404 +_play_context: + shell: None + remote_addr: u1404 + remote_user: root + private_key_file: ~/test.pem +connection: + transport: 'ssh' +hostvars: + '127.0.0.1': {} + '::1': {} + 'localhost': {} +asserts: + - "hasattr(SAM._connection, 'ismock')" + - "SAM._connection.transport == 'ssh'" + - "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['dest'] == 'root@el6host:/tmp/deleteme'" + - "self.final_module_args['private_key'] == '~/test.pem'" diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/task_vars_in.json b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/task_vars_in.json new file mode 100644 index 0000000..b8893ee --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/task_vars_in.json @@ -0,0 +1,379 @@ +{ + "ansible_pipelining": false, + "ansible_docker_extra_args": "", + "ansible_scp_extra_args": "", + "ansible_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "ansible_connection": "smart", + "ansible_ssh_common_args": "", + "environment": [], + "inventory_hostname": "el6host", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "el6host", + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "inventory_file": "inventory", + "role_names": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "role_names": [], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "play_hosts": [ + "el6host" + ], + "ansible_play_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + }, + "ansible_accelerate_port": 5099, + "roledir": null, + "ansible_ssh_extra_args": "", + "ansible_ssh_host": "u1404", + "ansible_current_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "group_names": [ + "ungrouped" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_pipelining": false, + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "role_names": [] + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "ansible_module_compression": "ZIP_DEFLATED", + "ansible_failed_hosts": [], + "ansible_check_mode": false, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_host": "u1404", + "ansible_shell_executable": "/bin/sh", + "inventory_hostname_short": "el6host", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "role_names": [], + "play_hosts": [ + "el6host" + ], + "ansible_sftp_extra_args": "" +} \ No newline at end of file diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/task_vars_out.json b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/task_vars_out.json new file mode 100644 index 0000000..0b551f0 --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_play_context_private_key/task_vars_out.json @@ -0,0 +1,387 @@ +{ + "ansible_pipelining": false, + "ansible_docker_extra_args": "", + "ansible_scp_extra_args": "", + "ansible_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "ansible_connection": "smart", + "ansible_ssh_common_args": "", + "environment": [], + "inventory_hostname": "el6host", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "el6host", + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "inventory_file": "inventory", + "role_names": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "role_names": [], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "play_hosts": [ + "el6host" + ], + "ansible_play_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + }, + "ansible_accelerate_port": 5099, + "roledir": null, + "ansible_ssh_extra_args": "", + "ansible_ssh_host": "u1404", + "ansible_current_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "group_names": [ + "ungrouped" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_pipelining": false, + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "role_names": [] + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "ansible_module_compression": "ZIP_DEFLATED", + "ansible_failed_hosts": [], + "ansible_check_mode": false, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_host": "u1404", + "ansible_shell_executable": "/bin/sh", + "inventory_hostname_short": "el6host", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "role_names": [], + "play_hosts": [ + "el6host" + ], + "ansible_sftp_extra_args": "" +} \ No newline at end of file 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 new file mode 100644 index 0000000..1242b1d --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/meta.yaml @@ -0,0 +1,29 @@ +fixtures: + taskvars_in: task_vars_in.json + taskvars_out: task_vars_out.json +task_args: + src: /tmp/deleteme + dest: /tmp/deleteme + private_key: ~/.ssh/id_rsa +_task: + delegate_to: u1404 +_play_context: + shell: None + remote_addr: u1404 + remote_user: root + private_key_file: ~/test.pem +connection: + transport: 'ssh' +hostvars: + '127.0.0.1': {} + '::1': {} + 'localhost': {} +asserts: + - "hasattr(SAM._connection, 'ismock')" + - "SAM._connection.transport == 'ssh'" + - "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['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_with_private_key/task_vars_in.json b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/task_vars_in.json new file mode 100644 index 0000000..b8893ee --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/task_vars_in.json @@ -0,0 +1,379 @@ +{ + "ansible_pipelining": false, + "ansible_docker_extra_args": "", + "ansible_scp_extra_args": "", + "ansible_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "ansible_connection": "smart", + "ansible_ssh_common_args": "", + "environment": [], + "inventory_hostname": "el6host", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "el6host", + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "inventory_file": "inventory", + "role_names": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "role_names": [], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "play_hosts": [ + "el6host" + ], + "ansible_play_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + }, + "ansible_accelerate_port": 5099, + "roledir": null, + "ansible_ssh_extra_args": "", + "ansible_ssh_host": "u1404", + "ansible_current_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "group_names": [ + "ungrouped" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_pipelining": false, + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "role_names": [] + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "ansible_module_compression": "ZIP_DEFLATED", + "ansible_failed_hosts": [], + "ansible_check_mode": false, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_host": "u1404", + "ansible_shell_executable": "/bin/sh", + "inventory_hostname_short": "el6host", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "role_names": [], + "play_hosts": [ + "el6host" + ], + "ansible_sftp_extra_args": "" +} \ No newline at end of file diff --git a/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/task_vars_out.json b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/task_vars_out.json new file mode 100644 index 0000000..0b551f0 --- /dev/null +++ b/tests/unit/plugins/action/fixtures/synchronize/delegate_remote_with_private_key/task_vars_out.json @@ -0,0 +1,387 @@ +{ + "ansible_pipelining": false, + "ansible_docker_extra_args": "", + "ansible_scp_extra_args": "", + "ansible_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "ansible_connection": "smart", + "ansible_ssh_common_args": "", + "environment": [], + "inventory_hostname": "el6host", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "el6host", + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "inventory_file": "inventory", + "role_names": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "role_names": [], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "play_hosts": [ + "el6host" + ], + "ansible_play_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + }, + "ansible_accelerate_port": 5099, + "roledir": null, + "ansible_ssh_extra_args": "", + "ansible_ssh_host": "u1404", + "ansible_current_hosts": [ + "el6host" + ], + "hostvars": { + "el6host": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "el6host", + "inventory_hostname_short": "el6host", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + }, + "u1404": { + "inventory_file": "inventory", + "group_names": [ + "ungrouped" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404", + "::1" + ], + "all": [ + "el6host", + "u1404", + "::1" + ] + }, + "inventory_hostname": "u1404", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "ansible_check_mode": false, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + } + } + }, + "group_names": [ + "ungrouped" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_pipelining": false, + "inventory_file": "inventory", + "ansible_delegated_vars": { + "u1404": { + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "vars": { + "ansible_check_mode": false, + "inventory_hostname": "u1404", + "inventory_file": "inventory", + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "environment": [], + "ansible_ssh_user": "root", + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "group_names": [ + "ungrouped" + ], + "play_hosts": [ + "el6host" + ], + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "role_names": [] + }, + "inventory_hostname_short": "u1404", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "group_names": [ + "ungrouped" + ], + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "ansible_host": "u1404", + "environment": [], + "ansible_play_hosts": [ + "el6host" + ], + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_check_mode": false, + "play_hosts": [ + "el6host" + ], + "role_names": [], + "ansible_port": null, + "ansible_version": { + "major": 2, + "full": "2.2.0", + "string": "2.2.0", + "minor": 2, + "revision": 0 + }, + "ansible_ssh_user": "root" + } + }, + "ansible_module_compression": "ZIP_DEFLATED", + "ansible_failed_hosts": [], + "ansible_check_mode": false, + "groups": { + "ungrouped": [ + "el6host", + "u1404" + ], + "all": [ + "el6host", + "u1404" + ] + }, + "ansible_host": "u1404", + "ansible_shell_executable": "/bin/sh", + "inventory_hostname_short": "el6host", + "omit": "__omit_place_holder__2433ce0463ffd13b68850ce9cdd98a1cde088e22", + "inventory_dir": "/home/jtanner/workspace/issues/AP-15905", + "playbook_dir": "/home/jtanner/workspace/issues/AP-15905", + "ansible_ssh_user": "root", + "role_names": [], + "play_hosts": [ + "el6host" + ], + "ansible_sftp_extra_args": "" +} \ No newline at end of file diff --git a/tests/unit/plugins/action/test_synchronize.py b/tests/unit/plugins/action/test_synchronize.py index 4f78928..f8f5f8a 100644 --- a/tests/unit/plugins/action/test_synchronize.py +++ b/tests/unit/plugins/action/test_synchronize.py @@ -251,6 +251,23 @@ class TestSynchronizeAction(unittest.TestCase): x = SynchronizeTester() x.runtest(fixturepath=os.path.join(self.fixturedir, 'delegate_remote_su')) + @patch('ansible_collections.ansible.posix.plugins.action.synchronize.connection_loader', FakePluginLoader) + def test_basic_with_private_key(self): + x = SynchronizeTester() + x.runtest(fixturepath=os.path.join(self.fixturedir, 'basic_with_private_key')) + + @patch('ansible_collections.ansible.posix.plugins.action.synchronize.connection_loader', FakePluginLoader) + def test_delegate_remote_with_private_key(self): + # delegate to other remote host and use the module param private_key + x = SynchronizeTester() + x.runtest(fixturepath=os.path.join(self.fixturedir, 'delegate_remote_with_private_key')) + + @patch('ansible_collections.ansible.posix.plugins.action.synchronize.connection_loader', FakePluginLoader) + def test_delegate_remote_play_context_private_key(self): + # delegate to other remote host and use the play context private_key + x = SynchronizeTester() + x.runtest(fixturepath=os.path.join(self.fixturedir, 'delegate_remote_play_context_private_key')) + @patch.object(ActionModule, '_low_level_execute_command', side_effect=BreakPoint) @patch.object(ActionModule, '_remote_expand_user', side_effect=ActionModule._remote_expand_user, autospec=True) def test_remote_user_not_in_local_tmpdir(self, spy_remote_expand_user, ll_ec):