我正在使用 vagrant 1.6.2,并将其与 ubuntu 14.04 机器一起使用。当我vagrant provision
这样做时,它会运行一个.sh
脚本。
#!/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
但我明白了/tmp/vagrant-shell: line 24: ansible: command not found
但当我进入框并输入时,ansible
它确实有效。我如何才能让它通过我的.sh
文件工作?
谢谢
答案1
尝试将source /home/vagrant/ansible/hacking/env-setup
直接移动到前面ansible playbook.yml
以确保每次在调用 ansible 之前运行它。