}

Ansible: failed to transfer file to ~/.ansible/tmp/ansible-tmp-xxx/setup.py: [Errno 2] No such file or directory

Created:

The error

When running ansible localhost using cloud-init, the following error is given:

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "failed to transfer file to ~/.ansible/tmp/ansible-tmp-1487178101.89-244463273612786/setup.py: [Errno 2] No such file or directory: '~/.ansible/tmp/ansible-tmp-1487178101.89-244463273612786/setup.py'"}
        to retry, use: --limit @/tmp/ansible/server/deploy_rancher_master.retry

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1

Solution 1:

Set those in ansible.cfg:

remote_tmp = $HOME/.ansible/tmp
local_tmp = $HOME/.ansible/tmp

Solution 2

Pass those environment variables to ansible-local command:

ANSIBLE_LOCAL_TEMP=$HOME/.ansible/tmp
ANSIBLE_REMOTE_TEMP=$HOME/.ansible/tmp

Solution 3:

Downgrade of ansible to version 2.2.0.0.