question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Packer build task fails for user provided template with multiple builders

See original GitHub issue

Environment

  • Server - VSTS

  • Agent - Hosted

    • If using Hosted agent, provide agent queue name: Hosted Linux

Issue Description

Packer build task fails for user provided template with multiple builders (e.g. virtualbox-ovf). Require ability to specify or should default command to use -only azure-arm. Example template:

{
  "variables": {
    "region": "{{env `AZURE_REGION`}}",
    "client_id": "{{env `AZURE_CLIENT_ID`}}",
    "client_secret": "{{env `AZURE_CLIENT_SECRET`}}",
    "resource_group": "{{env `AZURE_RESOURCE_GROUP`}}",
    "storage_account": "{{env `AZURE_STORAGE_ACCOUNT`}}",
    "subscription_id": "{{env `AZURE_SUBSCRIPTION_ID`}}",
    "object_id": "{{env `AZURE_OBJECT_ID`}}",
    "vm_size": "{{env `AZURE_VM_SIZE`}}",
    "ovf_path": "{{env `OVF_PATH`}}"
  },
  "builders": [{
    "type": "virtualbox-ovf",
    "vboxmanage": [
      [ "modifyvm", "{{.Name}}", "--memory", "2048" ],
      [ "modifyvm", "{{.Name}}", "--cpus", "2" ]
    ],
    "source_path": "{{user `ovf_path`}}",
    "communicator": "winrm",
    "winrm_username": "vagrant",
    "winrm_password": "vagrant",
    "winrm_port": "5985",
    "winrm_timeout": "5h",
    "guest_additions_mode": "disable",
    "headless": "true"
  }, {
    "type": "azure-arm",

    "client_id": "{{user `client_id`}}",
    "client_secret": "{{user `client_secret`}}",
    "resource_group_name": "{{user `resource_group`}}",
    "storage_account": "{{user `storage_account`}}",
    "subscription_id": "{{user `subscription_id`}}",
    "object_id": "{{user `object_id`}}",

    "capture_container_name": "images",
    "capture_name_prefix": "my-image",

    "os_type": "Windows",
    "image_publisher": "MicrosoftWindowsServer",
    "image_offer": "WindowsServer",
    "image_sku": "2016-Datacenter",

    "communicator": "winrm",
    "winrm_use_ssl": "true",
    "winrm_insecure": "true",
    "winrm_timeout": "3m",
    "winrm_username": "packer",

    "location": "{{user `region`}}",
    "vm_size": "{{user `vm_size`}}"
  }],
  "provisioners": [{
    "type": "powershell",
    "inline": [
      "winrm quickconfig -q"
    ]
  }, {
    "type": "powershell",
    "inline": [
      "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
      "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
      "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10  } else { break } }"
    ]
  }]
}

Error logs

After successfully building azure-arm builder:

2017-10-16T06:41:03.5280090Z ==> Some builds didn't complete successfully and had errors:
2017-10-16T06:41:03.5302070Z --> virtualbox-ovf: Failed creating VirtualBox driver: exec: "VBoxManage": executable file not found in $PATH
2017-10-16T06:41:03.5312140Z 
2017-10-16T06:41:03.5322010Z 
2017-10-16T06:41:03.5449910Z ==> Builds finished. The artifacts of successful builds are:
2017-10-16T06:41:03.5460690Z 
2017-10-16T06:41:03.5539880Z --> azure-arm: Azure.ResourceManagement.VMImage:
...
2017-10-16T06:41:03.6096900Z ##[error]Error: /opt/vsts/work/_temp/1508134227305/packer/packer failed with return code: 1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jogleasonjrcommented, Dec 18, 2018

Seconding the need for this. Either a free-form text box for any/all command line options, or individual UI elements for each build option (there aren’t very many) would be great. I was half curious about implementing the former myself – but it wasn’t clear from the contributing guide how to present a modified version of a built in task (such as the Packer task) to the DevOps pipeline. Is there any documentation on this?

0reactions
github-actions[bot]commented, Oct 13, 2020

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

Read more comments on GitHub >

github_iconTop Results From Across the Web

packer build - Commands - HashiCorp Developer
The packer build command takes a template and runs all the builds within it in order to generate a set of artifacts. The...
Read more >
packer - Parallel builds using identical json file - Stack Overflow
1 Answer 1 ... Packer doesn't support running the same builder multiple times. If you want to do that you need to duplicate...
Read more >
Create VM images in Azure with Packer - matthewdavis111
Packer has different builders that can be used to target different platforms (you can also use multiple builders in the same template).
Read more >
Packer a Complete Guide with Example | by Nandan B N
Packer is able to read a template and use that information to create multiple machine images in parallel. We'll look more at Builders,...
Read more >
Packer Tutorial For Beginners - Automate VM Image Creation
Step 2 : Inside the packer-vm folder, create a file named “ vm.pkr.hcl ” and copy the following HCL template. If we put...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found