Skip to content

Commit 14c5d82

Browse files
(PE-40379) fix issue on RBAC restore
1 parent dd7f25a commit 14c5d82

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

functions/migration_opts_default.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ function peadm::migration_opts_default () {
77
'config' => false,
88
'orchestrator' => true,
99
'puppetdb' => true,
10-
'rbac' => false,
10+
'rbac' => true,
1111
}
1212
}

plans/migrate.pp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@
7777
})
7878

7979
run_plan('peadm::restore', {
80-
targets => $new_primary_host,
81-
restore_type => 'migration',
82-
input_file => $remote_backup_path,
80+
targets => $new_primary_host,
81+
restore_type => 'migration',
82+
input_file => $remote_backup_path,
83+
console_password => $old_primary_password,
8384
})
8485

8586
$node_types = {

plans/restore.pp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
# Path to the recovery tarball
2121
Pattern[/.*\.tar\.gz$/] $input_file,
22+
23+
# Console password for restored system
24+
Optional[String] $console_password = undef,
2225
) {
2326
peadm::assert_supported_bolt_version()
2427

@@ -194,8 +197,8 @@
194197
# Restore secrets/keys.json if it exists
195198
out::message('# Restoring ldap secret key if it exists')
196199
run_command(@("CMD"/L), $primary_target)
197-
test -f ${shellquote($recovery_directory)}/rbac/keys.json \
198-
&& cp -rp ${shellquote($recovery_directory)}/keys.json /etc/puppetlabs/console-services/conf.d/secrets/ \
200+
test -f ${shellquote($recovery_directory)}/rbac/secrets/keys.json \
201+
&& cp -rp ${shellquote($recovery_directory)}/rbac/secrets/keys.json /etc/puppetlabs/console-services/conf.d/secrets/ \
199202
|| echo secret ldap key doesnt exist
200203
| CMD
201204
# lint:ignore:140chars
@@ -296,6 +299,11 @@
296299
# TODO: consider adding a heuristic to skip when innappropriate due to size
297300
# or other factors.
298301
if getvar('recovery_opts.puppetdb') and $restore_type == 'migration' {
302+
# ensure there is a valid token on the new primary host
303+
run_task('peadm::rbac_token', $primary_target,
304+
password => $console_password,
305+
token_lifetime => '1y',
306+
)
299307
run_command(@("CMD"/L), $primary_target)
300308
/opt/puppetlabs/bin/puppet-db import \
301309
--cert=$(/opt/puppetlabs/bin/puppet config print hostcert) \

0 commit comments

Comments
 (0)