Kate
Kate

Reputation: 294

Ansible failed to transfer file to Provision a Vagrant VM with Ansible on Windows/Cygwin

I am running vagrant VM with ansible on Windows cygwin. I started to get the following errors

PLAY [Setup Elasticsearch] ****************************************************
GATHERING FACTS *************************************************************** 
fatal: [127.0.0.1] => failed to transfer file to /home/user/.ansible/tmp/ansible-tmp-1454075801.6-225353733730018/setup

TASK: [generic | Install generic packages via yum] ****************************
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/local.py", line 114, in put_file
shutil.copyfile(in_path, out_path)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: '/home/user/.ansible/tmp/ansible-tmp-1454075801.6-225353733730018/setup'
fatal: [127.0.0.1] => failed to transfer file to /home/user/.ansible/tmp/ansible-tmp-1454075802.03-97639409350973/yum

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/user/main.retry

127.0.0.1                  : ok=0    changed=0    unreachable=2    failed=0

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/local.py", line 114, in put_file
shutil.copyfile(in_path, out_path)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: u'/home/user/.ansible/tmp/ansible-tmp-1454075802.03-97639409350973/yum'
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

I have added already the following code into ansible.cfg but it didn't help

[ssh_connection]
scp_if_ssh=True

[ssh_connection]
control_path = /tmp

Each time it fail to create file in the following folder C:\HashiCorp\Vagrant\embedded\home\user.ansible\tmp. However permission is set to full control for everyone Any ideas would be much appreciated

Upvotes: 0

Views: 687

Answers (1)

Kate
Kate

Reputation: 294

I have found a solution. It is better to run ansible playbook on the guest host instead of running it on master host. To make it work use "ansible_local" provision. For example,

frontend.vm.provision "ansible_local" do |ansible| ansible.playbook = "ansible/frontend.yml" end It will download and install ansible on guest host machine and there is no need to install ansible via cygwin

Upvotes: 1

Related Questions