Forge Home


Module to install and configure repmgr


8,127 latest version

4.3 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.1.7 (latest)
  • 0.1.6 (deleted)
released May 18th 2016
This version is compatible with:
  • Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.0.0 < 5.0.0

Start using this module

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

Add this module to your Puppetfile:

mod 'chrisjohntapp-repmgr', '0.1.7'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add chrisjohntapp-repmgr
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install chrisjohntapp-repmgr --version 0.1.7

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.



chrisjohntapp/repmgr — version 0.1.7 May 18th 2016



Module to install and configure repmgr from repo packages. Repmgr is a tool to aid management of postgresql replication and failover.

This module does not handle failback or automatic recovery of failed nodes.

The module can be used in environments where the puppet agent is constantly running (this is a change from earlier versions).

Module Description

This module installs and configures repmgr from repo packages. It creates a read/write primary and any number of read-only secondaries.

This module sets up the nodes to operate in a specific way. Following a failure of the primary, the highest priority secondary will promote itself to become the new primary, and the lower priority secondary will repoint itself to replicate from the new primary. Should the new primary also fail, the lower priority secondary will promote itself in turn. Should this node also fail, there would be no working servers until puppet is run to reset the cluster.

During a failover the promoted node will attempt to shut down the failed primary in order to avoid split-brain.

To avoid the risk of downtime following a failover, change the value of $primary to the new primary node, drop the repmgr database on the failed primary, and run puppet on it (or wait for the next puppet agent run if you are running the agent constantly). Puppet will then clone the new primary and register the node as a secondary. There is no need to do anything to the other nodes in the cluster, and there will be no loss of service.

This method provides the opportunity to examine a failed primary node, and the ability to reintroduce it as a secondary with only a couple of commands.

Secondaries can be re-cloned from the primary by just stopping the postgresql service and running the puppet agent.

Beginning with Repmgr

This module assumes the following:

  • postgresql is already installed;
  • password-less SSH access between nodes is already working;
  • fencing/stonith commands in are operational;
  • repmgr functions are enabled in postgresql.conf;
  • $repmgr_conf_dir and $repmgr_log_dir directories should already exist and have appropriate permissions.


When initially setting up the nodes, Run puppet on the primary first, then the secondaries.

Make the following class declaration to use defaults:

class { 'repmgr': }

To override the default installed postgresql version:

  class { 'repmgr':
    postgresql_version => '9.4',
    repmgr_conf_dir    => '/etc/postgresql/9.4/main',
    packages           => [ 'postgresql-9.4-repmgr', 'postgresql-server-dev-9.4' ],

To set cluster-wide values:

  class { 'repmgr':
    cluster_name => 'warehouse',
    primary      => '',

To set node-specific values:

  class { 'repmgr':
    node_number   => '2',
    node_name     => 'wh2',
    node_priority => '150',

To change default repmgr database values:

  class { 'repmgr':
    repmgr_db_name      => 'wh_repl',
    repmgr_db_user_name => 'wh_repl_usr',

All configurable settings are visible in params.pp.

Supported Operating Systems

Currently this module only supports Ubuntu 14.04. The intention is to add support for other versions of Ubuntu, Debian, and RHEL, in that order.


This module is very young and in active development.

TODO: Requires automated tests.

TODO: set up event_notifications.