我有一个问题与在OS X上运行带有Vagrantfile / provision的框有关,该框先前已在Windows上成功测试。盒子具有完全在VM上运行Ansible的特殊性,但我认为问题已经解决。
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "rubicon.vm"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--cpus", "2" ]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
end
config.vm.network "forwarded_port", guest: 8888, host: 8888
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/vagrant"
config.vm.provision :shell,
:keep_color => true,
:inline => "export PYTHONUNBUFFERED=1 && export ANSIBLE_FORCE_COLOR=1 && cd /vagrant && ./provision.sh"
end
在提供步骤中出现错误:
/tmp/vagrant-shell: line 1: ./provision.sh: Permission denied
为了验证是否找到了(1)Provision.sh和(2)用户应该是root用户并拥有所有权限,我使用以下方法修改了Provision行:
:inline => "cd /vagrant && ls -al && echo $USER && ./provision.sh"
输出为:
==> default: drwxr-xr-x 1 vagrant vagrant 204 Aug 12 10:06 .
==> default: drwxr-xr-x 23 root root 4096 Aug 12 10:12 ..
==> default: drwxr-xr-x 1 vagrant vagrant 136 Aug 11 14:28 ansible
==> default: -rw-r--r-- 1 vagrant vagrant 767 Aug 11 14:35 provision.sh
==> default: drwxr-xr-x 1 vagrant vagrant 102 Aug 11 14:30 .vagrant
==> default: -rwxr-xr-x 1 vagrant vagrant 785 Aug 12 10:06 Vagrantfile
==> default: root
==> default: /tmp/vagrant-shell: line 1: ./provision.sh: Permission denied
所以没有什么奇怪的。
最佳答案
您需要授予Provision.sh的执行权限
chmod +x provision.sh