Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add possibility to use variables everywhere in post-processor blocks #11094

Merged
merged 4 commits into from
Jun 15, 2021

Conversation

azr
Copy link
Contributor

@azr azr commented Jun 15, 2021

Todo list:

  • feature
  • tests

Including in:

  • name
  • only
  • except
  • keep_input_artifact

Example file:

source "null" "example1" {
  communicator = "none"
}

source "null" "example2" {
  communicator = "none"
}

locals {
  except = "null.example1"
}

variable "only" {
  default = "null.example1"
}

build {
  sources = ["source.null.example1", "source.null.example2"]
  post-processor "shell-local" {
    except = [local.except]
    inline = ["echo first post-processor"]
  }

  post-processor "shell-local" {
    only   = [var.only]
    inline = ["echo second post-processor"]
  }
}

Ouput:

$ packer build foo.pkr.hcl
null.example1: output will be in this color.
null.example2: output will be in this color.

==> null.example1: Running post-processor:  (type shell-local)
==> null.example2: Running post-processor:  (type shell-local)
==> null.example2 (shell-local): Running local shell script: /var/folders/3k/2gb5ct4s7cncr52_jh2kz6cw0000gq/T/packer-shell201696062
==> null.example1 (shell-local): Running local shell script: /var/folders/3k/2gb5ct4s7cncr52_jh2kz6cw0000gq/T/packer-shell494781572
    null.example1 (shell-local): second post-processor
Build 'null.example1' finished after 61 milliseconds 432 microseconds.
    null.example2 (shell-local): first post-processor
Build 'null.example2' finished after 111 milliseconds 678 microseconds.

==> Wait completed after 111 milliseconds 714 microseconds

close #4895

Including in:
* name
* only
* except
* keep_input_artifact
@azr azr requested a review from a team as a code owner June 15, 2021 14:18
@azr azr marked this pull request as draft June 15, 2021 14:22
@azr azr force-pushed the azr_var_in_pps_structs branch from 63037a0 to 6d1aefb Compare June 15, 2021 14:31
@azr azr force-pushed the azr_var_in_pps_structs branch from 6d1aefb to d759e04 Compare June 15, 2021 14:32
@azr azr marked this pull request as ready for review June 15, 2021 14:34
Copy link
Contributor

@sylviamoss sylviamoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! Indeed super simple! 👍🏼

@azr azr merged commit 9d0193a into master Jun 15, 2021
@azr azr deleted the azr_var_in_pps_structs branch June 15, 2021 16:29
@vishalbasra
Copy link

super awesome!
thankyou so much, I'll be testing this out shortly!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

packer Post Processor Ignores User Variables in "only"
3 participants