Management

 View Only

Leveraging the Power of Multi-Target-Automations

By Sebastian Wegmann posted Tue June 30, 2020 06:11 AM

  

The Runbook Automation release from May 2018 brought a new concept on automations into the world of CEM users. The ability to run a single automation on multiple targets at once. In this post we will show you some nifty tips and tricks on doing more with less effort.

Doing a lot in parallel

Generally speaking we like programs and applications, which can do the things we want to in parallel. Luckily CEM/RBA learned to do that with the new Multi-Target Automation feature. The most obvious use case is to use it to run something on as many servers as you like. Bygone are the days of chaining a simple automation, which takes ten seconds to run, twenty times and wait for more than three minutes.

In this example we’ll be checking the disc space of some of our systems running docker. In the past we had problems with the docker hosts running out of file system space, as the containers get a pre-defined amount of space. The host system stores the docker relevant files under /var/lib/docker.

The Automation

Our automation script looks like this:

#!/bin/sh

freeSpace=`df -m $path | grep -v -e ‘^Filesystem’ | awk ‘{ print $4;}’`
if test $freeSpace -lt $threshold
then
echo "There is not enough space left on the device ($freeSpace)."
exit 1
else
echo "Everything is good."
fi

Our script works with two variables. A $path and a $threshold. We will define both of them in our runbook, so we remain flexible should we want to change anything or use the automation in another context. If the amount of disc space is less than $threshold MiB, the script will fail.

The Mappings

The first step in leveraging the Multi-Target Automation is to embed this into a runbook. For now we will just run the automation and do nothing else. We created the following automation mappings:

Automation Parameter Mapping
Target Map to runbook parameter ‘hostnames’
User Use the username
path Map to runbook parameter ‘path’
threshold Fixed value ‘512’

Executing all-at-once

With everything setup, the last step is to actually execute the runbook. The operator receives a list of fifty systems to check. He looks up the correct runbook and enters as the parameters:

  • hostnames: [dockerhost01,dockerhost02,dockerhost03,…,dockerhost50]
  • path: /var/lib/docker

As a result, our operator gets one easy to read output:

dockerhost01 out: Everything is good.
dockerhost02 out: Everything is good.
dockerhost03 out: Everything is good.
(…)
dockerhost15 out: There is not enough space left on the device (212).
(…)
dockerhost49 out: Everything is good.
dockerhost50 out: Everything is good.

Unsuccessful: [dockerhost15] Successful: [dockerhost01,…,dockerhost14,…,dockerhost16,dockerhost50] Failed: []

As the automation typically only runs for a few seconds on each system, the operator gets the result in seconds and immediately sees which system is lacking the proper amount of free disc space.

Get the Example

Head on over to our public github repository and import the following runbook to add this example directly to your runbook library:

Basic Multi Target Automation Runbook






0 comments
9 views

Permalink