LogicMonitor seeks to disrupt AI landscape with $800M strategic investment at $2.4B valuation to revolutionize data centers.

Learn More

Puppet 4 Integration

Last updated on 02 August, 2022

Puppet is IT automation software that enables system administrators to manage provisioning and configuration of their infrastructure.  We know that in addition to maintaining correct infrastructure configuration, system administrators additionally rely on monitoring to help prevent outages.  Our Puppet module was created with this in mind, and allows your Puppet infrastructure code to manage your LogicMonitor account as well.  This enables you to confirm that correct device properties are maintained, that devices are monitored by the correct Collector, that they remain in the right device groups and much more.

Note:

  • This module is compatible with Puppet versions 3 and 4, and is a different (newer) version of our original module
  • This module is only compatible with linux servers. Windows compatibility may be added in future releases.
  • This module requires PuppetDB

Module Overview

LogicMonitor’s Puppet module defines 4 classes and 4 custom resource types:

Classes

  • logicmonitor: Handles setting the credentials needed to interact with the LogicMonitor API
  • logicmonitor::master: Collects the exported lm_device resources and lm_devicegroup resources. Communicates with the LogicMonitor API
  • logicmonitor::collector: Handles LogicMonitor collector management for the device. Declares an instance of lm_collector and lm_installer resources
  • logicmonitor::device: Declares an exported lm_device resource
  • logicmonitor::device_group: Declares an exported lm_device_group resource

Resource Type

  • lm_device_group: Defines the behavior of the handling of LogicMonitor device groups. We recommend using exported resources
  • lm_device: Defines the handling behavior of LogicMonitor collectors. Used only with the logicmonitor::collector class
  • lm_collector: Defines the handling behavior of LogicMonitor collectors. Used only with the logicmonitor::collector class
  • lm_installer: Defines the handling behavior of LogicMonitor collector binary installers. Used only within the logicmonitor::collector class

Requirements

To use LogicMonitor’s Puppet Module, you need the following:

  1. Ruby 1.8.7 or 1.9.3
  2. Puppet 3.X or Puppet 4.x
  3. JSON Ruby gem (included by default in Ruby 1.9.3)
  4. Store Configs in Puppet
  5. Device Configuration

Store Configs

To enable store configs, add storeconfigs = true to the [master] section of your puppet.conf file, like so:

# /etc/puppet/puppet.conf
[master]
storeconfigs = true

Once enabled, PuppetDB is needed to store the config info.

Device Configuration

As with your other LogicMonitor devices, the collector will need to communicate with the device in order to gather data. Make sure the correct properties and authentication protocols are configured as part of the Puppet installation.

Installing the LogicMonitor Puppet Module

You can install LogicMonitor’s Puppet Module one of two ways:

  1. Using Puppet’s Module Tool
  2. Using GitHub

Using Puppet’s Module Tool

Run the following command on your Puppet Master to download and install the most recent version of the LogicMonitor Puppet Module published on Puppet Forge:

$ puppet module install logicmonitor-logicmonitor

Using GitHub

$ cd /etc/puppet/modules
$ git clone git: //github.com/logicmonitor/logicmonitor-puppetv4.git
$ mv logicmonitor-puppet-v4 logicmonitor

Getting Started

Once you’ve installed LogicMonitor’s Puppet Module, you can get started using the following sections:

Create a New User for Puppet

We recommend you create a new user with administrator privileges in your LogicMonitor account that you will use exclusively within your Puppet nodes to track changes made by Puppet in the audit log. You will need to provision this user API Tokens.

Configuration

  • Class: logicmonitor (modules/logicmonitor/manifests/init.pp)

This is the top level class for the LogicMonitor module; it only needs to be defined on the Puppet Master. Its purpose is to set the LogicMonitor credentials to be used by all the child classes.

ParameterDescriptionInputs
accountYour LogicMonitor account name. e.g. if you log into https://mycompany.logicmonitor.com your account should be “mycompany”String
access_idThe API access id of a LogicMonitor user with access to manage device, groups, and collectors. Actions taken by Puppet show up in the audit log associated with this API access id. We recommend creating a dedicated user for your Puppet account.String
access_keyThe API access key associated with the LogicMonitor user Puppet will be making changes on behalf of.String
  • class: logicmonitor::master (modules/logicmonitor/manifests/master.pp)

