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

Exit on failure of any command inside remote-exec #682

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

agarciamontoro
Copy link
Member

Summary

According to the documentation on the remote-exec provisioner:

Since inline is implemented by concatenating commands into a script, on_failure applies only to the final command in the list. In particular, with on_failure = fail (the default behaviour) earlier commands will be allowed to fail, and later commands will also execute. If this behaviour is not desired, consider using "set -o errexit" as the first command.

Gonna test this now.

Ticket Link

--

According to the documentation on the remote-exec provisioner (https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec):

Since inline is implemented by concatenating commands into a script,
on_failure applies only to the final command in the list. In particular,
with on_failure = fail (the default behaviour) earlier commands will be
allowed to fail, and later commands will also execute. If this behaviour
is not desired, consider using "set -o errexit" as the first command.
@agarciamontoro agarciamontoro added the 2: Dev Review Requires review by a core committer label Jan 10, 2024
Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

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

Makes sense 👍

Copy link
Member

@agnivade agnivade left a comment

Choose a reason for hiding this comment

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

Nice one!

@agarciamontoro
Copy link
Member Author

I've run several deployments with this change, and it seems to be working. Merging now.

@agarciamontoro agarciamontoro added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Jan 12, 2024
@agarciamontoro agarciamontoro merged commit 185a38d into master Jan 12, 2024
1 check passed
@agarciamontoro agarciamontoro deleted the remote-exec.exit.on.failure branch January 12, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants