In your Packer logs you are getting the following message

2018/04/07 10:04:40 packer.exe: 2018/04/07 10:04:40 Retryable error: *http 
response error: 401* - invalid content type
2018/04/07 10:04:40 packer.exe: 2018/04/07 10:04:40 [INFO] 0 bytes written 
for 'stderr'
2018/04/07 10:04:40 packer.exe: 2018/04/07 10:04:40 [INFO] 0 bytes written 
for 'stdout'

Http 401 error are credential related issues.. I will suggest first in your 
script to hardcode the username/password and see how it goes

If you want to troubleshoot your script, will suggest to print out what is 
the value you get in the variable $password and make sure your script is 
passing valid username/password values..


$domain = "xxxxx" 

$password = "xxxxx" | ConvertTo-SecureString -asPlainText -Force 

$username = "$domain\aaa.bbb" 

$credential = New-Object 
System.Management.Automation.PSCredential($username,$password) 

On Monday, April 30, 2018 at 7:35:56 PM UTC+12, Alvaro Miranda Aguilera 
wrote:
>
> can you put a minimal repro case?
>
> in that way will be easier to just run packer and see the issue.
>
> On Mon, Apr 30, 2018 at 6:35 AM, Sim <[email protected] <javascript:>> 
> wrote:
>
>> Packer failed to continue running the template after the PowerShell 
>> domain join command was executed. 
>>
>> This issue has been here for a while, I did raise this issue as a bug but 
>> @Mathew suggested me to update the plugins which I already did, and also to 
>> wait for the latest release which could possibly fix my issue, but the 
>> issue still has not been resolved and I believe this is a bug and hopefully 
>> there would be someone to investigate this bug. Thanks so much.
>>
>>
>> As I need to add the temporary VM which is generated by Packer during the 
>> build into the domain, I have added a Domain join PowerShell script into 
>> the template which looks like this:
>>
>>
>> $domain = "xxxxx" 
>>
>> $password = "xxxxx" | ConvertTo-SecureString -asPlainText -Force 
>>
>> $username = "$domain\aaa.bbb" 
>>
>> $credential = New-Object 
>> System.Management.Automation.PSCredential($username,$password) 
>>
>> Add-Computer -DomainName $domain -Credential $credential
>>
>>
>> and then in the provisioners part of the template, I have placed the 
>> domain join script before the windows-restart command.
>>
>> { "type": "powershell",
>>
>>  "script": "PackerUpload/join_domain.ps1" }, 
>>
>> { "type": "windows-restart",
>>
>>  "restart_check_command": "powershell -command \"& {Write-Output 
>> 'restarted.'}\"" }
>>
>>
>> Technically, Packer is supposed to restart and continue the running other 
>> components in the template. However, I don't know why the packer build 
>> failed to restart or even run another script (I did attempt to replace the 
>> windows-restart with another PowerShell script, but it also failed to run). 
>> I might suspect that the domain join script has somehow disconnected the 
>> temporary VM with Packer or maybe Packer failed to reconnect the VM after 
>> the domain join script had been successfully executed. I guess this may be 
>> a bug in Packer. I have attached the debug_log below. There is no problem 
>> if I run other PowerShell scripts (not domain join one), the connection is 
>> fine and windows-restart works fine. Thank you.
>>
>> Info:
>>
>>    - Packer version from 1.2.3
>>    - Host platform: Windows10
>>    - Debug log output from PACKER_LOG=1 packer build template.json.
>>    https://gist.github.com/ngeegoh/a6d5c662cd54f7844109d3986ac5b544 
>>    <https://gist.github.com/ngeegoh/6ad9151990601ccb2899c7e5bf0e8c7f>
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/76298b3c-1137-4eed-bb1d-dc7d253dd191%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/76298b3c-1137-4eed-bb1d-dc7d253dd191%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/4427447b-1968-4671-ab1e-e799d46be712%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to