Paessler Blog - All about IT, Monitoring, and PRTG

Automate tasks in Paessler PRTG with Ansible

Written by Sascha Neumeier | Feb 17, 2023

Hang on, before you think, “This article will be way too technical for me...”, don’t skip it! I'll explain it simply! 🫶

After reading this article you will know:

What Ansible is
How Ansible helps you automate aspects of Paessler PRTG
That we started a Paessler PRTG Ansible collection
What use cases other PRTG sysadmins are implementing with Ansible

This will be amazing, so let's go!

What is Ansible and how does it work?

What could be more obvious in such a case than to ask ChatGPT about the functionality of Ansible? Our (human) Ansible expert David was quite impressed by the result!

Ansible is an open-source automation tool that helps automate various IT tasks such as configuration management, application deployment, and task automation. It uses an agentless architecture, meaning it does not require any software to be installed on the target systems. Instead, it uses SSH for communication and Python for scripting.

Ansible works by connecting to target systems and executing tasks on them. These tasks are defined in playbooks, which are written in a simple, human-readable language called YAML. Playbooks contain a series of instructions, called tasks, that Ansible uses to configure and manage target systems.

Ansible also uses modules, which are pre-built, reusable scripts that perform specific tasks. These modules can be used to execute commands, install software, manage files, and more.

Ansible uses an inventory file to define the target systems it will connect to. The inventory file is a simple text file that lists the IP addresses or hostnames of the target systems.

Ansible uses a control machine, which is the machine where Ansible is installed and executed from, to connect to target systems and execute tasks.

(Source: ChatGPT, verified by David, one of our Ansible experts at Paessler)

📢 Overall, Ansible works by connecting to target systems using SSH, executing tasks on those systems using modules and playbooks, and providing an easy-to-use, human-readable language for defining and automating IT tasks.

What would PRTG sysadmins like to do with Ansible?

To better understand what our PRTG users want to do with Ansible, we simply talked to some of you. We learned that there is quite a range of things that you want to do:

  • Create devices and sensors (this was the most common)
  • Pause/resume devices
  • Trigger an Ansible playbook when a sensor goes down in PRTG
  • Check to make sure that the state of PRTG is correct e.g. ensure notifications aren't paused, check that all their devices in inventory are also being monitored with PRTG, etc.

We also learned that some customers are already using Ansible to automate aspects around PRTG. One of our customers does PRTG updates and failover with Ansible. Let's take a closer look at how this works.

PRTG updates and failover with Ansible

The sysadmins of the customer just mentioned uses Ansible in unique ways to manage PRTG and their network. One way that I found interesting is how they use Ansible to do zero downtime updates and high availability for PRTG.

They run 2 PRTG servers and duplicate remote probes for all their locations. Using Ansible Automation Platform, they use robocopy to copy the PRTG configuration and database a few times a day.  

With the main server being backed up like this, if there’s a failure on one of the cores, they only have to start the PRTG core and probe services on the secondary node and they are back up and monitoring again.

The remote probes are also usually in standby mode and when the primary and secondary nodes are switched, the services on the standby remote probes are also switched on.  The trick here is that the remote probes have the same GUIDs so that when they connect to the secondary node, it has the configuration for all the remote probes, and they will immediately start monitoring.

This is practical for 2 reasons. First, when they need to do a PRTG update, the remote probes will also get updated and the whole setup can be tested before it’s used by the network team. Second, if there’s a problem with any of the VM’s that are being used for the core or the remote probes, the other system can be brought up instantly.

📢 The neat thing about the way this playbook is written is that using the automation platform, they can run the playbook in Active mode to check that all the PRTG services are running across their organization. When it’s run in Standby mode, it switches off the main PRTG and starts the standby system to allow for updates or failover scenarios.

We were excited by the customer's use case, and our developers immediately had lots of other ideas for tasks that could be automated with Ansible. That is why we decided to build our own Paessler PRTG Ansible collection which we provide to you for free!

First steps with our Paessler PRTG Ansible collection

We just started to build the collection. The first playbook handles the pausing and resuming of devices. This fairly simple automation is deployed in the use case of another customer.

This customer wants to use Ansible to perform some updates on his 30 Linux servers which requires a reboot. This would lead to alarms in PRTG. They can use the ansible module to pause the devices before performing the update and resume them after the updates and the reboot have happened. To do this manually would be quite time-consuming.

Our plan is to continue adding new modules to the ansible collection as they become available in our brand-new Paessler PRTG API v2. Our goal is to offer you a comprehensive collection, enabling you to seamlessly include PRTG in your automation efforts with Ansible. To do so, we need your feedback! 😊

Survey time! Your feedback is priceless

You can find our Paessler PRTG Ansible collection on gitlab.com. There you will also find the necessary PRTG requirements, installation tips and how you can contribute to the collection. 

We would also like to better understand which of your processes you would like to automate, what your use cases are with Ansible or if you use completely different software for automation. You would be doing us a big favor if you participate in ▶️▶️▶️ Process automation and you - a survey ◀️◀️◀️

We are excited about your feedback.

In addition to the survey, we are happy to read your comments on how you already use Ansible with PRTG.

Share your insights below or write us at roadmap@paessler.com

👇