Overview
In this article we will cover utilizing the property tool kit to dynamically generate a MAC address that will be passed into your Infoblox. Since the subnet is managed by Microsoft there is a requirement to pass through a MAC address into your Infoblox so that Microsoft can reserve the IP Address. Without a MAC Address, Microsoft DNS will not reserve a record / PTR for you and the deployment will fail.
CAUTION: If you are deploying to an Infoblox managed zone you may get an error for getting next IP Address and/or to enter a Valid MAC Address. This workaround is ONLY for zones that are Sync'd to Infoblox from Microsoft.
Considerations
- Are using both Infoblox and Microsoft to manage IP Subnets / DNS
- The subnet you want to update is managed through Microsoft
- You have licensed the SovLabs Property Toolkit
- You have a good understanding of template engine code
Code used for MAC address creation
Below is the Template Engine code for the creation of a random MAC Address for use with Microsoft. This code will dynamically create a MAC address starting with 02 which will make it a Private MAC address. The code is written in a way that it is generated per VM and won't be over written on subsequent runs.
{% if VirtualMachine.Network0.MacAddress and VirtualMachine.Network0.MacAddress != '' %}{{VirtualMachine.Network0.MacAddress}}{% else %}02:{% assign min = 0 %}{% assign max = 255 %}{% assign diff = max | minus: min %}{% assign myDate = 'now' | date: '%Y%m%d%H%M%S' %}{% assign num = myDate | times: 54628 | modulo: diff | plus: min %}{% assign res1 = num | divided_by: 16 %}{% assign rem1 = num | modulo: 16 %}{% assign rem2 = res1 | modulo: 16 %}{% assign rems = rem2 | append: ',' | append: rem1 | split: ',' %}{% for rem in rems %}{% assign num = rem | plus: 0 %}{% if num < 10 %}{{num}}{% elsif num == 10 %}a{% elsif num == 11 %}b{% elsif num == 12 %}c{% elsif num == 13 %}d{% elsif num == 14 %}e{% elsif num == 15 %}f{% else %}default{% endif %}{% endfor %}:{% assign num = myDate | times: 21628 | modulo: diff | plus: min %}{% assign res1 = num | divided_by: 16 %}{% assign rem1 = num | modulo: 16 %}{% assign rem2 = res1 | modulo: 16 %}{% assign rems = rem2 | append: ',' | append: rem1 | split: ',' %}{% for rem in rems %}{% assign num = rem | plus: 0 %}{% if num < 10 %}{{num}}{% elsif num == 10 %}a{% elsif num == 11 %}b{% elsif num == 12 %}c{% elsif num == 13 %}d{% elsif num == 14 %}e{% elsif num == 15 %}f{% else %}default{% endif %}{% endfor %}:{% assign num = myDate | times: 58293 | modulo: diff | plus: min %}{% assign res1 = num | divided_by: 16 %}{% assign rem1 = num | modulo: 16 %}{% assign rem2 = res1 | modulo: 16 %}{% assign rems = rem2 | append: ',' | append: rem1 | split: ',' %}{% for rem in rems %}{% assign num = rem | plus: 0 %}{% if num < 10 %}{{num}}{% elsif num == 10 %}a{% elsif num == 11 %}b{% elsif num == 12 %}c{% elsif num == 13 %}d{% elsif num == 14 %}e{% elsif num == 15 %}f{% else %}default{% endif %}{% endfor %}:{% assign num = myDate | times: 92617 | modulo: diff | plus: min %}{% assign res1 = num | divided_by: 16 %}{% assign rem1 = num | modulo: 16 %}{% assign rem2 = res1 | modulo: 16 %}{% assign rems = rem2 | append: ',' | append: rem1 | split: ',' %}{% for rem in rems %}{% assign num = rem | plus: 0 %}{% if num < 10 %}{{num}}{% elsif num == 10 %}a{% elsif num == 11 %}b{% elsif num == 12 %}c{% elsif num == 13 %}d{% elsif num == 14 %}e{% elsif num == 15 %}f{% else %}default{% endif %}{% endfor %}:{% assign num = myDate | times: 20193 | modulo: diff | plus: min %}{% assign res1 = num | divided_by: 16 %}{% assign rem1 = num | modulo: 16 %}{% assign rem2 = res1 | modulo: 16 %}{% assign rems = rem2 | append: ',' | append: rem1 | split: ',' %}{% for rem in rems %}{% assign num = rem | plus: 0 %}{% if num < 10 %}{{num}}{% elsif num == 10 %}a{% elsif num == 11 %}b{% elsif num == 12 %}c{% elsif num == 13 %}d{% elsif num == 14 %}e{% elsif num == 15 %}f{% else %}default{% endif %}{% endfor %}{% endif %}
Procedure
Create a property group using property toolkit
- Once logged into vRA, Click on Administration (1), Property Dictionary (2), Property Groups (3) and the click on New (4)
- Enter the name of your new Property group, ensure it begins with SVL_ to trigger the property toolkit. Enter a description as required.
- Next to properties, click on New
- In the Name field, Type in "VirtualMachine.Network0.MacAddress" (Without quotation marks). and the Value Field, paste the code from the Code used section then click on OK
- Repeat steps 3 and 4 except enter the Name of "VirtualMachine.Network0.MacAddressType" and the Value of "Static" (No quotation marks) and click OK
- Click on OK to finish creating the group
Add the newly create SVL_ property group to your blueprint
- From within vRA, click on Design and the click on the blueprint you wish to add the SVL_ property group to
- In your blueprint click on Properties (1), Property Groups (2) and click on Add (3)
- Locate your SVL_ Group that you created and place a check next to the name and click on OK
- Click on Finish
Updating your Infoblox IPAM Endpoint
We will go through adding the Template information into the Infoblox endpoint so that it will add the value for MAC Address. This assumes you already have an endpoint created.
- Click on Deployments (1) and then under components look for SovLabs Infoblox Endpoint (2) and place a check next to this
- For the Infoblox Endpoint you wish to update, click on Actions (2) and then click on Update Infoblox Endpoint (2)
- Click on Advanced
- In the field for Fixed Address template, you will see a value named "mac":"{{paramMac}}". We will change the text in the curly brackets to be VirtualMachine.Network0.MacAddress
BEFORE
AFTER - Click on Submit
Deploying a VM with the Dynamically created MAC address
- To validate the functionality. I deployed a machine called Dynamac and checked my Infoblox to see what the MAC Address field was populated with.
- I deployed 2 instances on the same template to validate that the MAC address creation was dynamic and all were different allocating the same host name but allowing the Naming sequence to create the sequence for me.
Additional information
SovLabs template engine : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/framework/sovlabs-template-engine/basics/intro/
SovLabs Property Toolkit : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/modules/vra-toolkits/property-toolkit/
SovLabs Infoblox IPAM : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/modules/ipam/infoblox-ipam/
SovLabs Infoblox DNS : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/modules/dns/infoblox-dns/
0 Comments