3ND
3ND

Reputation: 430

vagrant provisioning with ansible error

I'm getting the following error on

==> default: Configuring cache buckets...
==> default: Running provisioner: ansible... 

The executable 'ansible-playbook' Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.

I'm using vagrant-cachier plugin for composer vendor caching and ansible is installed. What could be the problem?

Upvotes: 0

Views: 681

Answers (1)

Nathan Hoover
Nathan Hoover

Reputation: 636

As @ydaetskcoR said, you're missing Ansible on the host machine. Alternatively, you can run the playbooks locally, but the provisioner that ships with Vagrant doesn't support that, so you'll have to do it with a shell provisioner:

config.vm.synced_folder "ansible", "/opt/ansible"

config.vm.provision "ansible", type: "shell" do |s|
  s.inline = <<SCRIPT
    hash ansible-playbook &> /dev/null
    if [ $? -eq 0 ]; then
      echo Ansible already installed.
    else
      echo $(date +"%T"): Updating APT database.
      apt-get update &> /dev/null
      echo $(date +"%T"): Installing Python and pip.
      apt-get -y install python-pip python-dev &> /dev/null
      echo $(date +"%T"): Installing Ansible via pip.
      pip install ansible &> /dev/null
    fi
    mkdir -p /etc/ansible
    hostname > /etc/ansible/hosts
    echo $(date +"%T"): Executing Ansible playbook.
    ansible-playbook /opt/ansible/playbook.yml --connection=local
SCRIPT
end

Upvotes: 1

Related Questions