Store variable value from shell provisioner and handle exit code

226 views
Skip to first unread message

Vamshi krishna

unread,
Jun 12, 2017, 11:21:59 AM6/12/17
to Packer
  1. Is it possible to store the output of an inline shell command in a packer variable?  I have looked into docs and have not found a proper example of doing it. 
  2. Is it possible to run shell provisioner even if other provisioners fails to execute or throw an exit code 1 ?
one of my provisioner runs chef-client and if it succeeds I won't have any problems but if it fails the packer exit's with code 1. my subsequent provisioners are `deleting the node and client` from the chef server. I want these commands to be executed even if the first provisioner fails.

Rickard von Essen

unread,
Jun 13, 2017, 3:25:38 AM6/13/17
to packe...@googlegroups.com
1. No

2. No. To do something like that you have to wrap your script in another script that will execute appropriate cleanup tasks*). This only works in a shell provisioner. If you rely on another provisioner you might manipulate the execute_command to write down the exit code to a file and ignore expected exit codes. And then run a script that do appropriate cleanup and reuse the exit code from the previous provisioner.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/41c7834d-6f30-4cf1-a6eb-a33335e99b34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages