Forge Home

puppetdb_gc

A Module for managing PuppetDB (PostgreSQL data) Garbage Collection

4,024 downloads

1,790 latest version

5.0 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

  • 1.1.0 (latest)
  • 1.0.1
  • 1.0.0
released Dec 4th 2020
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, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x
  • Puppet >= 5.5.0
  • , , , , ,
This module has been deprecated by its author since Jul 28th 2022.

Start using this module

Documentation

puppetlabs/puppetdb_gc — version 1.1.0 Dec 4th 2020

Table of Contents

Overview

This module provides PuppetDB garbage collection of PostgreSQL data via cron.

Usage

Disable the internal garbage collection performed by the PuppetDB service via gc-interval on all of your PuppetDB nodes. In PE, do that by setting the following in Hiera.

---
puppet_enterprise::profile::puppetdb::gc_interval: 0

Classify the node running PuppetDB with the puppetdb_gc class. That node is the Primary Master in a Monolithic installation, or the PE PuppetDB host in a Split install.

include puppetdb_gc

Note: If you setup PE HA, you should include puppetdb_gc on both the Primary Master and the Replica. This is because PuppetDB Sync does not sync deletions, so garbage collection needs to be performed on both the Primary Master and the Replica.

What you get

puppet apply -e "include puppetdb_gc"

Notice: Compiled catalog for c02n54lfg3qd in environment production in 0.21 seconds
Notice: /Stage[main]/puppetdb_gc/puppetdb_gc::Gc_cron[expire_nodes]/Cron[puppet_db_gc_expire_nodes]/ensure: created
Notice: /Stage[main]/puppetdb_gc/puppetdb_gc::Gc_cron[purge_nodes]/Cron[puppet_db_gc_purge_nodes]/ensure: created
Notice: /Stage[main]/puppetdb_gc/puppetdb_gc::Gc_cron[purge_reports]/Cron[puppet_db_gc_purge_reports]/ensure: created
Notice: /Stage[main]/puppetdb_gc/puppetdb_gc::Gc_cron[other]/Cron[puppet_db_gc_other]/ensure: created
Notice: Applied catalog in 0.10 seconds
crontab -l -u root

# Puppet Name: puppet_db_gc_expire_nodes
1 * * * * curl -X POST http://127.0.0.1:8080/pdb/admin/v1/cmd -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"command": "clean", "version": 1, "payload": ["expire_nodes"] }'
# Puppet Name: puppet_db_gc_purge_nodes
5 * * * * curl -X POST http://127.0.0.1:8080/pdb/admin/v1/cmd -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"command": "clean", "version": 1, "payload": ["purge_nodes"] }'
# Puppet Name: puppet_db_gc_purge_reports
15,45 * * * * curl -X POST http://127.0.0.1:8080/pdb/admin/v1/cmd -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"command": "clean", "version": 1, "payload": ["purge_reports"] }'
# Puppet Name: puppet_db_gc_other
55 0 20 * * curl -X POST http://127.0.0.1:8080/pdb/admin/v1/cmd -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"command": "clean", "version": 1, "payload": ["other"] }'

Reference

The standard usage of this module is to include the main class which will add all of the GC cron tab entries with the default schedules.

include puppetdb_gc

Additional parameters exist to configure how the module interacts with PuppetDB as well as individual job configuration.

puppetdb_gc_cron_ensure Ensure the presence of the GC cron tab entries. Allows for absent and present. Defaults to present

expire_nodes_cron Configuration settings for the expire_nodes cron tab entry. Allows for a hash of parameters for puppetdb_gc::gc_cron. Defaults to { cron_minute => 3 }

purge_nodes_cron Configuration settings for the purge_nodes cron tab entry. Allows for a hash of parameters for puppetdb_gc::gc_cron. Defaults to { cron_minute => 5 }

purge_reports_cron Configuration settings for the purge_reports cron tab entry. Allows for a hash of parameters for puppetdb_gc::gc_cron. Defaults to {cron_minute => 55,vacuum_reports => false}

other_cron Configuration settings for the other cron tab entry. Allows for a hash of parameters for puppetdb_gc::gc_cron. Defaults to {cron_minute => 55,cron_hour => 0,cron_day => absent}

gc_packages_cron Configuration settings for the gc_packages cron tab entry. Allows for a hash of parameters for puppetdb_gc::gc_cron. Defaults to {cron_minute => 50,cron_hour => 0,cron_day => absent}

PuppetDB GC Interval

https://puppet.com/docs/puppetdb/latest/configure.html#gc-interval

PuppetDB GC Admin API Documentation

https://docs.puppet.com/puppetdb/latest/api/admin/v1/cmd.html#post-pdbadminv1cmd