Press "Enter" to skip to content

vRA 8 and AWS UserData

I have been working days straight getting some emergency convid 19 capability up and running for customers. Ive heard cloud native being spewed out so many times over the last couple of weeks and have heard I am assuming every definition of what it is from “it when you use containers” or “when you use cloud services like lambda or RDS etc” or “its when you use micro services” all the way to its “when you deploy into the public cloud”. For me I like to keep it simple in basically inline with CNCF definition. to me its more an operating model making use of the cloud operating models of IaaS, SaaS and PaaS so at the end of the day it’s not a destination its not a technology its how you operate, highly automated deployment and management.

Why did I cover that? well because I have been automating a “cloud native” application and at its core requires windows server on EC2 machines to be deployed and the way they operate it is very much a cloud native app making use of IaaS automation and auxiliary services plugging into the likes of S3 and rds etc.

Usually my go to is Software Components while they don’t replace the need for a config management system they where very good at deploying large complex clustered deployment requiring reboots and the passing of inputs and outputs between 1 or many machines. While this isn’t impossible with other tools, Software Components handled this complex logic for you and all you had to worry about was the scripts. Now Software Components from what I have heard are coming back but util then Currently with vRA 8 / Cloud when ansible and puppet is not available the fall back is to cloud-init.

There are many blogs out there on cloud init and vRA but I have yet to see one dealing with windows. I do have a video on this HERE. but this video is making use of cloudbase-init which is cloud-init for windows. When working with cloud-init or cloudbase-init it makes it agnostic to the endpoint. For the most recent challenge it was only going to AWS using EC2 windows servers, now I know I can use userdata and run scripts in windows or Linux machines in AWS and from my experience vRA submits the cloud config as userdata as part of the build request. So I thought hey lets try using the AWS windows userdata syntax and see if it works, will save me installing cloudbase-init.

I cant share the actual code I was using on the customers site but the example is something I knocked together in my lab.
Using the below code block under the cloudconfig property in the blueprint

         Install-WindowsFeature -name Web-Server -IncludeManagementTools
         c:\\temp\\sql\\setup.exe /Q /IACCEPTSQLSERVERLICENSETERMS /ACTION="install" /FEATURES=SQL,AS,IS,Tools /INSTANCENAME=${input.sqlInstanceName} /SQLSVCACCOUNT="virtualiseme\service_vcac" /SQLSVCPASSWORD="${input.servicePassword}" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /ASSYSADMINACCOUNTS="virtualiseme\service_vcac" /AGTSVCACCOUNT="virtualiseme\service_vcac" /AGTSVCPASSWORD="${input.servicePassword}" /ASSVCACCOUNT="virtualiseme\service_vcac" /ASSVCPASSWORD="${input.servicePassword}" /ISSVCAccount="virtualiseme\service_vcac" /ISSVCPASSWORD="${input.servicePassword}" /SAPWD="${input.servicePassword}"
         Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

It successfully passed this into AWS userdata and executed this code within a windows server, I was using an ami off the base windows 2016 and 2019 image in the marketplace with some binaries pre-uploaded. but the base image will work with any ootb powershell commands.
Below is the code in full context:

formatVersion: 1
    type: string
    encrypted: true
    description: Service Account Password
    title: SQL Service4 Account Password
    type: string
    description: Name for SQL Instance
    title: SQL Instance Name
    type: Cloud.Network
      networkType: existing
        - tag: 'networkZone:private'
    type: Cloud.Machine
      image: Windows 2019
      flavor: medium
        - tag: 'platform:aws'
      cloudConfig: |
          Install-WindowsFeature -name Web-Server -IncludeManagementTools
          c:\\temp\\sql\\setup.exe /Q /IACCEPTSQLSERVERLICENSETERMS /ACTION="install" /FEATURES=SQL,AS,IS,Tools /INSTANCENAME=${input.sqlInstanceName} /SQLSVCACCOUNT="service_vcac" /SQLSVCPASSWORD="${input.servicePassword}" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /ASSYSADMINACCOUNTS="virtualiseme\service_vcac" /AGTSVCACCOUNT="service_vcac" /AGTSVCPASSWORD="${input.servicePassword}" /ASSVCACCOUNT="service_vcac" /ASSVCPASSWORD="${input.servicePassword}" /ISSVCAccount="service_vcac" /ISSVCPASSWORD="${input.servicePassword}" /SAPWD="${input.servicePassword}"
          Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
        - network: '${}'

Notice that this is just using the <powershell> tags. I havent tested but I would assume going from the aws reference we could use <script> tags for CMD like:

echo Current date and time >> %SystemRoot%\Temp\test.log
echo %DATE% %TIME% >> %SystemRoot%\Temp\test.log

Thought this was pretty cool and something I was able to utilize to very rapidly get a customers covid 19 application up and running without mucking around. having a mix of windows and cloud native services rapidly deployed and scaled as a whole. Also shows how easily and flexible vRA 8/Cloud can be.

Until Next Time

One Comment

  1. Naresh K Debta
    Naresh K Debta May 31, 2020

    Hi Friend,

    Can we have a blueprint on 8.1 to create a 2 or 3 node Microsoft failover cluster where node connect with RDM and share with all nodes. Basically I want to know how can we create BP take input for RDM from user and attach it to vm and share with multiple vm automatically

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti SPAM BOT Question * Time limit is exhausted. Please reload CAPTCHA.