admin管理员组

文章数量:1122847

I'm trying to understand the best way to achieve this in a packer template.

For example: I have a list of 3 values. Let's use red, blue, and green as an example

I want to create 3 separate builds (or however many items in the list I have) that do the same exact thing except in one of the provisioners, pass this value to a script being run there.

Create one build using:

provisioner "shell" {
    execute_command = "{{ .Vars }} sudo -E bash '{{ .Path }}'"
    inline = [
      "/tmp/my_script.sh red
    ]
}

Second build:

provisioner "shell" {
    execute_command = "{{ .Vars }} sudo -E bash '{{ .Path }}'"
    inline = [
      "/tmp/my_script.sh blue
    ]
}

etc.

I currently have 1 source and 1 build block, but need a way to create dynamically as many as there are items in the list

本文标签: hclHow to create parallel builds foreach item in list using packer templateStack Overflow