Problem:
When deploying Windows VM using vSphere and sysprep, then I cannot specify machine OU and domain join cannot work
Expected outcome:
possibility to provide OU with domain join
Foreman and Proxy versions:
3.7
Foreman and Proxy plugin versions:
Distribution and version:
Other relevant data:
Hey,
we can join domain by using powershell script and this way also provide the OU when joining.
We need to specify the OU as each tenant has their own. we cannot allow one tenant deploy into OU of another.
In Foreman we also find usage of this. example in your windows default finish template:
powershell.exe -OutputFormat text -command Add-Computer -DomainName '<%= host_param('computerDomain') -%>' -Credential (New-Object -TypeName System.Management.Automation.PSCredential '<%= host_param('domainAdminAccount') -%>', (ConvertTo-SecureString -String '<%= host_param('domainAdminAccountPasswd') -%>' -AsPlainText -Force)) <% if host_param('computerOU').present? -%>-OUPath '<%= host_param('computerOU') -%>'<% end -%>
See how OU path is specified.
this powershell script is used in PXE provisioning, but we want to utilise VM clone with vSphere guest customization and sysprep.
Sysprep allows for this. see machineObjectOU in Identification | Microsoft Learn
I’ve tried that, but the moment I remove joinWorkGroup and add joinDomain, it errors that domainAdminAccount is also required:
identification->domainAdmin is required when using Sysprep identity and identification → joinDomain
i searched your github repo to find this error, but couldn’t but found exact reference to vsphere fog github
it in one of the foreman packages I also found reference to fog, so it seems you utilise this.
I’ve then followed the instructions by reverse-engineering the code and configuring in user-data script
identification:
joinDomain: '<%= @host.domain %>'
domainAdmin: <%= host_param('domain_user') %>
domainAdminPassword:
plainText: true
value: <%= host_param('domain_password') %>
this allows me to provison the VM, but customization never ends, my feeling is that it is due to the fact nowhere I specified which OU to add it to
and looking at the fog vsphere there is no way.
any ideas? is there a different way other than to utilise webhook and pre-join the VM in OU with set machine password?