-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
core: Can't use user variable in keep_input_artifact
#2630
Comments
Thanks for the report. I've seen some options that want a boolean and others that want a string This particular case might be caused by the interpolation happening after the value in the template has been coerced into the appropriate type, so we probably need to coerce the interpolated value as well. I think this usually works as expected so I'm not sure what's different in this case. |
I personally don't mind whether it's a string or a boolean, as long as at least one of them works :) |
Having this issue with 0.8.6 as well. Was just trying to be 'clever' and handle keeping the artifact based on whether I was in "dev" mode or "ci" mode and it appears I currently cannot do this due to the strict typing on keep_input_artifact. |
I'm running into this with 0.9.0 so I'm stuck on 0.7.5 |
I tried with packer 0.12.0 and this issue is still valid (discovered while working on boxcutter/ubuntu#87). Here is the log:
Here are the relevant parts of the template:
I am using boxcutter/ubuntu 16.04 template. I don't know if this issue is still observed. Should I open a new one? Thanks ping @cbednarski |
@ferrarimarco Gist full log ( |
Here it is, @rickard-von-essen thanks:
|
@rickard-von-essen I tried with the latest devevelopment version, no changes:
|
Could you try on another system or in a vagrant box etc? |
That log was generated from inside a Docker container, starting from hashicorp/docker-hub-images Dockerfile-full. I just removed the |
Ok, do you access the ubuntu repo through a volume mount into docker? |
I tried in two ways:
|
So what is the exact output of first: docker run -it ubuntu:trusty bash and then: apt-get update > /dev/null && apt-get -y install git unzip wget > /dev/null
wget https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_amd64.zip
unzip packer_0.12.0_linux_amd64.zip
git clone https://github.com/boxcutter/ubuntu.git && cd ubuntu && ../packer validate ubuntu.json |
Here are the results with the "vanilla" template.
My edits to
Results:
Thanks @rickard-von-essen |
Check! I got a bit lost while trying to understand this. I think a hint on why this doesn't work is that |
Hopefully we'll be able to fix this when we implement the HCL2 configs; I'm not going to prioritize it before then because it's got a workaround. To paraphrase Matthew's comment above, It's a deep architectural quirk and the refactor necessary to make this one key work is dramatically more effort than implementing a workaround on your end. For now I'm going to mark this with the "config-2.0" and "wontfix" flags to hopefully remove confusion about the maintainers' stance on this bug. tl;dr We know it's still kickin' around and we aren't going to fix it independently of the large refactor we already have planned for late 2019. |
I thought the HCL2 configs were already in Packer 1.3.x, since they were a prereq for the Vault integrations that @SwampDragons coincidentally implemented. Additionally, will the HCL2 configs enable Arrays as well instead of the e.g. |
HCL2 turned out not to be necessary for that Vault integration. |
I think whether we support arrays for particular options will have to do with the option in question. |
Hello there, just to say that this is now possible to set |
@azr can you give an example config file for visualizing how to do this? |
Of course, one thing we can do is use an input variable: variable "keep_that_input_artifact" {
default = true
}
build {
source = ["..."] # your sources
# provision ...
post-process "shell-local" {
keep_input_artifact = var.keep_that_input_artifact
}
} That variable could be set from cli arguments; env or a config file; . |
Ah no, wait; @SwampDragons just found out that I was saying something wrong; the 'eval context' is not present at the moment we parse these variables and therefore we cannot use variables there het; Issue is here: the second argument of decodebody should just take it as an argument: packer/hcl2template/types.build.post-processor.go Lines 25 to 36 in cf514d3
|
I've got the same issue as #1913 recurring in 0.8.5 when using a string user variable for the boolean keep_input_artifact in the vagrant post-processor.
Oddly enough though, I can use the same string syntax for booleans successfully in the headless setting in the virtualbox builder.
The text was updated successfully, but these errors were encountered: