Hi All,
I'm trying to fully automate a Windows 10 build using Packer. I'm mostly successful, with the exception of patching the OS before I generate the AMI/VM template.
I don't know if that's feasible or how to approach this, but here's what I'm trying:
1. Use specific WINRM credentials before my VM is joined to the domain.
2. After it is joined to the domain, use new credentials to keep interacting with the VM.
Since I can't specify a different communicator within the "provisioners" block, I'm not sure how I could do this? Reason I need to join the domain is because windows won't patch if it is not activated.
Invalid example (as I specified communicator info in the provisioner):
builder:
...
"communicator": "winrm",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_use_ntlm": true,
"winrm_username": "Administrator",
"winrm_password": "Password1",
...
"provisioners": [
{
"type": "powershell",
"environment_vars": [
"vm_hostname={{user `vm_hostname`}}"
],
"inline": ["Rename-Computer -NewName \"$env:vm_hostname\""]
},
{ "type": "windows-restart",
"pause_before": "30s"
},
{
"type": "powershell",
"script": "{{template_dir}}/join-domain.ps1",
"environment_vars": [
"vm_hostname={{user `vm_hostname`}}",
"ad_domain={{user `ad_domain`}}",
"ad_ou_path={{user `ad_ou_path`}}",
"ad_domain_user=DOMAIN\\user",
"ad_domain_pw=DOMAIN\\password"
]
}
],
"provisioners": [
{
"communicator": "winrm",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_use_ntlm": true,
"winrm_username": "{{ user `ad_username` }}",
"winrm_password": "{{ user `ad_password` }}",
"type": "windows-restart",
"pause_before": "30s"
}
]
}
Thanks!