hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.11k stars 3.33k forks source link

Feature request: Comma separated builder "name" list for defining multiple, similar builds. #7227

Closed curiositycasualty closed 4 years ago

curiositycasualty commented 5 years ago

This would be a feature whereby a single builder could define multiple, similar builds by housing a comma-separated list (or JSON array) of build names in that builder's name property:

    {
      "name": "alpha-aws,beta-aws",
      "tags": {
        "A": "long",
        "list": "of",
        "tags": "that",
        "apply": "to",
        "multiple": "builds."
      },
      "type": "amazon-ebs"
    }

Or even: ... "name": ["alpha-aws", "beta-aws"] ...

Such that both of the two builds would share the tags property.

Customizing specifics of these builds could be accomplished through the user of the override property (assuming that functionality would be added for builders):

    {
      "name": [
        "alpha-aws",
        "beta-aws"
      ],
      "tags": {
        "A": "long",
        "list": "of",
        "tags": "that",
        "apply": "to",
        "multiple": "builds."
      },
      "override": {
        "alpha-aws": {
          "tags": {
            "A": "different",
            "set": "of",
            "tags": "."
          }
        }
      },
      "type": "amazon-ebs"
    }
SwampDragons commented 5 years ago

This is a cool idea, and I think it actually falls in line with some of the thinking we've been doing around what Packer 2.0 will look like. I think it's unlikely that we'll be getting to it any time in the next year though.

azr commented 4 years ago

Hello there ! With HCL2 it is now possible to have tags variable and reuse these tags in sources:

variable "my_tags" {
  default = {
   A  = "bunch"
   Of = "tags
  }
}

source "amazon-ebs" "example" {
  # config
}

build {
  source "amazon-ebs.example" {
    name = "alpha-aws"
    tags = var.tags
  }
  source "amazon-ebs.example" {
    name = "beta-aws"
    tags = var.tags
  }

  # ... provision

}

Closing this issue as it should just work, cheers ! 🎉

ghost commented 4 years ago

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.