The master class enables communication between the LogicMonitor module and your LogicMonitor account for group and device management. This class acts as the collector for the lm_device and lm_devicegroup exported resources. This prevents conflicts and provides a single point of contact for communicating with the LogicMonitor API. This class must be explicitly declared on a single device.

Note: All devices with the logicmonitor::collector and logicmonitor::master classes will need to be able to make outgoing https requests.

Parameters: none

  • Class: logicmonitor::collector (modules/logicmonitor/manifests/collector.pp)

This class manages the creation, download, and installation of a LogicMonitor collector on the specified node.

  • The only absolute requirement for a collector node is that it is Linux and can make an outgoing SSL connection over port 443
  • We suggest the collector system have at least 1G of RAM
  • If the collector will be collecting data for more than 100 devices, it is a good idea to dedicate a machine to it
ParameterDescriptionInputs
install_dirThe path to install the LogicMonitor collector.A valid directory path. Default to “/usr/local/logicmonitor”
  • Class: logicmonitor::device (modules/logicmonitor/manifests/device.pp)

This class is used to add devices to your LogicMonitor account. Devices which are managed through Puppet will have any properties not specified in the device definition removed.

ParameterDescriptionInputs
collectorThe fully qualified domain name of the collector machine. You can find this by running hostname -f on the collector machine.String. No Default (required)
hostnameThe IP address or fully qualified domain name of the node. This is the way that the collector reaches this device.String. Default to $fqdn
display_nameThe human readable name to display in your LogicMonitor account. e.g. “dev2.den1”String. Default to $fqdn
descriptionThe long text description of the host. This is seen when hovering over the device in your LogicMonitor account.String. No Default (Optional)
disable_alertingTurn on or off alerting for the device. If a parent group is set to disable_alerting = true alerts for child devices will be turned off as well.Boolean, Default to false
groupsA list of groups that the device should be a member of. Each group is a String representing its full path. E.g. “/linux/production”List. No Default (Optional)
propertiesA hash of properties to be set on the device. Each entry should be “propertyName” => “propetyValue”. E.g. {“mysql.port” => 6789, “mysql.user” => “dba1”}Hash. No Default (Optional)
class {'logicmonitor:: device':
collector => "qa1.domain.com",
hostname => "10.171.117.9",
groups => ["/Puppetlabs", "/Puppetlabs/Puppetdb"],
properties => {"snmp.community" => "Puppetlabs"}.
description => "This device hosts the PuppetDB instance for this deployment",
}
class {'logicmonitor::device':
collector => $fqdn,
display_name => "MySQL Production Host 1",
groups => ["/Puppet", "/production", "/mysql"],
properties => {"mysql.port" => 1234},
}

Adding a Device Group:

Type: lm_device_group Device groups should be added using an exported resource to prevent conflicts. It is recommended device groups are added from the same node where the logicmonitor::master class is included. Devices can be included in zero, one, or many device groups. Device groups are used to organize how your Logic Monitor Devices are displayed and managed and d not require a collector. Properties set at the device group level will be inherited by any devices added to the group.

ParameterDescriptionInputs
full_pathThe full path of the host group. E.g. a device group “bar” with parent group “foo” would have the full_path of “/foo/bar”String (required)
ensurePuppet ensure parameter.Present/absent. No Default (required)
disable_alertingTurn on/off alerting for the group. If desirable_alerting is true, all child groups and devices will have alerting disabledBoolean. Default to True.
propertiesA hash of properties to be set on the device group. Each entry should be “propertyName” => “propertyValue”. E.g. {“mysql.user” => “dba1”}. The properties will be inherited by all child groups and hostsHash, No Default (optional)
descriptionThe long text description of the device group. This is seen when hovering over the group in your LogicMonitor account.String. No Default (optional)

Examples

To add collector to a node:

include logicmonitor::collector

If you want to specify a specific location where you’d like to install a collector:

class{"logicmonitor::collector":
install_dir => $install_dir,
}

To add and edit properties of device groups use lm_devicegroup, example below.

@@lm_device_group{"/parent/child/grandchild/greatgrandchild":
ensure => present,
disable_alerting => false,
properties => {"snmp.community" => "n3wc0mm", "mysql.port" => 9999, "fake.pass" => "12345"}, description => "This is the description",
}

For more examples of the module in action, check out logicmonitor-puppet-v4/README.md.

In This Article