Add/remove vCAC IaaS VMs to/from DNS

Add/remove vCAC IaaS VMs to/from DNS server use-case:

A use case which is often required and which I finally found the time to wrap together and do it without the need for any Powershell connection.

How? Well I took Christophe Decanini great “Guest Script Manager” package from this Communities post. More specifically the run dnscmd.exe example from this link but then repackaged it so that it now works when called from vCAC external Stubs MachineProvisioned and MachineDisposing. The only object these two workflows take as input parameter is vCAC:Entity, which comes dynamically from IaaS and nothing else. All other required attributes are pre-set in the workflow and so need to be edited and filled with the relevant information when ported from one environment to the next.

The dnscmd command needs to run on a Windows VM which resides in a vCenter Server which is both connected to vCO via the vCenter plugin (so can be pointed at as VC:VirtualMachine) and that has dnscmd.exe installed.

Here is a screenshot of the Attributes one needs to set before running the workflow:

dns

And here they are in the table below:

Name Type Value Description
vcacHost vCAC:VCACHost Insert you vCAC Server here Your vCAC Server
vm VC:VirtualMachine Insert Windows VM with dnscmd installed Windows VM with dnscmd installed
vmUsername String Insert DNS admin username DNS admin username
vmPassword SecureString Insert DNS admin password DNS admin password
dnsServerFqdn String Insert your DNS Server FQDN DNS Server FQDN
zoneNameFqdn String Insert your domain Domain Name
recordType String A Example: A
createPtr Boolean Set Yes or No Optional PTR Yes or No

Now we need to associate these 2 workflows with a vCAC external Stub. More information about vCAC external stubs and how they can be associated with vCO workflows and triggered at runtime can be found here in Chris Alleaume’s excellent blog: Chris’s Blog

Make sure you associate your “add to DNS…” workflow with MachineProvisioned stub and  “Delete record from DNS…” workflow with MachineDisposing stub as described in Chris’s blog.

Job Done.

For your convenience the two vCO workflows mentioned above can be downloaded from here:

http://tinyurl.com/o3xymhp

