0

I'm building a Packer template to use with several variable files and wanted to pass the builder name via variable so the provisioners will only execute according to the function I want to execute.

I tried coding it like:

{
  "variables": {
    "name": "",
    "project_id": "",
    "source_image_family": "",
    "zone": "",
    ...
  },
  "sensitive-variables": [
    "account_file",
    "winrm_username",
    "elevated_user",
    "elevated_password"
  ],
  "builders": [
    {
      "name": "{{user `name`}}",
      "type": "googlecompute",
      "project_id": "{{user `project_id`}}",
      ...
    }
  ]
}

And then pass the variables as:

{
  "name": "your_builder_name",
  ...
}

But when I try to validate, it always reports that the builder isn't found.

Any idea on how to do it, or if it's possible? I tried searching online and found some old indication that it wasn't possible, but then I found a post saying it's now possible, but didn't find an example to validate how I'm approaching this...

Thank you for any input! :)

Edit: After some more investigation and discussion with colleagues, I've came to conclusion this isn't possible. The 'only' feature can only be used (with purpose) if you have multiple builders within the same code... pitty...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.