NetDocuments-Archive / ad-join-cookbook

Chef cookbook to join windows computer to AD
Apache License 2.0
14 stars 12 forks source link

Attribute to prevent changing of hostname #5

Closed cpressland closed 8 years ago

cpressland commented 8 years ago

Hi,

It'd be nice to be able to set a value/attribute to define if the Computer Name update part of the Cookbook runs.

Maybe have an Attribute like:

default['ad-join']['windows']['update_hostname'] = true

I'm working in an environment where the production node name has a few extra characters than the actual hostname. Example, nodename = orgname-example while hostname = example

As the hostnames are previously set by knife-vsphere there is no need to update the hostname.

Thanks!

spuder commented 8 years ago

Could you elaborate?

As of right now, the cookbook only renames the VM in active directory if you bootstrap with the -N option.

If you don't pass in a new name, then it joins the domain with whatever the current hostname is.

cpressland commented 8 years ago

Sure, sorry I wasn't clear enough.

In a nut shell when we provision a VM we specify the hostname as part of it's creation, VMWare itself then syspreps the instance with the requested name. Example syntax would be like this:

knife vsphere vm clone STAGADJOIN01 --chostname STAGADJOIN01 --template Win2012R2_Template_V3 --cips 192.168.153.220/24 --ccpu 4 --cram 4 --datastore Datastore04 --cvlan hotels4u_dev --folder crm_folder/Templates --dest-folder crm_folder/'Staging Environment' --resource-pool Example/Example --cdnsips 192.168.157.10,192.168.157.11 --cdnssuffix grouplongtail.local --cspec WinCust_v3 --start true -VV

Within a few minutes the VM is provisioned and good to go with the hostname STAGADJOIN01. Once the process is finished, I bootstrap it:

knife bootstrap windows winrm 192.168.153.220 --winrm-user binduser -N glp-stagadjoin01 -E staging -VV

So as you can see, the VM's Hostname is STAGADJOIN01 and it's nodename is glp-stagadjoin01. When I run the cookbook it automatically tries to update the machines hostname to glp-stagadjoin01 when we'd like to keep it as STAGADJOIN01. So what I'm looking for is some kind of attribute or other config I can set which will prevent the name from updating regardless of config and only handle the binding to the domain.

Hope this helps, thanks for everything so far.

spuder commented 8 years ago

Could you try this branch and see if it does what you are looking for? Point your berksfile to the following branch / git ref.

https://github.com/NetDocuments/ad-join-cookbook/tree/feature/rename

https://github.com/NetDocuments/ad-join-cookbook/commit/8d39e9a1cc8d674556bfa7e86873dc12e705e25c

It has a new attribute that I believe will do what you are looking for. If the value is false, then the domain name will always be the same as the hostname (never the chef name).

node['ad-join']['rename_server'] = false
cpressland commented 8 years ago

Just finished testing this and it works exactly as expected. Thanks!

spuder commented 8 years ago

I've changed the attribute to the name you originally suggested.

node['ad-join']['windows']['update_hostname']

I've merged this to master and pushed version 4.4.0 to the supermarket.

I deleted the other branch so you will likely get errors until you switch your berks file back to point to the supermarket / master branch.