The other day I was using ansible_local provisioning for Vagrant. After the usual
vagrant up
it gave me this obsure error:
==> myserver: Running provisioner: ansible_local...
myserver: 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.
Guess what? It is a bug in Vagrant 1.8.1. It is already fixed in 1.8.4; however, if updating Vagrant is not an option, you can as well work around this bug by adding the following code in your Vagrantfile (this snippet is for RedHat-based distributions; for Debian-based you need to change ‘shell’ line):
# Patch for https://github.com/mitchellh/vagrant/issues/6793
config.vm.provision "shell", inline: 'sudo yum install -y epel-release && sudo yum install -y ansible'
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