0

我收到以下错误

==> 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.

我正在使用 vagrant-cachier 插件进行作曲家供应商缓存并安装了 ansible。可能是什么问题呢?

4

1 回答 1

1

正如@ydaetskcoR 所说,您在主机上缺少 Ansible。或者,您可以在本地运行 playbook,但 Vagrant 附带的配置器不支持,因此您必须使用 shell 配置器:

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
于 2015-05-18T18:46:06.390 回答