Overview of the Issue
note: i noticed that this may be a similar issue as #1942 however, i believe my use case is more complex and it works most of the time.
I am using packer with the following builders:
- virtualbox-iso
- virtualbox-ovf
The process fails to interpolate the variables, seemingly randomly.
Reproduction Steps
In my template, i have these variables:
"variables": {
"env_branch_name": "{{env `CI_COMMIT_REF_NAME`}}",
"env_os": "{{env `OS`}}",
"env_os_version": "{{env `OS_VERSION`}}",
"env_postfix": "{{env `POSTFIX`}}",
"env_output_dir": "{{env `OUTPUT_DIR`}}"
}
I am building variables like this:
{
"base_postfix": "base",
"base_long_name": "{{user `env_branch_name`}}-{{user `env_os`}}{{user `env_os_version`}}-{{user `base_postfix`}}",
"source_path": "{{user `env_output_dir`}}/{{user `env_branch_name`}}/{{user `env_os`}}{{user `env_os_version`}}-{{user `base_postfix`}}/virtualbox/{{user `base_long_name`}}.{{user `virtualbox_format`}}"
}
Log of Failure:
virtualbox-ovf: Download failed source path error: stat /u01/artifacts/ADOPT-1379/rhel7-base/virtualbox/{{user `env_branch_name`}}-{{user `env_os`}}{{user `env_os_version`}}-{{user `base_postfix`}}.ova: no such file or directory
Log of Success:
virtualbox-ovf: /u01/artifacts/ADOPT-1379/rhel7-base/virtualbox/ADOPT-1379-rhel7-base.ova
Packer version
From 1.5.4
Simplified Packer Buildfile
{"variables": {
"env_branch_name": "{{env `CI_COMMIT_REF_NAME`}}",
"env_os": "{{env `OS`}}",
"env_os_version": "{{env `OS_VERSION`}}",
"env_postfix": "{{env `POSTFIX`}}",
"env_inspec_profile": "{{env `INSPEC_PROFILE`}}",
"env_inspec_profiles_path": "{{env `INSPEC_PROFILES_PATH`}}",
"env_inspec_sa_token": "{{env `INSPEC_SA_TOKEN`}}",
"env_inspec_sa_username": "{{env `INSPEC_SA_USERNAME`}}",
"env_output_dir": "{{env `OUTPUT_DIR`}}",
"env_virtualbox_vms_dir": "{{env `VIRTUALBOX_VMS_DIR`}}"
},
"builders": [{
"type": "virtualbox-iso",
"boot_command": [
"{{ user `rhel_7_skip_check_cmd` }}",
"<tab> ks={{ user `floppy_drive` }}/ks.cfg <enter><wait>"
],
"boot_wait": "{{ user `boot_wait` }}",
"floppy_files": [
"{{ user `http_directory` }}/ks.cfg"
],
"format": "{{ user `virtualbox_format` }}",
"guest_os_type": "RedHat_64",
"hard_drive_interface": "sata",
"headless": "{{ user `headless` }}",
"http_directory": "{{ user `http_directory` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_url": "{{ user `iso_base` }}{{ user `iso_path` }}",
"output_directory": "{{ user `output_directory` }}/virtualbox",
"shutdown_command": "{{ user `shutdown_command` }}",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_pty": "{{ user `ssh_pty` }}",
"ssh_username": "{{ user `ssh_username` }}",
"ssh_timeout": "{{ user `ssh_timeout` }}",
"disk_size": "{{user `disk_size`}}",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"{{ user `memory` }}"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"{{ user `cpus` }}"
]
],
"vm_name": "{{ user `long_name` }}"
}]}
Operating system and Environment details
- rhel7 "Beefy box" running in vsphere
- configured with gitlab-runner, packer, vagrant and and virtualbox
- fully automated builds, build is kicked off on gitlab push
Log Fragments and crash.log files
Both logs come from the same hash. Job failed, I clicked retry and it worked.
Overview of the Issue
note: i noticed that this may be a similar issue as #1942 however, i believe my use case is more complex and it works most of the time.
I am using packer with the following builders:
The process fails to interpolate the variables, seemingly randomly.
Reproduction Steps
In my template, i have these variables:
I am building variables like this:
{ "base_postfix": "base", "base_long_name": "{{user `env_branch_name`}}-{{user `env_os`}}{{user `env_os_version`}}-{{user `base_postfix`}}", "source_path": "{{user `env_output_dir`}}/{{user `env_branch_name`}}/{{user `env_os`}}{{user `env_os_version`}}-{{user `base_postfix`}}/virtualbox/{{user `base_long_name`}}.{{user `virtualbox_format`}}" }Log of Failure:
Log of Success:
Packer version
From
1.5.4Simplified Packer Buildfile
{"variables": { "env_branch_name": "{{env `CI_COMMIT_REF_NAME`}}", "env_os": "{{env `OS`}}", "env_os_version": "{{env `OS_VERSION`}}", "env_postfix": "{{env `POSTFIX`}}", "env_inspec_profile": "{{env `INSPEC_PROFILE`}}", "env_inspec_profiles_path": "{{env `INSPEC_PROFILES_PATH`}}", "env_inspec_sa_token": "{{env `INSPEC_SA_TOKEN`}}", "env_inspec_sa_username": "{{env `INSPEC_SA_USERNAME`}}", "env_output_dir": "{{env `OUTPUT_DIR`}}", "env_virtualbox_vms_dir": "{{env `VIRTUALBOX_VMS_DIR`}}" }, "builders": [{ "type": "virtualbox-iso", "boot_command": [ "{{ user `rhel_7_skip_check_cmd` }}", "<tab> ks={{ user `floppy_drive` }}/ks.cfg <enter><wait>" ], "boot_wait": "{{ user `boot_wait` }}", "floppy_files": [ "{{ user `http_directory` }}/ks.cfg" ], "format": "{{ user `virtualbox_format` }}", "guest_os_type": "RedHat_64", "hard_drive_interface": "sata", "headless": "{{ user `headless` }}", "http_directory": "{{ user `http_directory` }}", "iso_checksum": "{{ user `iso_checksum` }}", "iso_checksum_type": "{{ user `iso_checksum_type` }}", "iso_url": "{{ user `iso_base` }}{{ user `iso_path` }}", "output_directory": "{{ user `output_directory` }}/virtualbox", "shutdown_command": "{{ user `shutdown_command` }}", "ssh_password": "{{ user `ssh_password` }}", "ssh_pty": "{{ user `ssh_pty` }}", "ssh_username": "{{ user `ssh_username` }}", "ssh_timeout": "{{ user `ssh_timeout` }}", "disk_size": "{{user `disk_size`}}", "vboxmanage": [ [ "modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}" ], [ "modifyvm", "{{.Name}}", "--cpus", "{{ user `cpus` }}" ] ], "vm_name": "{{ user `long_name` }}" }]}Operating system and Environment details
Log Fragments and crash.log files
Both logs come from the same hash. Job failed, I clicked retry and it worked.