Note: if you are facing an issue with UAC on 2012 and getting and error that it is unable to access file c:\Windows\system32\cmdANSI.exe (Workflow: Copy file from vCO to guest / Scriptable task (item1)#11), know that disabling UAC from the control panel might not be enough as you may also need to modify the registry and reboot as described here: http://social.technet.microsoft.com/wiki/contents/articles/13953.windows-server-2012-deactivating-uac.aspx

Thanks!

Yuval T

Advertisements

, , , , ,

  1. #1 by avlieshout on March 25, 2014 - 8:55 pm

    Hi Yuval,
    Nice post and useful in a lot of scenarios.
    The only drawback to using dnscmd.exe is that you can only use it against the DNS server in the domain the Windows VM is a member of. When you require provisioning VMs to multiple domains and multiple DNS servers it becomes more challenging.
    The only solution which I found useful is such a situation is using WMI and then PowerShell comes in handy again.

  2. #2 by cloudonsteroids on March 26, 2014 - 6:38 am

    Thanks Arnim. I see your point. Just thinking out loud here: I guess you could identify several windows servers in different domains to run dnscmd on and then add a decision point to your vCO workflow with a Custom property from the blueprint to decide which domain to point to and so which Windows server to point to for the dnscmd execution.

  3. #3 by Alex on April 15, 2014 - 5:28 am

    Great stuff. Great Blog.

    Question: would it not be easier to have DNSCMD installed on the Workers and just invoke a script from vCAC (bypassing vCO entirely) that runs the command?

    avlieshout,

    Complementing what Yuval suggested above, setting reserved custom properties at the Compute Resource level can probably make life easier in the scenario you described, i.e., you’d know exactly what the DNS suffix, servers, etc, are for each and every single one of them.

    • #4 by cloudonsteroids on April 15, 2014 - 5:35 am

      Going fwd all vCAC customisations/extensibility will be vco driven hence why I always push for vco rather than the Designer.

  4. #5 by Brandon on April 22, 2014 - 6:04 am

    Any input option to add the records to a child domain? Example:

    dnscmd dnsserver /recordadd company.com. Hostname.child A 10.x.x.x

    • #6 by cloudonsteroids on April 22, 2014 - 8:07 am

      I can’t think of why not. As a rule of thumb any command you can successfully run in the command line manually will work when automating via vCO so the answer is yes.

  5. #7 by Danny on September 24, 2014 - 4:06 pm

    Thank you very much for this, it works perfectly!

    Danny

  6. #8 by Santhosh on January 25, 2015 - 12:00 pm

    Thanks Yuval for sharing this information, how would I update dns record for Linux machine??
    I am provisioning Linux VM from vCAC and would like to add the current workflow to create dns A and ptr record for the Linux server.

    • #9 by cloudonsteroids on January 25, 2015 - 1:09 pm

      Santosh it is the same. Remember the dnscmd.exe is executed on a windows VM (vcac iaas server in my case) but the parameter we pass to it from vcac is the newly provisioned VM which can be either windows or Linux. Makes sense?

  7. #10 by Esi on June 17, 2015 - 4:11 pm

    Hi Yuval,

    Thanks for your post. it is very helpful. I have an issue with it and i was hoping you could help me: when i run the workflow manually i get a “chooser” popup window to search for vCAC:Entity, no matter what i type in the seach box, it does not find anything. Also adding this workflow as a MachineProvisioned state change workflow does not work either. I can see in the logs that workflow is called and run ok but i dont see it running in vRO at all. I checked the logs but i dont see any error. When I change the input for vCAC:entity to vCAC:VirtualMachine, running the workflow manually works but again it cannot be called from vcac. Any help would be appreciated.

    Esi

    • #11 by cloudonsteroids on June 17, 2015 - 4:15 pm

      Running manually in vco will not work as you noticed cause vcac:entity is an object that is only created during runtime in vcac. What do you see in the logs that makes you think it ran during machine provisioned state?

  8. #12 by Esi on June 17, 2015 - 4:21 pm

    Thanks for the prompt response. when i check the workflow history it says

    Succeeded 6/17/2015 12:00 PM WFStubMachineProvisioned DEM 6/17/2015 12:00 PM Workflow succeeded.

    what is what makes me think that the workflow is called, am I wrong?

    • #13 by cloudonsteroids on June 17, 2015 - 8:12 pm

      In the dem_all log you should see something like:
      Local:2015-06-17 13:06:03] [Debug]: Thread-Id: 9 – Using vCO ‘https://vra-01a.corp.local:8281/vco’
      [UTC:2015-06-17 20:06:03 Local:2015-06-17 13:06:03] [Debug]: Thread-Id: 9 – Executing workflow ‘WFStubBuildingMachine’ with id ‘3060d63b-bfc9-44d8-8806-70988c107787’
      [UTC:2015-06-17 20:06:03 Local:2015-06-17 13:06:03] [Debug]: Thread-Id: 9 – Parameter : virtualMachineId Value : 3b1bb04c-dd52-45b2-929d-11eac93e9edc
      [UTC:2015-06-17 20:06:03 Local:2015-06-17 13:06:03] [Trace]: Thread-Id: 9 – Sending workflow execution request: 3b1bb04c-dd52-45b2-929d-11eac93e9edc
      [UTC:2015-06-17 20:06:04 Local:2015-06-17 13:06:04] [Trace]: Thread-Id: 9 – Returned workflow execution id ‘https://vra-01a.corp.local:8281/vco/api/workflows/3060d63b-bfc9-44d8-8806-70988c107787/executions/ff8081814d7b9fc5014e0320b4f7056f/’
      [UTC:2015-06-17 20:06:04 Local:2015-06-17 13:06:04] [Trace]: Thread-Id: 9 – VcoWorkflow ‘WFStubBuildingMachine’ (https://vra-01a.corp.local:8281/vco/api/workflows/3060d63b-bfc9-44d8-8806-70988c107787/executions/ff8081814d7b9fc5014e0320b4f7056f/): Start checking for result, interval 10000 milliseconds
      [UTC:2015-06-17 20:06:14 Local:2015-06-17 13:06:14] [Trace]: Thread-Id: 9 – VcoWorkflow ‘WFStubBuildingMachine’ (https://vra-01a.corp.local:8281/vco/api/workflows/3060d63b-bfc9-44d8-8806-70988c107787/executions/ff8081814d7b9fc5014e0320b4f7056f/): got execution state ‘RUNNING’ after 00:00:10.0922256
      [UTC:2015-06-17 20:06:16 Local:2015-06-17 13:06:16] [Debug]: Thread-Id: 14 – Worker Controller.GetWorkflowInstances: Executing:1 Requested:14 Received:0
      [UTC:2015-06-17 20:06:24 Local:2015-06-17 13:06:24] [Trace]: Thread-Id: 9 – VcoWorkflow ‘WFStubBuildingMachine’ (https://vra-01a.corp.local:8281/vco/api/workflows/3060d63b-bfc9-44d8-8806-70988c107787/executions/ff8081814d7b9fc5014e0320b4f7056f/): got execution state ‘COMPLETED’ after 00:00:20.1774084
      [UTC:2015-06-17 20:06:24 Local:2015-06-17 13:06:24] [Trace]: Thread-Id: 9 – Found output parameter: subWorkflowOutputs value: System.Collections.Generic.Dictionary`2[System.String,System.Object]
      [UTC:2015-06-17 20:06:24 Local:2015-06-17 13:06:24] [Trace]: Thread-Id: 9 – Activity execution started.
      [UTC:2015-06-17 20:06:25 Local:2015-06-17 13:06:25] [Trace]: Thread-Id: 9 – Activity execution started.
      [UTC:2015-06-17 20:06:25 Local:2015-06-17 13:06:25] [Debug]: Thread-Id: 9 – ID: 3b1bb04c-dd52-45b2-929d-11eac93e9edc Workflow ‘WFStubBuildingMachine’ completed successfully.

      My example is with WFStubBuildingMachine but it should be the same with WFStubMachineProvisioned

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: