Automating the Configuration of Log Insight

Now that you know how to automate the deployment of Log Insight, you are probably wondering how to automate the configuration of Log Insight. Automating the configuration of Log Insight is a little harder because Log Insight does not have a configuration API today and because by default SSH is disabled until the root password is set. In addition, the root password cannot be set through OVF properties today.
So how do you automate the configuration of Log Insight?

Disclaimer

WARNING: This is not officially supported by VMware, use at your own risk. More specifically, the local filesystem and especially /storage should not be modified on the Log Insight VA. Doing so may result in Log Insight being unable to start or even permanent data loss.

I have had this post queued up for awhile and just learned yesterday that Caleb did a post on this topic. I would encourage you to take a look at his post here.

Create a template

  1. Deploy and power on Log Insight
  2. Set the root password on the console
  3. Power off the VM

Create a configuration file

IMPORTANT: This step is Log Insight version specific. If you plan to automate the deployment of Log Insight 1.0 and 1.5, you should create two separate configuration files as the format of the configuration file may change between versions.

  1. Deploy and power on Log Insight
  2. Set the root password on the console
  3. Navigate to the HTML 5 interface and perform the one-time configuration (skip the vCenter Operations Manager step)
  4. Run the following command to grab the configuration file generated from the VA
    CONFIGFILE=$(ssh root@<loginsight> "ls /storage/core/loginsight/config/loginsight-config.xml* | sort -k1.55n | tail -n 1")
    scp root@<loginsight>:${CONFIGFILE} .
    scp root@<loginsight>:/etc/ntp.target.conf ntp.conf
  5. Power off and delete the VM

Configure a Log Insight deployment

  1. Deploy Log Insight using the template created above
  2. Copy the configuration file generated to the deployed instance
  3. Copy a license key to the deployed instance
  4. Copy any content pack to be installed (optional)
  5. Configure NTP
  6. Restart the Log Insight process so the changes take effect
  7. Set the admin password
  8. Add users to postgres database (optional)

In scripted form this would look like:

ssh root@<loginsight2> "mkdir /storage/core/loginsight/config"
scp loginsight-config.xml* root@<loginsight2>:/storage/core/loginsight/config/
ssh root@<loginsight2> "echo \"<licenseKey>\" >/usr/lib/loginsight/application/etc/license/loginsight_license.txt"
ssh root@<loginsight2> "mkdir /usr/lib/loginsight/application/etc/content-packs/<contentPack>"
scp <contentPack> root@<loginsight2>:/usr/lib/loginsight/application/etc/content-packs/<contentPack>/content.json"
scp <ntp.conf> root@<loginsight2>:/etc/ntp.conf
ssh root@<loginsight2> "cp /etc/ntp.conf /etc/ntp.target.conf; chkconfig ntp --level 345 on; service ntp restart"
ssh root@<loginsight2> "service loginsight restart"
ssh root@<loginsight2> "/opt/vmware/bin/li-reset-admin-passwd.sh"

Notes:

  • To ease automation (at the cost of security) you can use sshpass to handle authentication instead of writing an expect script
  • To ease automation (at the cost of security) you can disable host key checking
  • The li-reset-admin-passwd.sh script by default generates a random password. If you wish to set the password then set the environment variable ADMINPASSWORD before running the command

An example of a scripted form given the above notes would be:

sshpass -p <rootPassword> ssh -oStrictHostKeyChecking=no root@<<loginsight2> "mkdir /storage/core/loginsight/config"
sshpass -p <rootPassword> scp -oStrictHostKeyChecking=no loginsight-config.xml* root@<loginsight2>:/storage/core/loginsight/config/
sshpass -p <rootPassword> ssh -oStrictHostKeyChecking=no root@<loginsight2> "mkdir /usr/lib/loginsight/application/etc/content-packs/<contentPack>"
sshpass -p <rootPassword> scp -oStrictHostKeyChecking=no <contentPack> root@<loginsight2>:/usr/lib/loginsight/application/etc/content-packs/<contentPack>/content.json"
sshpass -p <rootPassword> scp -oStrictHostKeyChecking=no <ntp.conf> root@<loginsight2>:/etc/ntp.conf
sshpass -p <rootPassword> ssh -oStrictHostKeyChecking=no root@<loginsight2> "cp /etc/ntp.conf /etc/ntp.target.conf; chkconfig ntp --level 345 on; service ntp restart"
sshpass -p <rootPassword> ssh -oStrictHostKeyChecking=no root@<loginsight2> "service loginsight restart"
sshpass -p <rootPassword> ssh -oStrictHostKeyChecking=no root@<loginsight2> "export ADMINPASSWORD="changeme"; /opt/vmware/bin/li-reset-admin-passwd.sh; export ADMINPASSWORD="

© 2014, Steve Flanders. All rights reserved.

Leave a Reply

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

Back To Top