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: diff --git a/manifests/init.pp b/manifests/init.pp index 3059fb4..7d29a59 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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', @@ -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', @@ -72,4 +89,7 @@ value => 'on', } } + if $pg_hba_conf_defaults == 'false' { + create_resources ('postgresql::server::pg_hba_rule',$pg_hba_custom) + } }