|
17 | 17 | $destination_target, |
18 | 18 | ])) |
19 | 19 |
|
20 | | - # Add the following two lines to /opt/puppetlabs/server/data/postgresql/11/data/pg_ident.conf |
| 20 | + # Retrieve source's PSQL version |
| 21 | + $psql_version = run_task('peadm::get_psql_version', $source_target).first.value['version'] |
| 22 | + |
| 23 | + # Determine clientcert setting |
| 24 | + $clientcert = $psql_version ? { |
| 25 | + '14' => 'verify-full', |
| 26 | + default => 1 |
| 27 | + } |
| 28 | + |
| 29 | + # Add the following two lines to /opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_ident.conf |
21 | 30 | # |
22 | 31 | # These lines allow connections from destination by pg_basebackup to replicate |
23 | 32 | # content |
24 | 33 | apply($source_target) { |
25 | 34 | file_line { 'replication-pe-ha-replication-map': |
26 | | - path => '/opt/puppetlabs/server/data/postgresql/11/data/pg_ident.conf', |
| 35 | + path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_ident.conf", |
27 | 36 | line => "replication-pe-ha-replication-map ${destination_target.peadm::certname()} pe-ha-replication", |
28 | 37 | } |
29 | 38 | file_line { 'replication-pe-ha-replication-ipv4': |
30 | | - path => '/opt/puppetlabs/server/data/postgresql/11/data/pg_hba.conf', |
31 | | - line => 'hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=1', |
| 39 | + path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf", |
| 40 | + line => "hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}", |
32 | 41 | } |
33 | 42 | file_line { 'replication-pe-ha-replication-ipv6': |
34 | | - path => '/opt/puppetlabs/server/data/postgresql/11/data/pg_hba.conf', |
35 | | - line => 'hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=1', |
| 43 | + path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf", |
| 44 | + line => "hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}", |
36 | 45 | } |
37 | 46 | } |
38 | 47 |
|
|
42 | 51 | # Save existing certificates to use for authentication to source. Can not use |
43 | 52 | # certs stored in /etc/puppetlabs/puppet/ssl because we will run pg_basebackup |
44 | 53 | # as pe-postgres user, which lacks access |
45 | | - run_command('mv /opt/puppetlabs/server/data/postgresql/11/data/certs /opt/puppetlabs/server/data/pg_certs', $destination_target) |
| 54 | + run_command("mv /opt/puppetlabs/server/data/postgresql/${psql_version}/data/certs /opt/puppetlabs/server/data/pg_certs", $destination_target) |
46 | 55 |
|
47 | 56 | # pg_basebackup requires an entirely empty data directory |
48 | 57 | run_command('rm -rf /opt/puppetlabs/server/data/postgresql/*', $destination_target) |
49 | 58 |
|
50 | 59 | $pg_basebackup = @("PGBASE") |
51 | 60 | runuser -u pe-postgres -- \ |
52 | 61 | /opt/puppetlabs/server/bin/pg_basebackup \ |
53 | | - -D /opt/puppetlabs/server/data/postgresql/11/data \ |
| 62 | + -D /opt/puppetlabs/server/data/postgresql/${psql_version}/data \ |
54 | 63 | -d "host=${source_host} |
55 | 64 | user=pe-ha-replication |
56 | 65 | sslmode=verify-full |
|
72 | 81 | apply($source_target) { |
73 | 82 | file_line { 'replication-pe-ha-replication-map': |
74 | 83 | ensure => absent, |
75 | | - path => '/opt/puppetlabs/server/data/postgresql/11/data/pg_ident.conf', |
| 84 | + path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_ident.conf", |
76 | 85 | line => "replication-pe-ha-replication-map ${destination_target.peadm::certname()} pe-ha-replication", |
77 | 86 | } |
78 | 87 | file_line { 'replication-pe-ha-replication-ipv4': |
79 | 88 | ensure => absent, |
80 | | - path => '/opt/puppetlabs/server/data/postgresql/11/data/pg_hba.conf', |
81 | | - line => 'hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=1', |
| 89 | + path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf", |
| 90 | + line => "hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}", |
82 | 91 | } |
83 | 92 | file_line { 'replication-pe-ha-replication-ipv6': |
84 | 93 | ensure => absent, |
85 | | - path => '/opt/puppetlabs/server/data/postgresql/11/data/pg_hba.conf', |
86 | | - line => 'hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=1', |
| 94 | + path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf", |
| 95 | + line => "hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}", |
87 | 96 | } |
88 | 97 | } |
89 | 98 |
|
|
0 commit comments