Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Uses Puppetlabs-Postgresql module https://github.com/puppetlabs/puppetlabs-postg

*This module is ready to be used with The Foreman tool http://theforeman.org/*

##Requirements

puppetlabs-Postgresql: https://github.com/puppetlabs/puppetlabs-postgresql
puppetlabs-stdlib: https://github.com/puppetlabs/puppetlabs-stdlib

##Overview

This module works by sending every logged modification on the Master to the Slave, replicating the database immediately. The files modified by the module are:
Expand Down
38 changes: 29 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
#init.pp
class postgresreplication (
# $slave = false,
$user = 'rep',
$master_IP_address,
$slave_IP_address,
$port = 5432,
$password,
$trigger_file = undef,
$extra_acls = [],
$pg_hba_conf_defaults = true,
$pg_hba_custom = {},
)
{
#validate_bool($slave)
#validate_integer($port)
validate_bool(is_ip_address($master_IP_address))
validate_bool(is_ip_address($slave_IP_address))
validate_bool($pg_hba_conf_defaults)
validate_hash($pg_hba_custom)

# Increase sysctl maximum File Descriptors
sysctl { 'fs.file-max': value => '65536' }
# Increase maximum File Descriptors in /etc/security/limits.conf
limits::fragment {
"*/soft/nofile":
value => "65535";
"*/hard/nofile":
value => "65535";
}

if $::ipaddress == $slave_IP_address {
$default_slave_acl = ["host replication $user $master_IP_address/32 md5"]
class { 'postgresql::server':
ipv4acls => ["host replication $user $master_IP_address/32 md5"],
listen_addresses => "localhost,$slave_IP_address",
ipv4acls => concat($default_slave_acl, $extra_acls),
listen_addresses => "localhost,$slave_IP_address",
manage_recovery_conf => true,
pg_hba_conf_defaults => $pg_hba_conf_defaults,
}
postgresql::server::recovery { 'postgresrecovery':
standby_mode => 'on',
Expand All @@ -39,14 +54,16 @@
postgresql::server::config_entry { 'hot_standby':
value => 'on',
}
postgresql::server::config_entry { 'max_wal_segments':
value => '1000',
postgresql::server::config_entry { 'hot_standby_feedback':
value => 'on',
}
}
else {
$default_master_acl = ["host replication $user $slave_IP_address/32 md5"]
class { 'postgresql::server':
ipv4acls => ["host replication $user $slave_IP_address/32 md5"],
listen_addresses => "localhost,$master_IP_address",
ipv4acls => concat($default_master_acl, $extra_acls),
listen_addresses => "localhost,$master_IP_address",
pg_hba_conf_defaults => $pg_hba_conf_defaults,
}
file { '/var/lib/postgresql/9.3/main/recovery.conf':
ensure => 'absent',
Expand All @@ -72,4 +89,7 @@
value => 'on',
}
}
if $pg_hba_conf_defaults == 'false' {
create_resources ('postgresql::server::pg_hba_rule',$pg_hba_custom)
}
}