From 6e74dae76e0986231657c5b5a52bed7fb32040da Mon Sep 17 00:00:00 2001 From: Hideki Saito Date: Fri, 28 Jan 2022 10:51:58 +0000 Subject: [PATCH] Added handling ansible_ssh_host the same as ansible_host - Fixes #298 --- changelogs/fragments/316_ansible_ssh_host_handling.yml | 3 +++ plugins/action/synchronize.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/316_ansible_ssh_host_handling.yml 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()