Script exited with non-zero exit status: 16001

1,606 views
Skip to first unread message

roni yako

unread,
Sep 6, 2018, 8:40:00 AM9/6/18
to Packer
Issue:  When a provisioner powershell file has the "Start-Sleep" command, the script fails and exits with a error code of 16001.

The start-sleep command should not be failing the script and should be acting as a pause in a provisioning script, but for some reason packer exits the script and terminates the job.


- Packer version: Packer v1.2.1
- Host platform: Windows 2012R2

Error below

1536230971,,ui,error,Build 'amazon-ebs' errored: Script exited with non-zero exit status: 16
001. Allowed exit codes are: [0]
1536230971,,error-count,1
1536230971,,ui,error,\n==> Some builds didn't complete successfully and had errors:
1536230971,amazon-ebs,error,Script exited with non-zero exit status: 16001. Allowed exit cod
es are: [0]
1536230971,,ui,error,--> amazon-ebs: Script exited with non-zero exit status: 16001. Allowed
exit codes are: [0]
1536230971,,ui,say,\n==> Builds finished but no artifacts were created.

roni yako

unread,
Sep 6, 2018, 8:40:31 AM9/6/18
to Packer
Anyone else have this issue?

Justin Metz

unread,
Sep 6, 2018, 8:47:49 AM9/6/18
to Packer
Can you post the exact text you are entering for that particular provisioner?

On Thursday, September 6, 2018 at 8:40:31 AM UTC-4, roni yako wrote:
Anyone else have this issue?

roni yako

unread,
Sep 6, 2018, 9:01:31 AM9/6/18
to Packer
An example would be the below

start-sleep 5

I would only have that piece of code in my script and it will give out that error. 

Justin Metz

unread,
Sep 6, 2018, 9:18:41 AM9/6/18
to Packer
Is this the first script provisioner you are running on the box or do other provisioners run before it?  The reason I ask is because if you don't have the Powershell executionpolicy set to the proper level via userdata when the instance is created, you won't be able to run scripts.

I'm assuming this is how you are calling your script in the provisioner and the script exists in the same folder as your packer template.

        {
            "type":"powershell",
            "script":"SleepExample.ps1"
        },

Alvaro Miranda Aguilera

unread,
Sep 6, 2018, 9:22:32 AM9/6/18
to packe...@googlegroups.com
packer checks for exit code 0 (linux/unix way)

whats the exit code of that command?

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/8da3464f-fe3a-4f9b-9d60-fbe4606e672f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alvaro

Justin Metz

unread,
Sep 6, 2018, 9:48:07 AM9/6/18
to Packer
For the most part, Powershell scripts return 0 by default unless forced to something different by the "exit" keyword..

Alvaro Miranda Aguilera

unread,
Sep 6, 2018, 3:42:27 PM9/6/18
to packe...@googlegroups.com
per your log is exiting with 16001


For more options, visit https://groups.google.com/d/optout.


--
Alvaro

roni yako

unread,
Sep 7, 2018, 12:08:57 AM9/7/18
to Packer
it's the first script and yes, thats how i am calling it, my execution policy is as follows. Can you confirm that's what you would expect. I can run scripts, so i think it works, its just weird that its exiting with this errror code when this command is run when it shouldn't be exiting. 

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
Reply all
Reply to author
Forward
0 new messages