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!

-- 
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/3b57c320-9db0-452e-b46f-88e04305ca1d%40googlegroups.com.

Reply via email to