How i can use post processor of type "vagrant" with qemu artifacts, they seem not supported by my packer configuration.
During packer build after qemu builder i use some post-processors to create ovf from a vdmk. with this tool
Option keep artifact" : true
seem to doesn't work and during qemu builder the expected qcow2 file doesn't appear in my build directory (just a file without extension "buster" is created)
Thanks for your help.
Command:
packer build -parallel=false -force config.json
The error :
==> qemu: Running post-processor: {{.Provider}}.box (type vagrant)
Build 'qemu' errored: 1 error(s) occurred:
* Post-processor failed: Unknown artifact type, can't build box:
Some builds didn't complete successfully and had errors: Mar 25 17:01:45 --> qemu: 1 error(s) occurred:
* Post-processor failed: Unknown artifact type, can't build box:
==> Builds finished but no artifacts were created.
My config.json
{
"builders": [{
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/buster-preseed.cfg <wait>",
"auto <wait>",
"locale=en_US.UTF-8 <wait>",
"netcfg/get_hostname={{ .Name }} <wait>",
"netcfg/get_domain=vagrantup.com <wait>",
"debconf/frontend=noninteractive <wait>",
"console-setup/ask_detect=false <wait>",
"kbd-chooser/method=us <wait>",
"console-keymaps-at/keymap=us <wait>",
"keyboard-configuration/xkb-keymap=us <wait>",
"net.ifnames=0 <wait>",
"<enter><wait>"
],
"disk_size": "20280",
"disk_interface": "virtio",
"headless": true,
"http_directory": "http",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "sha256",
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso",
"type": "qemu",
"format": "qcow2",
"accelerator": "hvf",
"qemuargs": [
["-m", "1024M"],
["-smp", "2"]
],
"ssh_password": "vagrant",
"ssh_username": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'vagrant' | sudo /sbin/halt -p",
"output_directory": "{{user `output_dir`}}",
"vm_name": "{{user `vm_name`}}"
},
{
"boot_command": [
"<up><wait><tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg PACKER_USER=vagrant PACKER_AUTHORIZED_KEY={{ .SSHPublicKey | urlquery }}<enter>"
],
"headless": true,
"checksum": "{{user `iso_checksum`}}",
"checksum_type": "sha256",
"type": "virtualbox-ovf",
"format": "ovf",
"source_path": "{{user `vm_name`}}.ovf",
"guest_additions_mode": "disable",
"virtualbox_version_file": "",
"communicator": "none",
"output_directory": "{{user `output_dir`}}",
"shutdown_command": "",
"shutdown_timeout": "1s",
"vm_name": "{{user `vm_name`}}"
}
],
"provisioners": [{
"type": "file",
"source": "res",
"destination": "/tmp/res",
"only": ["qemu"]
},
{
"type": "shell",
"pause_before": "5s",
"execute_command": "echo 'vagrant'| {{.Vars}} sudo --preserve-env --stdin sh '{{.Path}}'",
"environment_vars": [
"VAGRANT_BUILDER_FS=/"
],
"scripts": [
"../helpers/vagrant-setup",
"scripts/vagrant.sh",
"scripts/temp_install.sh",
"scripts/networking.sh",
"scripts/cleanup.sh",
"scripts/minimize.sh"
],
"only": ["qemu"]
}
],
"post-processors": [
[{
"type": "shell-local",
"environment_vars": [
"VM_NAME={{user `vm_name`}}",
"OUTPUT={{user `output_dir`}}"
],
"script": "scripts/to-ovf-init.sh",
"keep_input_artifact": true,
"only": ["qemu"]
},
{
"type": "shell-local",
"environment_vars": [
"VM_NAME={{user `vm_name`}}",
"OUTPUT={{user `output_dir`}}",
"WORK_PATH=./"
],
"script": "scripts/to-ovf-linux.sh",
"only_on": "linux",
"keep_input_artifact": true,
"only": ["qemu"]
},
{
"type": "shell-local",
"environment_vars": [
"VM_NAME={{user `vm_name`}}",
"OUTPUT={{user `output_dir`}}"
],
"script": "scripts/to-ovf-darwin.sh",
"only_on": "darwin",
"keep_input_artifact": true,
"only": ["qemu"]
},
{
"name": "{{.Provider}}.box",
"output": "{{user `vm_name`}}.exports/{{.Provider}}.{{user `vm_name`}}.box",
"type": "vagrant",
"keep_input_artifact": true
},
{
"type": "vagrant-cloud",
"box_tag": "loic-roux-404/deb64-buster",
"access_token": "{{user `cloud_token`}}",
"version": "{{user `box_version`}}",
"keep_input_artifact": true
}
]
], {variables...}}
Hi, thanks for reaching out!
This should definitely work, and it's not immediately clear to me why it doesn't. Can you please set the environment var PACKER_LOG=1, and run the build again using the --only=qemu
command line flag so that the logs don't get clutterd by the virtualbox one, and then paste the full output of the build into a gist for me? that should help me track what's going on with the artifact.
I also have two hopefully-helpful template notes, though I don't think either of these will solve your problem.
1) The shell-local post-processor automatically keeps the input artifact so you don't need to set keep_input_artifact=true.
2) Using {{.Provider}} inside the "name" field won't work because the name gets assigned before .Provider is interpolated by the post-processor. The ".Provider" engine will only work inside the "output" option in the post-processors.
Figured with packer new version, don't really know why, i'm going to reopen and publish a gist if i met this issue.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.