5abb8855e2db8b3611d3f76c3523b3e18c274667
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / manifests / pg_hba_rule.pp
1 # This resource manages an individual rule that applies to the file defined in
2 # $target.
3 define postgresql::pg_hba_rule(
4   $type,
5   $database,
6   $user,
7   $auth_method,
8   $address = undef,
9   $description = 'none',
10   $auth_option = undef,
11   $target = $postgresql::params::pg_hba_conf_path,
12   $order = '150'
13 ) {
14   include postgresql::params
15
16   validate_re($type, '^(local|host|hostssl|hostnossl)$',
17     "The type you specified [${type}] must be one of: local, host, hostssl, hostnosssl")
18   validate_re($auth_method, '^(trust|reject|md5|crypt|password|gss|sspi|krb5|ident|peer|ldap|radius|cert|pam)$',
19     "The auth_method you specified [${auth_method}] must be one of: trust, reject, md5, crypt, password, krb5, ident, ldap, pam")
20
21   if($type =~ /^host/ and $address == undef) {
22     fail('You must specify an address property when type is host based')
23   }
24
25   # This is required to make sure concat::setup is initialized first. This
26   # probably points to a bug inside ripienaar-concat.
27   include concat::setup
28
29   # Create a rule fragment
30   $fragname = "pg_hba_rule_${name}"
31   concat::fragment { $fragname:
32     target  => $target,
33     content => template('postgresql/pg_hba_rule.conf'),
34     order   => $order,
35     owner   => $::id,
36     mode    => '0600',
37   }
38
39   Class['concat::setup']->
40     Concat::Fragment[$fragname]
41 }