TIG, you're it!

Tutorial: How to quickly deploy a TIG stack using Puppet Bolt

Nick Lewis
© Shutterstock / Rafael Tenorio Aranguren

Nick Lewis, Senior Software Engineer for Puppet teaches us how to deploy a TIG stack – that’s a stack with Telegraf, InfluxDB, and Grafana – using Bolt. Bolt is an automation tool that can run scripts in almost any language thanks to the plugins provided at the Puppet Forge. Let’s get stuck in!

One key to maintaining reliable systems is having a reliable monitoring setup. A common set of software used for monitoring is the TIG stack: Telegraf, InfluxDB, and Grafana. Telegraf collects, processes, and aggregates system metrics such as CPU usage, Disk IO, and network throughput. InfluxDB stores that data in a way that has fast read/writes with scaling built-in. Grafana allows you to visualise the data in simple, flexible, and granular dashboards. Learning, installing, and configuring these components involves time, coordinating multiple steps, and understanding how they all fit together. Luckily, there’s Bolt.

Bolt is an open source project built by Puppet. It’s an agentless orchestration tool that helps you quickly spin up new software stacks and automate changes across infrastructure. Bolt is great at orchestrating multi-step, multi-node processes, like setting up a monitoring service and its clients. There’s a robust ecosystem around Bolt hosted on Puppet’s Forge that has hundreds of pre-written modules to automate software like Telegraf, InfluxDB, and Grafana. In the example below, we’ll use Bolt to deploy telegraf agents to a set of nodes, configure those agents to send data to InfluxDB, and visualise the data with Grafana, all with preexisting content from the Forge.

This provides a good foundation to start collecting more metrics for monitoring purposes and shows how to use Bolt to model configuration in code and orchestrate deployments.



Step 1 – Install Bolt

Bolt is packaged for Windows, macOS and most common Linux distributions. Check out the installation instructions for your platform.

Step 2 – Clone the demo

The content for this project is available on GitHub. You can clone that repo to follow along.

Step 3 – Download dependencies from the Forge

This project contains a Puppetfile, which lists the modules used by the project. It includes modules from the Puppet Forge to install Telegraf, InfluxDB and Grafana, as well as the stdlib module, which is a dependency.

First, tell Bolt to install those dependencies.

bolt puppetfile install

One of the modules used by this exercise requires a Ruby gem to be installed alongside Bolt.

/opt/puppetlabs/bolt/bin/gem install toml-rb

Step 4 – Write Puppet code to configure each piece

The modules we installed from the Forge are generic and can be used to manage the software in many ways. Our project defines a couple of Puppet classes that use those modules to setup the telegraf agent, InfluxDB and Grafana services the way we want them.

For example, the tig::telegraf class in site/tig/manifests/telegraf installs telegraf, configures it to send its data to our InfluxDB server, and sets up some specific data inputs.


SEE ALSO:GraalVM: Run programs faster everywhere

Step 5 – Orchestrate deployment with a Bolt plan

Each of these classes can manage the configuration of a single server, but to orchestrate the entire deployment we need a Bolt plan.

The plan in site/tig/plans/init.pp accepts a dashboard server and a list of agent nodes, then uses our Puppet classes to install InfluxDB and Grafana on the dashboard server and the Telegraf agent on the agent nodes. It does these steps in order, first setting up the InfluxDB and Grafana server so we have somewhere to send data, and then setting up the Telegraf agents.

plan tig(
  TargetSpec $dashboard,
  TargetSpec $agents
) {

This code defines the plan named tig and specifies that it accepts two arguments: dashboard and agents, each of which is a list of targets.

[$dashboard, $agents].apply_prep

The plan first calls the apply_prep function on the provided targets. This installs the necessary Puppet packages to be able to apply Puppet code on the targets. It also uses Facter to gather some system information required by the Puppet modules.

  apply($dashboard) {
    include tig::dashboard

  $dashboard_host = $dashboard.get_targets[0].name

  apply($agents) {
    class{ tig::telegraf:
      influx_host => $dashboard_host

These lines do the bulk of the work, applying snippets of Puppet code first on the dashboard host and then on the agents. Between those steps, we get the hostname of the dashboard to pass to the agents.

  return('grafana_dashboard' => "http://${dashboard_host}:8080")

Finally, the plan returns a result containing the URL of the Grafana dashboard.

Step 5 – Run the Bolt plan

You can run this plan with Bolt against some target nodes to see it in action.

bolt plan run tig,

bolt tutorial 1

Bolt will output some information about the steps it’s taking and will end with the result of the plan, which has the URL of the Grafana dashboard.

Step 6 – Behold the Grafana

You can follow the link from the Bolt output to see the Grafana dashboard running.

bolt tutorial 2

We can see that Telegraf has already started collecting a wealth of useful information about our systems, including CPU and memory usage, disk usage and performance, running processes, and network statistics.

By mixing and matching prebuilt content from the Puppet Forge, we were able to spin up this functioning TIG stack with ~100 lines of code and immediately see results. The Puppet classes we wrote can be used with the Puppet agent to manage these systems over time, and the Bolt plan can be reused to rebuild the stack or integrated with other plans to manage more complex deployments.

Nick Lewis
Nick Lewis is a software developer at Puppet, where he’s spent the past decade building tools to ease the lives of systems administrators and developers. He now works on Puppet Bolt, bringing task-based automation to the masses.

Inline Feedbacks
View all comments