|
143 | 143 | # task for idempotency reasons. When the orchestrator has been upgraded but
|
144 | 144 | # not all pxp-agents have, the built-in service task does not work over pcp.
|
145 | 145 | run_command('systemctl stop puppet', $all_targets)
|
| 146 | + |
| 147 | + # Create a variable for configuring PuppetDB access for all the certnames |
| 148 | + # that are known to need it. |
| 149 | + $profile_database_puppetdb_hosts = { |
| 150 | + 'puppet_enterprise::profile::database::puppetdb_hosts' => ( |
| 151 | + $compiler_targets + $master_target + $master_replica_target |
| 152 | + ).map |$t| { $t.peadm::target_name() }, |
| 153 | + } |
| 154 | + |
| 155 | + # Ensure the pe.conf files on the PostgreSQL node(s) are correct. This file |
| 156 | + # is only ever consulted during install and upgrade of these nodes, but if |
| 157 | + # it contains the wrong values, upgrade will fail. |
| 158 | + peadm::flatten_compact([ |
| 159 | + $puppetdb_database_target, |
| 160 | + $puppetdb_database_replica_target, |
| 161 | + ]).each |$target| { |
| 162 | + $current_pe_conf = run_task('peadm::read_file', $target, |
| 163 | + path => '/etc/puppetlabs/enterprise/conf.d/pe.conf', |
| 164 | + ).first['content'] |
| 165 | + |
| 166 | + $pe_conf = ($current_pe_conf ? { |
| 167 | + undef => {}, |
| 168 | + default => $current_pe_conf.peadm::parsehocon(), |
| 169 | + } + { |
| 170 | + 'console_admin_password' => 'not used', |
| 171 | + 'puppet_enterprise::puppet_master_host' => $master_target.peadm::target_name(), |
| 172 | + 'puppet_enterprise::database_host' => $target.peadm::target_name(), |
| 173 | + } + $profile_database_puppetdb_hosts).to_json_pretty() |
| 174 | + |
| 175 | + write_file($pe_conf, '/etc/puppetlabs/enterprise/conf.d/pe.conf', $target) |
| 176 | + } |
146 | 177 | }
|
147 | 178 |
|
148 | 179 | peadm::plan_step('upgrade-primary') || {
|
|
242 | 273 | $puppetdb_database_replica_target,
|
243 | 274 | ]))
|
244 | 275 |
|
245 |
| - # Upgrade the master replica |
| 276 | + # The `puppetdb delete-reports` CLI app has a bug in 2019.8.0 where it |
| 277 | + # doesn't deal well with the PuppetDB database being on a separate node. |
| 278 | + # So, move it aside before running the upgrade. |
| 279 | + $pdbapps = '/opt/puppetlabs/server/apps/puppetdb/cli/apps' |
| 280 | + $workaround_delete_reports = $arch['high-availability'] and $version =~ SemVerRange('>= 2019.8') |
| 281 | + if $workaround_delete_reports { |
| 282 | + run_command(@("COMMAND"/$), $master_replica_target) |
| 283 | + if [ -e ${pdbapps}/delete-reports -a ! -h ${pdbapps}/delete-reports ] |
| 284 | + then |
| 285 | + mv ${pdbapps}/delete-reports ${pdbapps}/delete-reports.original |
| 286 | + ln -s \$(which true) ${pdbapps}/delete-reports |
| 287 | + fi |
| 288 | + | COMMAND |
| 289 | + } |
| 290 | + |
| 291 | + # Upgrade the master replica. |
246 | 292 | run_task('peadm::puppet_infra_upgrade', $master_target,
|
247 | 293 | type => 'replica',
|
248 | 294 | targets => $master_replica_target.map |$t| { $t.peadm::target_name() },
|
249 | 295 | token_file => $token_file,
|
250 | 296 | )
|
| 297 | + |
| 298 | + # Return the delete-reports CLI app to its original state |
| 299 | + if $workaround_delete_reports { |
| 300 | + run_command(@("COMMAND"/$), $master_replica_target) |
| 301 | + if [ -e ${pdbapps}/delete-reports.original ] |
| 302 | + then |
| 303 | + mv ${pdbapps}/delete-reports.original ${pdbapps}/delete-reports |
| 304 | + fi |
| 305 | + | COMMAND |
| 306 | + } |
251 | 307 | }
|
252 | 308 |
|
253 | 309 | peadm::plan_step('upgrade-replica-compilers') || {
|
|
0 commit comments