Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell provisioner on noexec /tmp #6993

Closed
bbaassssiiee opened this issue Feb 6, 2016 · 3 comments
Closed

shell provisioner on noexec /tmp #6993

bbaassssiiee opened this issue Feb 6, 2016 · 3 comments

Comments

@bbaassssiiee
Copy link

The config.vm.provision script is copied to /tmp, if that is executed on a noexec mounted filesystem I get this error:

==> default: bash: line 2: /tmp/vagrant-shell: Permission denied

A suggested solution: treat the shell script as an input for bash:

    bash /tmp/vagrant-shell

Source file: vagrant/plugins/provisioners/shell/provisioner.rb

@sethvargo
Copy link
Contributor

Hi @bbaassssiiee

Thank you for opening an issue. Unfortunately we cannot just assume bash. Fortunately, the recommended work around is listed in the docs: https://www.vagrantup.com/docs/provisioning/shell.html

To run a script already available on the guest you can use an inline script to invoke the remote script on the guest.

Vagrant.configure("2") do |config|
  config.vm.provision "shell",
    inline: "/bin/sh /path/to/the/script/already/on/the/guest.sh"
end

The recommended pattern is to upload the script using a file provisioner and then manually execute it with your desired interpreter. Thanks! 😄

@Raskil
Copy link

Raskil commented Feb 23, 2016

Hi @sethvargo,
how should your workaround work? Problem is as follows: If you upload the file with a file provisioner, I' m not able to upload it with execute rights from a windows host. Therefore I can't use the shell provisioners path function to execute the script. On the other hand I can not use your provided inline: variant, because that just create /tmp/vagrant-shell with the content "/bin/sh /path/to/the/script/already/on/the/guest.sh" and tries to execute it. Of course the execute then fails, because /tmp is still noexec.
Is it somehow possible to tell the shell provisioner that it should create the tmp-file in a specific path?

Regards

Raskil

@andrewfraley
Copy link

In case anyone else come across this, you need to use the upload_path option to point the script somewhere else other than /tmp.

I use something like this:

config.vm.provision "vagrant preflight", type: "shell",
    path: "scripts/preflight.sh",
    upload_path: '/opt/preflight.sh',
    args: "#{username}"

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants