Ansible无法在Windows / Cygwin上使用Ansible将文件传输到Provision a Vagrant VM

时间:2016-01-29 14:07:26

标签: cygwin vagrant ansible

我在Windows cygwin上运行带有ansible的vagrant VM。我开始收到以下错误

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.

我已将以下代码添加到ansible.cfg中,但它没有帮助

[ssh_connection]
scp_if_ssh=True

[ssh_connection]
control_path = /tmp

每次无法在以下文件夹C:\ HashiCorp \ Vagrant \ embedded \ home \ user.ansible \ tmp中创建文件。但是,权限设置为完全控制每个人 任何想法将不胜感激

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。最好在来宾主机上运行ansible playbook,而不是在主控主机上运行它。为了使其工作使用“ansible_local”规定。例如,

frontend.vm.provision "ansible_local" do |ansible| ansible.playbook = "ansible/frontend.yml" end 它将在来宾主机上下载并安装ansible,无需通过cygwin安装ansible