You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When providing a relative path to ssh key, synchronize can't find it.
More precisely, this problem occurs when the ansible playbook is not in the directory where ansible is run from. In that case, other ansible tasks find the ssh key just fine, but synchronize does not.
all:
hosts:
myhost:
ansible_host: <IP>vars:
ansible_ssh_private_key_file: id_rsa# Replacing this with line below fixes the playbook#ansible_ssh_private_key_file: "{{'id_rsa'| realpath }}"
Somewhat related to this: While the above behavior demonstrates that synchronize uses the ansible_ssh_private_key_file variable [1], it seems to entirely ignore the ansible_ssh_common_args variable.
ansible_ssh_common_args can contain important settings that are required for connecting to the host (e.g. ProxyJumps), so it is very unexpected that this variable is ignored. Happy to open another bug for this.
[1] By the way, where does this happen? I looked through the synchronize module source code to understand why ansible_ssh_private_key_file was used but not ansible_ssh_common_args, but I could not find ansible_ssh_private_key_file in the module.
similarly, when using ssh arguments implied by use_ssh_args option the relative path to an identity file isn't resolved, see this previous report.
it would be helpful when an experienced Ansible developer could give advice where the expansion to an absolute path should happen. within the plugin or when options are read or somewher in between?
SUMMARY
When providing a relative path to ssh key, synchronize can't find it.
More precisely, this problem occurs when the ansible playbook is not in the directory where ansible is run from. In that case, other ansible tasks find the ssh key just fine, but synchronize does not.
Related (fixed) bug from 2017 ansible/ansible-modules-core#18
ISSUE TYPE
COMPONENT NAME
ansible.posix.synchronize
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
CentOS 7.9
STEPS TO REPRODUCE
Directory layout
With playbook.yml
hosts
ansible.cfg
EXPECTED RESULTS
synchronize finds ssh key
id_rsa
ACTUAL RESULTS
ansible finds ssh key
id_rsa
but
synchronize
fails withThe text was updated successfully, but these errors were encountered: