Skip to content
New issue

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

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

Already on GitHub? # to your account

vagrant package --vagrantfile not working #364

Closed
jamesla opened this issue Oct 11, 2020 · 2 comments
Closed

vagrant package --vagrantfile not working #364

jamesla opened this issue Oct 11, 2020 · 2 comments

Comments

@jamesla
Copy link
Contributor

jamesla commented Oct 11, 2020

If I run the command vagrant package --vagrantfile Vagrantfile --output mybox.box with the following vagrantfile:

#Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "test"
  config.vm.provision "shell", inline: <<-SHELL
    echo "HELLO WORLD"
  SHELL
end

The box is created however when I import and run the newly created box the vagrantfile isn't obeyed and it never echo's HELLO WORLD.

However when I do this using the virtualbox provider it works ok.

I am not sure but when I extracted mybox.box I found my vagrantfile inside the includes directory however it was _Vagrantfile rather than Vagrantfile, which it wasn't when I checked the virtualbox equivalent.

Any ideas how I can fix this?

EDIT:

Thought I would add some steps to reproduce to make this easier.

  1. Create a new vagrant box
    vagrant init bento/ubuntu-16.04

  2. Create a new Vagrantfile with a shell provisioner top test with
    echo 'Vagrant.configure("2") do |config| config.vm.provision "shell", inline: <<-SHELL echo "HELLO WORLD" SHELL end' > NewVagrantFile

  3. Launch the box
    vagrant up

  4. Package the box
    vagrant package --vagrantfile NewVagrantFile

  5. Add the new box
    vagrant box add newbox package.box

  6. Create new vagrant box and test

mkdir newbox && cd newbox
vagrant init newbox
vagrant up

You would expect to see the shell provisioner from NewVagrantFile say "HELLO WORLD" while provisioning but it doesn't. These steps do work with the virtualbox provider.

@jamesla
Copy link
Contributor Author

jamesla commented Oct 25, 2020

I have fixed this and opened the following PR here

#368

@legal90
Copy link
Collaborator

legal90 commented Oct 27, 2020

Fixed by #368 . Thanks, @jamesla !

@legal90 legal90 closed this as completed Oct 27, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants