Skip to content

Commit

Permalink
setup postgresql master config file
Browse files Browse the repository at this point in the history
  • Loading branch information
abessifi committed Jul 4, 2014
1 parent 03daba5 commit cbee07b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 71 deletions.
34 changes: 25 additions & 9 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
class repmgr::config {
class repmgr::config (

Account['repmgr'] -> Repmgr::Config_params['repmgr_config_file']
$cluster_name = undef,
$node_id = undef,
$node_name = undef,
$conninfo_host = undef,
){
$conninfo_user = 'repmgr'
$conninfo_dbname = 'repmgr'
$pg_bindir = '/usr/lib/postgresql/9.1/bin'
$master_response_timeout = 20
$reconnect_attempts = 4
$reconnect_interval = 10
$failover = 'automatic'
$promote_command = 'repmgr -f /etc/repmgr/repmgr.conf standby promote'
$follow_command = '/var/lib/postgresql/follow_command.sh'
$loglevel = 'debug'

Account['repmgr'] -> File['repmgr_config_file']

# Create repmgr config dir
file {'/etc/repmgr':
Expand All @@ -11,13 +27,13 @@
}

# Generate repmgr config file
repmgr::config_params {'repmgr_config_file':
cluster_name => 'collections',
node_id => 1,
node_name => 'node1',
conninfo_host => 'node1',
conninfo_user => 'repmgr',
conninfo_dbname =>'repmgr',
file {'repmgr_config_file':
ensure => present,
owner => repmgr,
group => repmgr,
mode => '0644',
content => template('repmgr/repmgr.conf.erb'),
path => '/etc/repmgr/repmgr.conf',
}

# Create repmgr user
Expand Down
26 changes: 0 additions & 26 deletions manifests/config_params.pp

This file was deleted.

58 changes: 28 additions & 30 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,38 @@
#

define repmgr(

$cluster = $title,
$cluster_subnet = undef,
$master = undef,
$slave = undef,
$witness = undef,
$name = undef,
$ensure = present,
$ensure = 'present',
$role = undef,
$name = $title,
$id = undef,
$cluster = undef,
$subnet = undef,

){

unless $cluster {

fail("Cluster name not specified !")
}
){

if $master == true {

$pg_cluster_subnet = '192.168.1.0/24'
case $role {

include repmgr::install
include repmgr::config
}
else {
fail("Master node not specified !")
}
'master' : {

}
/*
class repmgr {
if $cluster == undef {
fail("Cluster name not specified !")
}

# Continue with other tests

$pg_cluster_subnet = '192.168.1.0/24'
class { 'repmgr::install':
node_role => $role,
pg_cluster_subnet => $subnet,
}

class { 'repmgr::config':
cluster_name => $cluster,
node_id => $id,
node_name => $name,
conninfo_host => $name,
}
}
default : { fail("Invalid value given for role : $role. Must be one of master|slave|witness") }
}

include repmgr::install
include repmgr::config
}
*/
24 changes: 21 additions & 3 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
class repmgr::install {

class repmgr::install(

$node_role = undef,
$pg_cluster_subnet = undef,
){

# repmgr depends on some postgresql packages
require repmgr::postgresql
include repmgr::postgresql

$pg_configdir = '/etc/postgresql/9.1/main'

# Apply the correct postgresql config file (master|slave)
if $node_role == 'master' {
exec {'set_pg_master_config':
path => ['/bin'],
command => "cp -p $pg_configdir/postgresql.conf.master $pg_configdir/postgresql.conf",
notify => Service['postgresql'],
}
}
elsif $node_role in ['slave', 'witness'] {
## Not yet implemented !
}

# repmgr needs rsync also
package {'rsync':
Expand Down
5 changes: 2 additions & 3 deletions manifests/postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@
content => template('repmgr/pg_hba.conf.erb'),
notify => Service['postgresql-reload'],
}

# Set postgresql master config file
/*
exec {'set_pg_master_config':
path => ['/bin'],
command => "cp -p $pg_configdir/postgresql.conf.master $pg_configdir/postgresql.conf",
notify => Service['postgresql'],
}

*/
service {'postgresql':
ensure => running,
status => "sudo -u postgres $pg_ctl -D $pg_data status",
Expand Down

0 comments on commit cbee07b

Please sign in to comment.