我正在使用Vagrant并尝试使Ansible能够使用它.因为我在virtualenv使用Python 3.5.0,我必须使用Ansible-Local - "主"Ansible将不会在我的主机上运行,因为我没有运行Python 2.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.
Run Code Online (Sandbox Code Playgroud)
但是,如果我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
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么办.我可以运行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
Run Code Online (Sandbox Code Playgroud)
任何建议都非常感谢.谢谢!
通过将盒子置于调试模式:
VAGRANT_LOG=debug vagrant up
Run Code Online (Sandbox Code Playgroud)
显示:
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
Run Code Online (Sandbox Code Playgroud)
ansible-galaxy --help是问题,因为它期待一个行动.因为失败了,vagrant认为安装有问题.
你可以尝试的是:
# -*- 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
Run Code Online (Sandbox Code Playgroud)
注意:感谢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
Run Code Online (Sandbox Code Playgroud)
或者等待修复程序被释放时的另一个选择是从源代码构建vagrant.
| 归档时间: |
|
| 查看次数: |
3876 次 |
| 最近记录: |