diff --git a/changelogs/fragments/316_ansible_ssh_host_handling.yml b/changelogs/fragments/316_ansible_ssh_host_handling.yml new file mode 100644 index 0000000..2945138 --- /dev/null +++ b/changelogs/fragments/316_ansible_ssh_host_handling.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- synchronize - handle ansible_ssh_host the same as ansible_host (https://github.com/ansible-collections/ansible.posix/issues/298). diff --git a/plugins/action/synchronize.py b/plugins/action/synchronize.py index a5752b9..a646671 100644 --- a/plugins/action/synchronize.py +++ b/plugins/action/synchronize.py @@ -235,10 +235,11 @@ class ActionModule(ActionBase): src_host = '127.0.0.1' inventory_hostname = task_vars.get('inventory_hostname') dest_host_inventory_vars = task_vars['hostvars'].get(inventory_hostname) - dest_host = dest_host_inventory_vars.get('ansible_host', inventory_hostname) - + dest_host = dest_host_inventory_vars.get('ansible_host') or \ + dest_host_inventory_vars.get('ansible_ssh_host', inventory_hostname) dest_host_ids = [hostid for hostid in (dest_host_inventory_vars.get('inventory_hostname'), - dest_host_inventory_vars.get('ansible_host')) + dest_host_inventory_vars.get('ansible_host'), + dest_host_inventory_vars.get('ansible_ssh_host')) if hostid is not None] localhost_ports = set()