Skip to content

Instantly share code, notes, and snippets.

@turingmachine
Created December 9, 2009 13:33
Show Gist options
  • Save turingmachine/252471 to your computer and use it in GitHub Desktop.
Save turingmachine/252471 to your computer and use it in GitHub Desktop.
class disks::dbserver_domu::pgsql {
# write ahead log (WAL)
file{'/srv/db_rw_log/pgsql':
ensure => directory,
require => Mount['/srv/db_rw_log'],
owner => postgres, group => postgres, mode => 0700;
}
file{'/var/lib/pgsql':
ensure => directory,
owner => postgres, group => postgres, mode => 0700;
}
mount{'/var/lib/pgsql':
atboot => true,
ensure => mounted,
fstype => none,
options => 'bind',
device => '/srv/db_rw_log/pgsql',
before => Package['postgresql-server'],
require => [
File['/srv/db_rw_log/pgsql'],
File['/var/lib/pgsql'],
],
}
# tablespace
file{'/srv/db_tablespace/pgsql':
ensure => directory,
require => [
Mount['/srv/db_tablespace'],
Package['postgresql-server'],
]
notify => Exec['init_pgsql'],
owner => postgres, group => postgres, mode => 0700;
}
mount{'/var/lib/pgsql/data/base':
atboot => true,
ensure => mounted,
fstype => none,
options => 'bind',
device => '/srv/db_tablespace/pgsql',
before => Service['postgresql'],
require => [
Exec['init_pgsql'],
Exec['move_pgsql_tablespace_onto_bindmount'],
File['/srv/db_rw_log/pgsql/base'],
Mount['/var/lib/pgsql'],
],
}
exec{'init_pgsql':
refreshonly => true,
command => '/etc/init.d/postgres start; /etc/init.d/postgres stop',
require => Package['postgresql-server'],
notify => Exec['move_pgsql_files_onto_bindmount'],
}
exec{'move_pgsql_tablespace_onto_bindmount':
refreshonly => true,
command => '/bin/mv /var/lib/pgsql/data/base/* /srv/db_tablespace/pgsql',
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment