Skip to content

Packer plugin needs an architecture parameter. Packer builder does not download boxes with explicitly set architecture. #102

@mykelalvis

Description

@mykelalvis

Overview of the Issue

When building boxes in Vagrant cloud, if the architecture is explicitly set (why wouldn't it be?) during build, the vagrant box add command fails on subsequent use. Ostensibly, this is due to a "not found" for the box in question.

Specifying the architecture during a cloud version/provider upload interferes with using that arch later.

  • This may be a issue with the interaction between vagrant and the packer plugin.
  • I would expect packer's call to vagrant box add using provider/version to use the default arch value in Vagrant cloud without specifying architecture, but that doesn't seem to happen (see logs at bottom).
  • Since it doesn't use the default, I would expect to be able to specify the architecture within the vagrant builder source but that does not appear to be possible.

Reproduction Steps

Attempt to build a box with packer and virtualbox using this source

source "vagrant" "f38ansible" {
  communicator = "ssh"
  source_path = "mykelalvis/fedora38base"
  provider = "virtualbox"
  box_version = "0.0.1"
  add_force = true
}

Plugin and Packer version

Packer version: 1.9.4 [go1.20.7 windows amd64]

Plugin is 1.1.1_x5.0_windows_amd64 per the error below

Simplified Packer Buildfile

packer {
  required_plugins {
    vagrant = {
      source  = "github.com/hashicorp/vagrant"
      version = "~> 1"
    }
    ansible = {
      version = "~> 1"
      source = "github.com/hashicorp/ansible"
    }
  }
}
source "vagrant" "f38ansible" {
  communicator = "ssh"
  source_path = "mykelalvis/fedora38base"
  provider = "virtualbox"
  box_version = "0.0.1"
  add_force = true
}

build {
  sources = ["source.vagrant.f38ansible"]

}

Operating system and Environment details

Win 11-64 fully updated

Log Fragments and crash.log files

2023/10/22 18:13:07 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:07 [vagrant] Calling box add with following args mykelalvis/fedora38base --box-version 0.0.1 --force --provider virtualbox
2023/10/22 18:13:07 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:07 Calling Vagrant CLI: []string{"box", "add", "mykelalvis/fedora38base", "--box-version", "0.0.1", "--force", "--provider", "virtualbox"}
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stdout: ==> box: Loading metadata for box 'mykelalvis/fedora38base'
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stdout:     box: URL: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: The box you're attempting to add doesn't support the provider
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: you requested. Please find an alternate box or use an alternate
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: provider. Double-check your requested provider to verify you didn't
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: simply misspell it.
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr:
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: If you're adding a box from HashiCorp's Vagrant Cloud, make sure the box is
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: released.
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr:
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: Name: mykelalvis/fedora38base
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: Address: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
2023/10/22 18:13:10 packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe plugin: 2023/10/22 18:13:10 [vagrant driver] stderr: Requested provider: virtualbox (x64)

For reference, here is a series of vagrant box add command outputs. Note that in Vagrant cloud, the amd64 VirtualBox provider is specified as the default provider.

PS C:\Users\mykel> vagrant -v
Vagrant 2.4.0
PS C:\Users\mykel> vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.
PS C:\Users\mykel> vagrant box add mykelalvis/fedora38base
==> box: Loading metadata for box 'mykelalvis/fedora38base'
    box: URL: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
The box you're attempting to add has no available version that
matches the constraints you requested. Please double-check your
settings. Also verify that if you specified version constraints,
that the provider you wish to use is available for these constraints.

Box: mykelalvis/fedora38base
Address: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
Constraints: >= 0
Available versions: 0.0.1
PS C:\Users\mykel> vagrant box add --box-version 0.0.1 mykelalvis/fedora38base
==> box: Loading metadata for box 'mykelalvis/fedora38base'
    box: URL: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
The box you're attempting to add has no available version that
matches the constraints you requested. Please double-check your
settings. Also verify that if you specified version constraints,
that the provider you wish to use is available for these constraints.

Box: mykelalvis/fedora38base
Address: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
Constraints: 0.0.1
Available versions: 0.0.1
PS C:\Users\mykel> vagrant box add --box-version 0.0.1 --architecture amd64 mykelalvis/fedora38base
==> box: Loading metadata for box 'mykelalvis/fedora38base'
    box: URL: https://vagrantcloud.com/api/v2/vagrant/mykelalvis/fedora38base
==> box: Adding box 'mykelalvis/fedora38base' (v0.0.1) for provider: virtualbox (amd64)
    box: Downloading: https://vagrantcloud.com/mykelalvis/boxes/fedora38base/versions/0.0.1/providers/virtualbox/amd64/vagrant.box
    box:
==> box: Successfully added box 'mykelalvis/fedora38base' (v0.0.1) for 'virtualbox (amd64)'!
PS C:\Users\mykel>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions