mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-11-24 09:53:40 +00:00
ACA-4558: synchronize: use ansible_host from play vars when absent from hostvars (#779)
* synchronize: use ansible_host from play vars when absent from hostvars The synchronize action plugin built the rsync/ssh destination exclusively from task_vars['hostvars'][inventory_hostname]. When ansible_host was set via play-level vars: rather than inventory/ group_vars/host_vars, it was absent from that snapshot and the plugin silently fell back to bare inventory_hostname, producing 'Host not found' errors when ansible_host differed from the inventory name. Fixes #469
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
---
|
||||
# Test that ansible_host set via play-level vars: (present in task_vars but
|
||||
# absent from the hostvars snapshot for the target host) is correctly used
|
||||
# to build the rsync destination instead of falling back to inventory_hostname.
|
||||
# Regression test for https://github.com/ansible-collections/ansible.posix/issues/469
|
||||
fixtures:
|
||||
taskvars_in: taskvars_in.json
|
||||
taskvars_out: taskvars_out.json
|
||||
connection:
|
||||
transport: ssh
|
||||
hostvars:
|
||||
127.0.0.1: {}
|
||||
::1: {}
|
||||
localhost: {}
|
||||
asserts:
|
||||
- hasattr(SAM._connection, 'ismock')
|
||||
- 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.example.org:/tmp/deleteme'
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"inventory_hostname": "el6host",
|
||||
"ansible_user": "root",
|
||||
"ansible_host": "el6host.example.org",
|
||||
"hostvars": {
|
||||
"el6host": {}
|
||||
},
|
||||
"vars": {
|
||||
"ansible_host": "el6host.example.org"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user