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

vagrant builder's vagrantfile template mixes source and output #7

Open
ghost opened this issue Apr 21, 2021 · 0 comments
Open

vagrant builder's vagrantfile template mixes source and output #7

ghost opened this issue Apr 21, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 21, 2021

This issue was originally opened by @andkononykhin as hashicorp/packer#8245. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

A patch hashicorp/packer#7957 introduced new multi-machine vagrantfile template for vagrant builder:

  • source box is taken by source_path but not by box_name
  • for output machine it sets box name of the source box as a vm.box but also sets output package.box file as vm.box_url which seems confusing

It leads to:

  • vagrant up itself during packer build tries to add box for source machine and it might fail the build if the source path is too long
  • two boxes are actually added during the build: one by packer with box_name value and one by vagrant with source_path value as a name
  • vagrant up output will bring up machine based on a source box instead of output one

Packer version

1.4.4

Simplified Packer Buildfile

{
  "builders": [
    {
      "type"                : "vagrant",
      "provider"            : "virtualbox",
      "source_path"         : "{{template_dir}}/../../bla/bla/bla/long-path/package.box",
      "add_force"           : true,
      "box_name"            : "centos7-base",
      "output_dir"          : "{{template_dir}}/../../.boxes/centos7-with-new-dir",
      "communicator"        : "ssh",
      ...
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "mkdir -p /tmp/new"
      ]
    }
  ]
}

Generated Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.define "source", autostart: false do |source|
        source.vm.box = "... <skipped> .../../../bla/bla/bla/long-path/package.box"
  end
  config.vm.define "output" do |output|
        output.vm.box = "centos7-base"
        output.vm.box_url = "file://package.box"
  end
  config.vm.synced_folder ".", "/vagrant", disabled: true
end

Operating system and Environment details

centos7

Log Fragments and crash.log files

2019/10/18 14:46:51 packer: 2019/10/18 14:46:51 Calling Vagrant CLI: []string{"up", "source", "--provider=virtualbox"}
2019/10/18 14:46:55 packer: 2019/10/18 14:46:55 [vagrant driver] stdout: Bringing machine 'source' up with 'virtualbox' provider...
2019/10/18 14:46:55 packer: ==> source: Box '... <skipped> .../../../bla/bla/bla/long-path/package.box' could not be found. Attempting to find and install...
2019/10/18 14:46:55 packer:     source: Box Provider: virtualbox
2019/10/18 14:46:55 packer:     source: Box Version: >= 0
2019/10/18 14:46:55 packer: ==> source: Box file was not detected as metadata. Adding it directly...
2019/10/18 14:46:55 packer: ==> source: Adding box '... <skipped> .../../../bla/bla/bla/long-path/package.box' (v0) for provider: virtualbox
2019/10/18 14:46:55 packer:     source: Unpacking necessary files from: file://... <skipped> .../../../bla/bla/bla/long-path/package.box

2019/10/18 14:46:55 packer: 2019/10/18 14:46:55 [vagrant driver] stderr: /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:230:in `mkdir': File name too long @ dir_s_mkdir -  ... <skipped> ...-VAGRANTSLASH-..-VAGRANTSLASH-..-VAGRANTSLASH-bla-VAGRANTSLASH-bla-VAGRANTSLASH-bla-VAGRANTSLASH-long-path-VAGRANTSLASH-package.box (Errno::ENAMETOOLONG)
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:230:in `fu_mkdir'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:208:in `block (2 levels) in mkdir_p'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:206:in `reverse_each'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:206:in `block in mkdir_p'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:191:in `each'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/fileutils.rb:191:in `mkdir_p'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/pathname.rb:576:in `mkpath'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:161:in `block (3 levels) in add'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:470:in `with_temp_dir'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:134:in `block (2 levels) in add'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:470:in `with_temp_dir'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:115:in `block in add'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:457:in `block in with_collection_lock'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:456:in `with_collection_lock'
2019/10/18 14:46:55 packer:     from /tmp/.mount_vagran5Uh4mU/usr/gembundle/gems/vagrant-2.2.5/lib/vagrant/box_collection.rb:104:in `add'
==> vagrant: destroying Vagrant box...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants