provision.sh 的 Vagrant 权限在 osx 被拒绝

Vagrant permission to provision.sh denied on osx

我有一个问题与 运行 OS X 上的一个盒子有关,Vagrantfile/provision 之前在 Windows 上测试成功。该盒子具有 运行 Ansible 完全在 VM 上的特殊性,但我认为问题早于此。

# -*- 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 用户并拥有所有权限,我修改了规定行:

: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