-
Notifications
You must be signed in to change notification settings - Fork 167
Module synchronize: ansible_host in host vars pointing to a variable is treated as literal #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@kimu thank you for reporting this issue.
$ ansible-playbook -i <PATH/TO/INVENTORY> <PATH/TO/PLAYBOOK> -e managed_node="server10"
---
ansible_host: "{{ managed_node }}" I'm thinking that it possibly be regarding the following variable precedence: |
Hi @saito-hideki. Passing the values as extra_vars works. The vars I am using are at level The vault file is included in the playbook
Host vars are Vault vars have already been parsed at this stage and the ansible_host value in As you can read in the description of this issue, this is actually the case for all other vars from the same source
All May be that |
@kimu ahh, thank you for the clarification :) |
Uh oh!
There was an error while loading. Please reload this page.
SUMMARY
Module
ansible.posix.synchronize
. The parameteransible_host
in a file contained inhost_vars
pointing to another variable is treated as string literal.In my case the variable is in a vault protected file, but I guess the same goes for any other location.
hosts.ini
host_vars/proxmox-01.mydomain.com.yml
ansible_ssh_private_key_file
andansible_ssh_user
are correctly resolved, the value inansible_host
is treated as a literal.With this task
I get this error
where you can see that
{{ vault_hosts.proxmox_01.host }}
is treated as a string literal instead of being resolved whenhost_vars/proxmox0-1.mydomain.com.yml
is parsed.ansible_ssh_private_key_file
is correctly resolved to/home/user/.ssh/proxmox01_key
ansible_ssh_user
is correctly resolved toroot
as inroot@{{ vault_hosts.proxmox_01.host }}
ansible_host
is not resolved and the value is treated as a string literal{{ vault_hosts.proxmox_01.host }}
The error is
Unexpected remote arg: }}:/root/test-folder
If the value in
host_vars/proxmox-01.mydomain.com.yml
foransible_host
is changed to an IP addressthe command is successfully executed.
The original configuration works for any another module I have used so far. This problem seems to be affecting only
ansible.posix.synchronize
.ISSUE TYPE
COMPONENT NAME
ansible.proxy.synchronize
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Windows 11. WSL2 with Ubuntu 20.04 LTS.
STEPS TO REPRODUCE
See above.
EXPECTED RESULTS
ansible_host
value should be correctly parsed as for any other value in a host_vars files instead of being treated as a string literal.ACTUAL RESULTS
ansible_host
value in a host_vars file is treated as a string literal making the rsync command failing.The text was updated successfully, but these errors were encountered: