我正在使用Vagrant,并试图使Ansible能够使用它。因为我是在使用Python3.5.0的virtualenv中工作,所以我必须使用Ansible-Local "main“,因为我没有运行Python2.x。
无论如何,除了vagrant up找不到Ansible之外,所有东西都能工作。下面是调用的输出:
==> default: Running provisioner: ansible_local...
default: Installing Ansible...
The Ansible software could not be found! Please verify
that Ansible is correctly installed on your guest system.
If you haven't installed Ansible yet, please install Ansible
on your Vagrant basebox, or enable the automated setup with the
`install` option of this provisioner. Please check
https://docs.vagrantup.com/v2/provisioning/ansible_local.html
for more information.但是,如果我使用vagrant ssh访问VM,那么Ansible显然是安装的:
vagrant@vagrant-ubuntu-trusty-64:~$ ansible --version
ansible 2.0.0.2
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides我不知所措。我可以运行ansible-playbook server.yml,而SSH已经进入服务器,并且工作正常。然而,我使用Ansible的全部要点是,我可以通过Vagrant自动运行它。下面是我的Vagrantfile文件的相关部分:
config.vm.provision "ansible_local" do |ansible|
ansible.install = true
ansible.version = "latest"
ansible.sudo = true
ansible.playbook = "server.yml"
end如有任何建议,将不胜感激。谢谢!
发布于 2016-02-09 23:25:36
通过在调试模式下打开框:
VAGRANT_LOG=debug vagrant up显示:
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: ansible-galaxy --help && ansible-playbook --help (sudo=false)
DEBUG ssh: stderr: ERROR! Missing required action
DEBUG ssh: stdout: Usage: ansible-galaxy [delete|import|info|init|install|list|login|remove|search|setup] [--help] [options] ...
Options:
-h, --help show this help message and exit
-v, --verbose verbose mode (-vvv for more, -vvvv to enable connection
debugging)
--version show program's version number and exit
DEBUG ssh: Exit status: 5不可接受的星系--帮助是问题所在,正如它所期望的那样。因为失败了,流浪汉认为安装有问题。
看起来这个问题已经在master branch上得到了解决,并且将出现在next version中。
你可以尝试的是:
# -*- mode: ruby -*-
# vi: set ft=ruby :
$install_ansible = <<SCRIPT
apt-get -y install software-properties-common
apt-add-repository ppa:ansible/ansible
apt-get -y update
apt-get -y install ansible
SCRIPT
Vagrant.configure(2) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.provision 'shell', inline: $install_ansible
# Patch for https://github.com/mitchellh/vagrant/issues/6793
config.vm.provision "shell" do |s|
s.inline = '[[ ! -f $1 ]] || grep -F -q "$2" $1 || sed -i "/__main__/a \\ $2" $1'
s.args = ['/usr/bin/ansible-galaxy', "if sys.argv == ['/usr/bin/ansible-galaxy', '--help']: sys.argv.insert(1, 'info')"]
end
config.vm.provision :ansible_local do |ansible|
ansible.sudo = true
ansible.playbook = 'server.yml'
end
end注意:对于以下代码段,请记入MasonM的贷方:
# Patch for https://github.com/mitchellh/vagrant/issues/6793
config.vm.provision "shell" do |s|
s.inline = '[[ ! -f $1 ]] || grep -F -q "$2" $1 || sed -i "/__main__/a \\ $2" $1'
s.args = ['/usr/bin/ansible-galaxy', "if sys.argv == ['/usr/bin/ansible-galaxy', '--help']: sys.argv.insert(1, 'info')"]
end 或者,在等待补丁发布时,另一个选项是构建vagrant from source。
https://stackoverflow.com/questions/35299304
复制相似问题