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