Automate Log Insight logging of new Linux VM’s Provisioned from vRA

So you just implemented the vRealize Suite and you want to make sure any Linux VM you deploy get’s added to Log Insight right? Well look no further you came to the right place.

Pre-Reqs you need in place for this integration to work:

  • vCAC 6.0, 6.1 or vRA 6.2 installed and configured
  • vRealize Log insight 2.5 installed and configured
  • Linux Guest agent template see my guide here
  • An NFS server with a script directory available for you to run scripts and install software from
  • A quite place to work for a few hours where you will not be interrupted.

Let’s get started: Power on your Linux guest agent template and login as root or sudo to root and create directory on the root file system named repo. This is where you will mount your NFS share to.

media_1414087558649.png

Next, create a file named repomount.sh using the vi editor with the following content and save it.

media_1414087673570.png
mount -t nfs $1:$2 /repo &>/repomount.log

Make the repomount .sh executable by typing the following then pressing enter

media_1423318777280.png
chmod u+x repomount.sh

Note: Depending on your Linux installation you may not have the nfs-utils package. You can instal it manually on the template image or add it to your repomount.sh file. You should test your repomount script to make sure it works prior to shutting down the template.

media_1423318876950.png
yum -y install nfs-utils

Now shutdown your template. If you are using Linked clones you will also need to take a new snapshot and then run an inventory scan in vCAC and update the blueprint to point to the new snapshot. See here for instructions.

Now we need add the necessary files and scripts to the NFS share. First we will need to get the Linx RPM based agent from Log Insight server. Log into the vRealize Log insight portal then go to the administration page and agents and click Download Log Insight Agent version 2.5

media_1423319315072.jpg

Choose the Linux RPM (32-bit/64-bit) and save that file to your local system.

media_1423319367465.jpg

Now use WinSCP to upload this rpm to the NFS server

media_1423319555099.png

Now we need to create the script that will install the agent and register it with the vRealize Log Insight server. create a new file named vrlogagentinstall.sh using the vi editor

media_1423319694542.png
vi vrlogagentinstall.sh

Enter the command in the following format. Notice that server host is a variable $1 and the RPM name needs to match what you downloaded from the Log Insight server with the path relative to repo which we will mount as part of the vRA provisioning process. When done press ESC and then hold down shift and pres zz and hit enter to save the file.

media_1423319904563.png
SERVERHOST=$1 rpm -i /repo/VMware-Log-Insight-Agent-2.5.0-2347850.noarch.rpm

Now let’s create the build profile for this blueprint to use. Login to vCAC and navigate to the Infrastructure tab, then Blueprints, then Build Profiles and click to create a new build profile.

media_1414085844034.jpg

Now create the following build profile

media_1423320349540.png
LogInsight.Server vrlog-01a.corp.local
repo.path /scripts
repo.server yourNFSServer
VirtualMachine.Admin.UseGuestAgent true
VirtualMachine.Customize.WaitComplete true
VirtualMachine.Software0.Name repomount.sh
VirtualMachine.Software0.ScriptPath /repomount.sh {repo.server} {repo.path}
VirtualMachine.Software1.Name vrlogagentinstall.sh
VirtualMachine.Software1.ScriptPath /repo/vrlogagentinstall.sh {LogInsight.Server}

Now navigate to your Linux guest agent blueprint and attach this build profile to it and save it.

media_1423320680988.jpg

What this integration will actually do: It will call the repomount.sh script to mount the NFS share on the server you specify and to the directory you specified. It will mount that NFS share to the /repo directory in the guest. Next it will execute the script you specified that is in the NFS share to install the Log Insight agent. It will pass the Log Insight server to the RPM installer so if you ever need to change log insight servers you can update the property in the build profile.

Now fire off a new request and test your results.

media_1423321464422.png

After the new server is provisioned you should see it added to the Log Insight server

media_1423321364110.jpg

Instantly begin analyzing logs from the new server.

media_1423321564999.png

Let’s just recap what we did:

  1. We created a Linux blueprint with the vCAC guest agent installed and configured
  2. We added a repomount script to the Linux template that will mount a repo directory where a develper could call whatever scripts they want in the guest
  3. We created a custom build profile that will install and configure the Log Insight agent from an NFS share.
  4. We requested a new VM with this build profile
  5. Verified the script ran and installed and configure the Log Insight Agent by viewing the Log Insight web portal.

 

 

Remember, sharing is caring ->Tweet about this on Twitter
Twitter
Share on Facebook
Facebook
0Share on LinkedIn
Linkedin
Email this to someone
email

One Reply to “Automate Log Insight logging of new Linux VM’s Provisioned from vRA”

  1. Pingback: Newsletter: February 15, 2015 | Notes from MWhite

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.