From b7776600d37ea0d39b9eaa1dadafb93216d6c777 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Fri, 18 Sep 2015 09:50:45 -0300 Subject: [PATCH 1/5] Increase maximum File Descriptors --- manifests/init.pp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index a994123..a7f829e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -13,6 +13,17 @@ #validate_integer($port) validate_bool(is_ip_address($master_IP_address)) validate_bool(is_ip_address($slave_IP_address)) + + # 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 { class { 'postgresql::server': ipv4acls => ["host replication $user $master_IP_address/32 md5"], From 4e25a54044f99736b9276d703a574ce47eefa810 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Fri, 18 Sep 2015 10:17:00 -0300 Subject: [PATCH 2/5] Added extra_acls parameter --- manifests/init.pp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 6f5c8a9..234381c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,16 +1,14 @@ #init.pp class postgresreplication ( -# $slave = false, $user = 'rep', $master_IP_address, $slave_IP_address, $port = 5432, $password, $trigger_file = undef, + $extra_acls = [], ) { - #validate_bool($slave) - #validate_integer($port) validate_bool(is_ip_address($master_IP_address)) validate_bool(is_ip_address($slave_IP_address)) @@ -25,9 +23,10 @@ } 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, } postgresql::server::recovery { 'postgresrecovery': @@ -55,9 +54,10 @@ } } 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", } file { '/var/lib/postgresql/9.3/main/recovery.conf': ensure => 'absent', From d168485e514e5390f25b3675f58e8c563b222482 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Fri, 18 Sep 2015 10:19:21 -0300 Subject: [PATCH 3/5] Added requirements section in README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4850911..56063e2 100644 --- a/README.md +++ b/README.md @@ -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: From 9a3b7619ad2de8874f2a41a81cdf61da6f8d10ea Mon Sep 17 00:00:00 2001 From: Gabriel R F Date: Mon, 16 Nov 2015 10:05:45 -0200 Subject: [PATCH 4/5] Allow longer queries on standby server. --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 234381c..3b476f6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,8 +49,8 @@ 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 { From 33c12bd4c5e30512226dfceb8caf6f897001776a Mon Sep 17 00:00:00 2001 From: GabrielRF Date: Tue, 17 Nov 2015 11:30:32 -0200 Subject: [PATCH 5/5] pg_hba hash added --- manifests/init.pp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 3b476f6..7d29a59 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,10 +7,14 @@ $password, $trigger_file = undef, $extra_acls = [], + $pg_hba_conf_defaults = true, + $pg_hba_custom = {}, ) { 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' } @@ -28,6 +32,7 @@ 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', @@ -58,6 +63,7 @@ class { 'postgresql::server': 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', @@ -83,4 +89,7 @@ value => 'on', } } + if $pg_hba_conf_defaults == 'false' { + create_resources ('postgresql::server::pg_hba_rule',$pg_hba_custom) + } }