if then statement inside of inline shell?

16 views
Skip to first unread message

Vritual Packer

unread,
Aug 5, 2019, 1:01:29 PM8/5/19
to Packer
Spent quite a while googling this and can't find an example...

What is the proper way to do a if then statement inside of an inline  shell?

example:
"type": "shell",
"inline" : [
"yum update -y"
 " if [ $VAR -eq "something" ]; then
   do this
   and this
   and finally this
  else
  do something else
fi",

Thank you for any help...


Benjamin Lu

unread,
Aug 5, 2019, 1:08:07 PM8/5/19
to Packer
I don't think you can, the best way to use scripts on its own file and you can do if statements. 

"scripts": [
    "scripts/setup.sh",
    "scripts/update.sh",
    "scripts/packages.sh"
],

Vritual Packer

unread,
Aug 5, 2019, 3:49:28 PM8/5/19
to Packer
I know something like this works:

" if [ ${SOMETHING} -eq 1 ]; then do this; fi"

I just can't figure out how to get it formatted for multiple lines so it looks nice/more readable.
Reply all
Reply to author
Forward
0 new messages