Skip to content

Commit 51b0dc3

Browse files
committed
Set different clientcert values depending on version
The possible values for the clientcert setting changed between 11 and 14, use get_psql_info to determine setting based on version
1 parent 5ad0f65 commit 51b0dc3

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

plans/subplans/db_populate.pp

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
# Retrieve source's PSQL version
2121
$psql_version = run_task('peadm::get_psql_version', $source_target).first.value['version']
2222

23+
# Determine clientcert setting
24+
$clientcert = $psql_version ? {
25+
'14' => 'verify-full',
26+
default => 1
27+
}
28+
2329
# Add the following two lines to /opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_ident.conf
2430
#
2531
# These lines allow connections from destination by pg_basebackup to replicate
@@ -31,11 +37,11 @@
3137
}
3238
file_line { 'replication-pe-ha-replication-ipv4':
3339
path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf",
34-
line => 'hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=1',
40+
line => "hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}",
3541
}
3642
file_line { 'replication-pe-ha-replication-ipv6':
3743
path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf",
38-
line => 'hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=1',
44+
line => "hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}",
3945
}
4046
}
4147

@@ -81,12 +87,12 @@
8187
file_line { 'replication-pe-ha-replication-ipv4':
8288
ensure => absent,
8389
path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf",
84-
line => 'hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=1',
90+
line => "hostssl replication pe-ha-replication 0.0.0.0/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}",
8591
}
8692
file_line { 'replication-pe-ha-replication-ipv6':
8793
ensure => absent,
8894
path => "/opt/puppetlabs/server/data/postgresql/${psql_version}/data/pg_hba.conf",
89-
line => 'hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=1',
95+
line => "hostssl replication pe-ha-replication ::/0 cert map=replication-pe-ha-replication-map clientcert=${clientcert}",
9096
}
9197
}
9298

tasks/get_psql_version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def execute!
2121
Puppet.initialize_settings
2222
task = GetPSQLInfo.new(JSON.parse(STDIN.read))
2323
task.execute!
24-
end
24+
end

0 commit comments

Comments
 (0)