Although a lot of the developments in vRealize Automation are focussed on the integration with VMware’s own solutions (an exception is support for Azure since 7.2), vRealize Automation 7.4 adds a nice new feature for the AWS endpoint. vRA 7.4 now supports the AWS “user data” feature. For those who don’t know this option: with the user data you feature can run Linux commands at the initial launch, to perform common configuration tasks including the execution of scripts. Notice the user data is only used once, during the initial first boot.
Unfortunately nothing is mentioned about this feature in the 7.4 release notes, but it’s really there:
You can use the user data script to update your OS with the latest packages or do a basic application install. In a certain way it’s an alternative for the application services feature in vRealize Automation, but it’s much more limited and only Linux is supported. A big advantage is that you don’t need an agent to let this feature work. Let’s have a closer look on how to configure this new feature.
Configure the user data feature
To leverage the user data feature the only you have to do is to configure the Amazon.Extensions.UserData custom property. You can add this property directly to the blueprint, put in a property group or even add to the vRA request form for the virtual machine. In this example I am adding the custom property directly to the blueprint:
The value for userdata is the installation/configuration script. In this example I’m using the following script:
#!/bin/bash yum update -y yum install httpd -y service httpd start chkconfig httpd on
This script runs a basic installation of Apache webserver, start the service and makes sure that the webserver is automatically started after a reboot. Unfortunately the custom property doesn’t except a multi line input, so we have to add some line feeds here. The script above will change to this oneliner:
#!/bin/bash{LF}sudo yum update -y{LF}sudo yum install httpd -y{LF}sudo service httpd start{LF}sudo chkconfig httpd on
Now we can request the virtual machine in the vRA portal and see what happens. Unfortunately you don’t see anything in the execution information that this script is executed:
But after the VM is deployed in AWS, we can logon to the VM and check what is executed:
[ec2-user@ip-172-31-12-47 /]$ sudo cat /var/lib/cloud/instance/user-data.txt #!/bin/bash sudo yum update -y sudo yum install httpd -y sudo service httpd start sudo chkconfig httpd on [ec2-user@ip-172-31-12-47 /]$
As you can see the userdata script is perfectly inserted into the EC2 VM. And after a short while the Apache default homepage is available!