Forge Home

pe_to_mqtt

A Puppet module for setting up a fact terminus and/or report processor for publishing data to an MQTT broker via the MQTT protocol.

536 downloads

65 latest version

3.1 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.3.0 (latest)
  • 0.2.1
  • 0.2.0
  • 0.1.0
released Sep 19th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2021.7.x
  • Puppet >= 7.24.0 < 9.0.0
  • , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'jortencio-pe_to_mqtt', '0.3.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add jortencio-pe_to_mqtt
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install jortencio-pe_to_mqtt --version 0.3.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

jortencio/pe_to_mqtt — version 0.3.0 Sep 19th 2024

pe_to_mqtt

A Puppet module that is used for setting up a fact terminus and/or report processor for publishing fact and/or report data respectively from a Puppet Server to an MQTT broker via the MQTT protocol.

Note: This module has been tested to send data to an EMQX MQTT broker, but should work with other MQTT brokers as well as it is just making using a generic MQTT client.

Table of Contents

  1. Description
  2. Setup - The basics of getting started with pe_to_mqtt
  3. Usage - Configuration options and additional functionality
  4. Limitations
  5. Development - Contributing to the module

Description

This Puppet module can be used to configure a Puppet server to send data to a given MQTT broker via the MQTT protocol.

  • Facts data for nodes will by default be published to the topic puppet/facts
  • Reports for nodes will by default be published to the topic puppet/reports

Setup

What pe_to_mqtt affects

This module will manage/install the mqtt gem on the Puppet server and will configure the following configuration files:

  • puppet.conf file to make use of the fact indirector code (via a custom route_file) and report processor code installed via this module.
  • mqtt_routes.yaml a custom route_file for setting the facts terminus and facts cache terminus
  • pe_mqtt.yaml a configuration file for setting MQTT server details and controlling fact/report data sent to the MQTT broker

Setup Requirements

  • Puppet Server
  • MQTT Broker (Such as EMQX. A Puppet module for configuring EMQX can be found here)

Beginning with pe_to_mqtt

Basic configuration to set up both the facts terminus and report processor to report to a given MQTT broker, classify the Puppet Primary server with the following:

class { 'pe_to_mqtt':
  mqtt_hostname => '<mqtt hostname>',
}

Usage

This module supports the use of Hiera data for setting parameters. The following is a list of parameters configurable in Hiera: (Please refer to REFERENCE.md for more details)

---
pe_to_mqtt::manage_mqtt_gem: true
pe_to_mqtt::configure_report_processor: true
pe_to_mqtt::manage_route_file: true
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883
pe_to_mqtt::disable_report_mqtt: false
pe_to_mqtt::disable_facts_mqtt: false
pe_to_mqtt::report_publish_status: 'all'
pe_to_mqtt::report_mqtt_topic: 'puppet/reports'
pe_to_mqtt::facts_terminus: mqtt
pe_to_mqtt::facts_cache_terminus: json
pe_to_mqtt::facts_mqtt_topic: 'puppet/facts'

Common usage:

Classify a node with pe_to_mqtt:

include pe_to_mqtt

Configure pe_to_mqtt to only configure the fact terminus:

---
pe_to_mqtt::configure_report_processor: false
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883

Configure pe_to_mqtt to only configure the fact terminus:

---
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883
pe_to_mqtt::manage_route_file: false

Configure pe_to_mqtt to only configure the report processor:

---
pe_to_mqtt::configure_report_processor: false
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883

Configure pe_to_mqtt to only send failed reports to MQTT broker:

---
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883
pe_to_mqtt::report_publish_status: 'failed'

Configure pe_to_mqtt to only send reports to a different MQTT topic:

---
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883
pe_to_mqtt::report_mqtt_topic: 'custom_topic/puppet_reports'

Configure pe_to_mqtt to only send select fields of a Puppet report to the MQTT broker (refer to REFERENCE.md for available fields to select or Puppet gem documentation4):

---
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883
pe_to_mqtt::report_selected_fields:
  - host
  - time
  - configuration_version
  - transaction_uuid
  - report_format
  - puppet_version
  - status
  - transaction_completed
  - noop
  - noop_pending
  - environment

Configure pe_to_mqtt to only send select facts to the MQTT Broker:

---
pe_to_mqtt::mqtt_hostname: 'mqtt.example.com'
pe_to_mqtt::mqtt_port: 1883
pe_to_mqtt::facts_selected_facts:
  - os
  - memory
  - puppetversion
  - system_uptime
  - load_averages
  - ipaddress
  - fqdn

Limitations

  • Currently tested on a Puppet Enterprise Installation (PE 2021.7.9/PE 2023.8.0)
  • Only basic configuration is available for MQTT, (e.g. SSL not yet supported).
  • There can be some issues publishing facts/report data that is > 500 KB. This behaviour has been noticed for Puppet Primary Server/Compiler reports where reports published to the MQTT Broker seem to get lost when they are greater than 500 KB on EMQX. This is likely to be due to settings on the MQTT broker regarding max size limits for message payloads.

Development

If you would like to contribute with the development of this module, please feel free to log development changes in the issues register for this project