0

I am using vagrant 1.6.2 and using it with an ubuntu 14.04 box. When I do vagrant provision it runs an .sh script.

#!/usr/bin/env bash

export DEBIAN_FRONTEND=noninteractive

apt-get update -qq
apt-get install -y make git-core

if [[ ! -d /home/vagrant/ansible ]]; then
    # Install Ansible dependencies.
    apt-get install -y python-mysqldb python-yaml python-jinja2 python-paramiko sshpass

    # Checkout the Ansible repository.
    git clone https://github.com/ansible/ansible.git /home/vagrant/ansible

    mkdir /etc/ansible

    echo "localhost" > /etc/ansible/hosts

    source /home/vagrant/ansible/hacking/env-setup
    echo "source /home/vagrant/ansible/hacking/env-setup" >> /home/vagrant/.bashrc
fi

cd /home/vagrant/me/provisioning
ansible playbook.yml

But I get the message /tmp/vagrant-shell: line 24: ansible: command not found

But when I go into the box and type ansible it does work. How can I make it work through my .sh file?

Thanks

1

Try to move the source /home/vagrant/ansible/hacking/env-setup directly in front of the ansible playbook.yml to ensure it is run every time before ansible is called.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.