v0.9.4
Fails (expected):
provisioner "remote-exec" {
inline = [
"not_a_valid_command"
]
connection {
...
}
}
Fails (expected):
provisioner "remote-exec" {
inline = [
"not_a_valid_command",
"touch /home/ec2-user/ok",
"also_not_a_valid_command"
]
connection {
...
}
}
Does not fail (unexpected):
provisioner "remote-exec" {
inline = [
"not_a_valid_command",
"touch /home/ec2-user/ok"
]
connection {
...
}
}
https://gist.github.com/davidvartan/ce32d7ed82222874ce094a508a77ba6b
(Search for not_a_valid_command in the output. Despite this, provisioning succeeds, and subsequent command still runs.)
N/A
If an inline command fails:
bash -e behavior)inline block was successful.touch from my example).remote-exec provisioner (with aws_instance in my case)inline block, write an invalid command followed by a valid command.terraform applyN/A
N/A
FWIW, I can confirm that this is still valid with terraform 0.10.6
This was fixed by #11155 but was subsequently reverted. Related issue: https://github.com/hashicorp/terraform/issues/11145
Also seeing this in Terraform v0.11.2
Not sure which version contained the fix before it was reverted, but we are also hit by this issue with Terraform 0.10.8.
I realize @mitchellh is quite busy these days, but if the original author @pmcatominey or reviewer @stack72 could provide a little context as to why it was reverted and if there is any plans to bring it back, it would be helpful to know how long we need workarounds for this problem.
Thanks
Hi @MichaelPereira,
I wasn't aware that the change had been reverted, after looking on Github I can't find a corresponding PR to add context to why it was reverted.
The commit in question is 640faf1, from looking at the tags it has been reverted since 0.9.0.
Apologies for not being able to shine a light on the reasons, as a workaround you could instead use the script option and set shell options to exit when a command fails.
I'm actually OK with this behaviour, provided that it's documented. set -e as the first line, and it should abort as expected.
set -e works with linux, but what I should do with windows? script || exit 1 does not work
Doesn't work on v0.12.0-beta2.
set -e - also doesn't help
Most helpful comment
I'm actually OK with this behaviour, provided that it's documented.
set -eas the first line, and it should abort as expected.