I am trying to use a jumpbox to reach my target VM on ansible. I have the following file structure
play.yaml
hosts
serverA
serverB
testServers/
serverX
serverY
group_vars/
all.yml
server[X,Y] host file contains
[serverType]
1.2.3.4
all.yml file under hosts/testServers/ contain
ansible_ssh_private_key_file: key.priv
proxy_user: myServiceAccount
proxy_user_key: key.priv
ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="ssh -i {{ proxy_user_key }} -W %h:%p -q {{ proxy_user }}@{{ bastion_host }}
I have a ping module in play.yaml
- hosts: all
gather_facts: true
tasks:
- action: ping
I run the following command
ansible-playbook -vvvv play.yaml -i hosts/testServers/serverX
-e ansible_ssh_user="$LDAP_USER" -e ansible_ssh_pass="$LDAP_PASS"
-e ansible_become_pass="$LDAP_PASS"
-e bastion_host="$BASTION_NAME"
I get the following error
Failed to create temporary directory.In some cases, you may have
been able to authenticate and did not have permissions on the
target directory. Consider changing the remote tmp path in
ansible.cfg to a path rooted in \"/tmp\", for more error
information use -vvv. Failed command was: ( umask 77 && mkdir -p
\"` echo /tmp `\"&& mkdir
/tmp/ansible-tmp-1626262883.727861-210-80403864334304 && echo
ansible-tmp-1626262883.727861-210-80403864334304=\"` echo
/tmp/ansible-tmp-1626262883.727861-210-80403864334304 `\" ),
exited with result 6
To consider
- the ssh_user has permissions to rwx permissions on /tmp
- the
remote_tmpis set to/tmpin ansible.cfg - the ssh configs are set correctly on the source VM and the keypairs are working as expected by following this tutorial https://blog.ruanbekker.com/blog/2020/10/26/use-a-ssh-jump-host-with-ansible/