Skip to content

vagrant package --vagrantfile not working  #364

@jamesla

Description

@jamesla

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions