Inspec provisioner exit codes

364 views
Skip to first unread message

n n

unread,
Mar 14, 2019, 2:23:34 PM3/14/19
to Packer
Hi,
packer is failing when inspec returns a 101 exit code due to skipped tests.

Build 'amazon-ebs' errored: Error executing Inspec: Non-zero exit status: exit status 100

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Error executing Inspec: Non-zero exit status: exit status 100

==> Builds finished but no artifacts were created.



Is there a way to use additional exit codes?


0 run ok + all passed:
100 run okay + failures
101 run okay + skipped only


The powershell provisioner has a way to specify valid exit codes

and it looks like the shell provisioner is getting one as well


thanks
-N

Alvaro Miranda Aguilera

unread,
Mar 15, 2019, 4:37:38 PM3/15/19
to packe...@googlegroups.com
how are you running inspec ?

alvaro

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/18d8d8ba-36c8-4bbe-bbb5-c27dbbc74e1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alvaro

Megan Marsh

unread,
Mar 15, 2019, 5:14:23 PM3/15/19
to packe...@googlegroups.com
@alvaro we recently added an inspec provisioner.  

I don't think there's currently a way to set extra valid exit codes, but open a feature request on github and maybe someone from the community can try to implement that.

n n

unread,
Mar 18, 2019, 11:20:16 AM3/18/19
to Packer
I posted a workaround in the issue. You can change the exit code behavior in inspec by using the --no-distinct-exit flag

[--distinct-exit], [--no-distinct-exit]            # Exit with code 101 if any tests fail, and 100 if any are skipped (default). If disabled, exit 0 on skips and 1 for failures.



"extra_arguments": [ "--no-distinct-exit" ]

Here is how I'm using it
"type": "inspec",
"user": "ec2-user",
"profile": "https://github.com/dev-sec/linux-patch-baseline.git",
"extra_arguments": [ "-l", "debug", "--no-distinct-exit", "--sudo", "--reporter", "cli", "junit:./results/inspec.xml" ]


Reply all
Reply to author
Forward
0 new messages