How to install vRealize Operations Telegraf agent using vRealize Automation and SaltStack Config
| 5 minutes
VMware vRealize SaltStack Config vRealize Automation vRealize Operations vRealize Suite SaltStack Telegraf

While exploring vRealize Automation and SaltStack Config, I had the bright idea to expand the integrations across the vRealize Suite by automatically installing the vROPs Telegraf agent during a vRA Deployment. This would provide immediate guest OS monitoring and (optional) application monitoring to every machine deployed from vRA.

What you’ll need:

  • vRealize Automation 8.8
  • vRealize SaltStack Config 8.8
    • Integrated with vRealize Automation through either vRealize Suite Lifecycle Manager or as a standalone SaltStack instance. This article was written using the integrated method via vRSLCM, not a standalone deployment.
  • vRealize Operations 8.6.x
    • Cloud Proxy deployed and integrated with vRealize Operations.
  • The CTRL, C and V keys on your keyboard

Before you start, review the prerequisites for the Telegraf agent here.

For this demo, we’ll be installing the Linux Telegraf agent on Ubuntu. Scripted installation instructions can be found here. These instructions were used to create the Salt State File.

Creating the Salt State file and dependencies

Referencing the Telegraf installation documentation, the process to install the vROPs Telegraf agent requires us to fetch a download.sh file from the Cloud Proxy registered with vROPs. Based on my testing, the script requires root equivalent access to install the agent. In my Ubuntu image, the default ubuntu account has sudo access but was still not able to install directly from the download.sh script. This necessitated a “wrapper” script that would wrap a sudo elevated execution of the download.sh file. I’ll provide the state file and the wrapper script in this post.

Create the installation wrapper script

  1. Start by logging in to your vRealize SaltStack Config console and navigate to Config > File Server.

  2. In the right hand pane, select a Salt Environment and your preferred path for a new SLS file. For this example, I used the Salt Environment lab and the file path /linux/telegraf/wrapper.sh. If you want to create a new Salt Environment, type a new value in the Environment drop down.

  3. In the large text box, paste the following replacing the {vrops-fqdn}, {vrops-admin} and {vrops-password} options with your own. Then click Save.
    #!/bin/bash
    sudo su -c '/tmp/download.sh -o install -v {vrops-fqdn} -u {vrops-admin} -p {vrops-password}'
    

    Installation wrapper

  4. Once saved, you can browse the Salt File Server directory tree and you’ll see the new file in the path you specified:

With the installation wrapper ready, we can create the Telegraf installation Salt State File.

Create the Telegraf Installation State File

  1. With the File Server page still open, click the Create button.

  2. In the right hand pane, similar to the installation wrapper, select a Salt Environment and your preferred path for a new SLS file. For this example, I used the Salt Environment lab and the file path /linux/telegraf/init.sls. If you want to create a new Salt Environment, type a new value in the Environment drop down.

  3. In the large text box, paste the following and click Save
unzip:
    pkg.installed

download-vrops-installer-script:
    file.managed:
        - source: https://vrcp-01.williams.lab/downloads/salt/download.sh
        - name: /tmp/download.sh
        - mode: '0777'

download-wrapper-script:
    file.managed:
        - source: salt://linux/telegraf/wrapper.sh
        - name: /tmp/wrapper.sh
        - mode: '0777'
    
install_vrops_agent:
    cmd.run:
        - name: /tmp/wrapper.sh
        - retry:
            attempts: 5
            until: True
            interval: 60
  1. Once saved, you can browse the directory tree and you’ll see the new file in the path you specified:

Let’s breakdown each block.

Ensure the “unzip” package is installed on the OS:

unzip:
    pkg.installed

Ensure the Telegraf installation script from the vROPs Cloud Proxy is available on the local file system at /tmp/download.sh. We’re also skipping checksum validation and SSL vertification for the HTTPS endpoint.

download-vrops-installer-script:
    file.managed:
        - source: https://vrcp-01.williams.lab/downloads/salt/download.sh
        - name: /tmp/download.sh
        - mode: '0777'
        - skip_verify: True
        - verify_ssl: False

Ensure the installation wrapper script located on the Salt Master (under /linux/telegraf) is available on the local file system at /tmp/wrapper.sh:

download-wrapper-script:
  file.managed:
    - source: salt://linux/telegraf/wrapper.sh
    - name: /tmp/wrapper.sh
    - mode: '0777'

Run the installation wrapper script:

install_vrops_agent:
  cmd.run:
    - name: /tmp/wrapper.sh
    - retry:
        attempts: 5
        until: True
        interval: 60

With the Salt state file created, we can move onto creating the vRA Cloud Template.

Using the new Salt state in vRealize Automation

Update your Cloud Template

  1. Open your vRA instance in a new tab and launch Cloud Assembly.
  2. Open an existing template or create a new one. I’m using my Ubuntu 20.04 - Vanilla template.
  3. Drag-and-drop the SaltStack Config object to the canvas.

  4. In the template yaml, locate the new SaltStack Config object.

  5. Populate the SaltStack object with your environments SaltStack variables, along with the State file created earlier.

    Note: vRA will attempt to provide you a dropdown to select values imported from SaltStack.

Deploying a test VM

  1. Deploy your your template with your expected inputs, and navigate to the History tab. We can monitor the status of the request.

  2. Once the VM resource creation has completed, you’ll see the Cloud.SaltStack resource creation start.

  3. Switch back to your SaltStack Config tab and navigate to Activity > In Progress.

  4. You’ll see one or two jobs related to your new machine. Look for the deploy.minion function.

  5. It’ll take a few minutes, but SaltStack will install the minion and the deploy.minion task will move to the Completed jobs section.

  6. A short while later, you’ll see the minion key accepted, followed by the state.apply function run. This is our vROPs Agent installation state being applied.

  7. Go back to vRA and look at your deployment. You’ll see the deployment was successful and the SaltStack resource was also successful. Note that our Health badge is visible, thanks to the vRA and vROPs integration.

  8. Open a new tab and login to your vROPs instance.
  9. Navigate to Environment > Applications > Manage Telegraf Agents.

  10. Notice anything? Yup! Our newly deployed VM is available in vROPs ready for applications to be monitored.

Bonus Content

One thing I noticed was that the SaltStack Config object in the template supports the use of allocatePerInstance. This means we can scale out the number of Cloud.Machine objects with a count property, and just add allocatePerInstance: true to the SaltStack object:

SaltStack Config with allocatePerInstance and Cloud.Machine with a count of '3'

Request submitted with a VM count of 3

3 minion keys accepted

3 states applied, 1 for each VM

All 3 nodes listed in vROPs


There we have it, installing the vROPs Telegraf agent with SaltStack Config and a vRA Template. If you have any questions drop them in the comments.

About Stellios Williams
Senior Cloud Solutions Architect - Service Providers VMware
This is my personal tech related blog for anything private and public cloud - including homelabs! My postings are my own and don’t necessarily represent VMware’s positions, strategies or opinions. Any technical guidance or advice is given without warranty or consideration for your unique issues or circumstances.
Comments
comments powered by Disqus
Advertisement