|
10 | 10 | # |
11 | 11 | # Sample Usage: |
12 | 12 | # |
13 | | -class postgresql::params { |
| 13 | + |
| 14 | +# TODO: add real docs |
| 15 | + |
| 16 | +# This class allows you to use a newer version of postgres, rather than your |
| 17 | +# system's default version. |
| 18 | +# |
| 19 | +# If you want to do that, note that it is important that you use the '->', |
| 20 | +# or a before/require metaparameter to make sure that the `params` |
| 21 | +# class is evaluated before any of the other classes in the module. |
| 22 | +# |
| 23 | +# Also note that this class includes the ability to automatically manage |
| 24 | +# the yumrepo resource. If you'd prefer to manage the repo yourself, simply pass |
| 25 | +# 'false' or omit the 'manage_repo' parameter--it defaults to 'false'. You will |
| 26 | +# still need to use the 'params' class to specify the postgres version |
| 27 | +# number, though, in order for the other classes to be able to find the |
| 28 | +# correct paths to the postgres dirs. |
| 29 | + |
| 30 | +class postgresql::params( |
| 31 | + $version = $::postgres_default_version, |
| 32 | + $manage_package_repo = false, |
| 33 | + $package_source = undef, |
| 34 | +) { |
14 | 35 | $user = 'postgres' |
15 | 36 | $group = 'postgres' |
16 | 37 | $ip_mask_deny_postgres_user = '0.0.0.0/0' |
|
21 | 42 | # TODO: figure out a way to make this not platform-specific |
22 | 43 | $manage_redhat_firewall = false |
23 | 44 |
|
| 45 | + |
| 46 | + if ($manage_package_repo) { |
| 47 | + case $::osfamily { |
| 48 | + 'RedHat': { |
| 49 | + $rh_pkg_source = pick($package_source, 'yum.postgresql.org') |
| 50 | + |
| 51 | + case $rh_pkg_source { |
| 52 | + 'yum.postgresql.org': { |
| 53 | + class { "postgresql::package_source::yum_postgresql_org": |
| 54 | + version => $version |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + default: { |
| 59 | + fail("Unsupported package source '${rh_pkg_source}' for ${::osfamily} OS family. Currently the only supported source is 'yum.postgresql.org'") |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + default: { |
| 65 | + fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian") |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + |
24 | 71 | # This is a bit hacky, but if the puppet nodes don't have pluginsync enabled, |
25 | 72 | # they will fail with a not-so-helpful error message. Here we are explicitly |
26 | 73 | # verifying that the custom fact exists (which implies that pluginsync is |
|
39 | 86 |
|
40 | 87 | case $::osfamily { |
41 | 88 | 'RedHat': { |
42 | | - $service_name = 'postgresql' |
43 | | - $client_package_name = 'postgresql' |
44 | | - $server_package_name = 'postgresql-server' |
45 | | - $devel_package_name = 'postgresql-devel' |
46 | 89 | $needs_initdb = true |
47 | | - $initdb_path = '/usr/bin/initdb' |
48 | | - $createdb_path = '/usr/bin/createdb' |
49 | | - $psql_path = '/usr/bin/psql' |
50 | | - $datadir = '/var/lib/pgsql/data/' |
51 | | - $pg_hba_conf_path = '/var/lib/pgsql/data/pg_hba.conf' |
52 | | - $postgresql_conf_path = '/var/lib/pgsql/data/postgresql.conf' |
53 | 90 | $firewall_supported = true |
54 | 91 | $persist_firewall_command = '/sbin/iptables-save > /etc/sysconfig/iptables' |
| 92 | + |
| 93 | + if $version == $::postgres_default_version { |
| 94 | + $client_package_name = 'postgresql' |
| 95 | + $server_package_name = 'postgresql-server' |
| 96 | + $devel_package_name = 'postgresql-devel' |
| 97 | + $service_name = 'postgresql' |
| 98 | + $bindir = '/usr/bin' |
| 99 | + $datadir = '/var/lib/pgsql/data' |
| 100 | + $confdir = $datadir |
| 101 | + } else { |
| 102 | + $version_parts = split($version, '[.]') |
| 103 | + $package_version = "${version_parts[0]}${version_parts[1]}" |
| 104 | + $client_package_name = "postgresql${package_version}" |
| 105 | + $server_package_name = "postgresql${package_version}-server" |
| 106 | + $devel_package_name = "postgresql${package_version}-devel" |
| 107 | + $service_name = "postgresql-${version}" |
| 108 | + $bindir = "/usr/pgsql-${version}/bin" |
| 109 | + $datadir = "/var/lib/pgsql/${version}/data" |
| 110 | + $confdir = $datadir |
| 111 | + } |
| 112 | + |
| 113 | + $service_status = undef |
55 | 114 | } |
56 | 115 |
|
57 | 116 | 'Debian': { |
| 117 | + $needs_initdb = false |
| 118 | + $firewall_supported = false |
| 119 | + # TODO: not exactly sure yet what the right thing to do for Debian/Ubuntu is. |
| 120 | + #$persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4' |
| 121 | + |
| 122 | + |
58 | 123 | case $::operatingsystem { |
59 | 124 | 'Debian': { |
60 | | - $service_name = 'postgresql' |
| 125 | + $service_name = 'postgresql' |
61 | 126 | } |
62 | 127 |
|
63 | 128 | 'Ubuntu': { |
|
69 | 134 | } |
70 | 135 | } |
71 | 136 |
|
72 | | - $client_package_name = 'postgresql-client' |
73 | | - $server_package_name = 'postgresql' |
74 | | - $devel_package_name = 'libpq-dev' |
75 | | - $needs_initdb = false |
76 | | - $initdb_path = "/usr/lib/postgresql/${::postgres_default_version}/bin/initdb" |
77 | | - $createdb_path = "/usr/lib/postgresql/${::postgres_default_version}/bin/createdb" |
78 | | - $psql_path = "/usr/lib/postgresql/${::postgres_default_version}/bin/psql" |
79 | | - $datadir = "/var/lib/postgresql/${::postgres_default_version}/main" |
80 | | - $pg_hba_conf_path = "/etc/postgresql/${::postgres_default_version}/main/pg_hba.conf" |
81 | | - $postgresql_conf_path = "/etc/postgresql/${::postgres_default_version}/main/postgresql.conf" |
82 | | - $firewall_supported = false |
83 | | - $service_status = "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+'" |
84 | | - # TODO: not exactly sure yet what the right thing to do for Debian/Ubuntu is. |
85 | | - #$persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4' |
86 | | - |
| 137 | + $client_package_name = 'postgresql-client' |
| 138 | + $server_package_name = 'postgresql' |
| 139 | + $devel_package_name = 'libpq-dev' |
| 140 | + $bindir = "/usr/lib/postgresql/${::postgres_default_version}/bin" |
| 141 | + $datadir = "/var/lib/postgresql/${::postgres_default_version}/main" |
| 142 | + $confdir = "/etc/postgresql/${::postgres_default_version}/main" |
| 143 | + $service_status = "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+'" |
87 | 144 | } |
88 | 145 |
|
89 | | - |
90 | 146 | default: { |
91 | 147 | fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian") |
92 | 148 | } |
93 | 149 | } |
94 | 150 |
|
| 151 | + $initdb_path = "${bindir}/initdb" |
| 152 | + $createdb_path = "${bindir}/createdb" |
| 153 | + $psql_path = "${bindir}/psql" |
| 154 | + $pg_hba_conf_path = "${confdir}/pg_hba.conf" |
| 155 | + $postgresql_conf_path = "${confdir}/postgresql.conf" |
95 | 156 | } |
0 commit comments