|
5 | 5 | Optional[Boolean] $remove_pdb = true, |
6 | 6 | ) { |
7 | 7 | $primary_target = peadm::get_targets($primary_host, 1) |
8 | | - $legacy_compiler_targets = peadm::get_targets($legacy_hosts) |
| 8 | + $convert_legacy_compiler_targets = peadm::get_targets($legacy_hosts) |
9 | 9 |
|
10 | 10 | $cluster = run_task('peadm::get_peadm_config', $primary_host).first.value |
11 | 11 | $error = getvar('cluster.error') |
12 | 12 | if $error { |
13 | 13 | fail_plan($error) |
14 | 14 | } |
15 | 15 |
|
| 16 | + $replica_host = getvar('cluster.params.replica_host') |
| 17 | + $primary_postgresql_host = getvar('cluster.params.primary_postgresql_host') |
| 18 | + $replica_postgresql_host = getvar('cluster.params.replica_postgresql_host') |
| 19 | + $compiler_hosts = getvar('cluster.params.compiler_hosts') |
| 20 | + $legacy_compilers = getvar('cluster.params.legacy_hosts') |
| 21 | + |
| 22 | + $replica_target = peadm::get_targets($replica_host, 1) |
| 23 | + $primary_postgresql_target = peadm::get_targets($primary_postgresql_host, 1) |
| 24 | + $replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1) |
| 25 | + $compiler_targets = peadm::get_targets($compiler_hosts) |
| 26 | + $legacy_targets = peadm::get_targets($legacy_compilers) + $convert_legacy_compiler_targets |
| 27 | + |
16 | 28 | $all_targets = peadm::flatten_compact([ |
17 | | - getvar('cluster.params.primary_host'), |
18 | | - getvar('cluster.params.replica_host'), |
19 | | - getvar('cluster.params.primary_postgresql_host'), |
20 | | - getvar('cluster.params.replica_postgresql_host'), |
21 | | - getvar('cluster.params.compiler_hosts'), |
| 29 | + $primary_target, |
| 30 | + $replica_target, |
| 31 | + $primary_postgresql_target, |
| 32 | + $replica_postgresql_target, |
| 33 | + $compiler_targets, |
| 34 | + $legacy_targets, |
22 | 35 | ]) |
23 | 36 |
|
24 | 37 | # Ensure input valid for a supported architecture |
25 | 38 | $arch = peadm::assert_supported_architecture( |
26 | | - getvar('cluster.params.primary_host'), |
27 | | - getvar('cluster.params.replica_host'), |
28 | | - getvar('cluster.params.primary_postgresql_host'), |
29 | | - getvar('cluster.params.replica_postgresql_host'), |
30 | | - getvar('cluster.params.compiler_hosts'), |
| 39 | + $primary_host, |
| 40 | + $replica_host, |
| 41 | + $primary_postgresql_host, |
| 42 | + $replica_postgresql_host, |
| 43 | + $compiler_hosts, |
| 44 | + $legacy_compilers, |
31 | 45 | ) |
32 | 46 |
|
33 | 47 | if $arch['disaster-recovery'] { |
34 | 48 | # Gather certificate extension information from all systems |
35 | 49 | $cert_extensions = run_task('peadm::cert_data', $all_targets).reduce({}) |$memo,$result| { |
36 | 50 | $memo + { $result.target.peadm::certname => $result['extensions'] } |
37 | 51 | } |
38 | | - $legacy_compiler_a_targets = $legacy_compiler_targets.filter |$index,$target| { |
| 52 | + $legacy_compiler_a_targets = $convert_legacy_compiler_targets.filter |$index,$target| { |
39 | 53 | $exts = $cert_extensions[$target.peadm::certname()] |
40 | 54 | if ($exts[peadm::oid('peadm_availability_group')] in ['A', 'B']) { |
41 | 55 | $exts[peadm::oid('peadm_availability_group')] == 'A' |
|
47 | 61 | $index % 2 == 0 |
48 | 62 | } |
49 | 63 | } |
50 | | - $legacy_compiler_b_targets = $legacy_compiler_targets.filter |$index,$target| { |
| 64 | + $legacy_compiler_b_targets = $convert_legacy_compiler_targets.filter |$index,$target| { |
51 | 65 | $exts = $cert_extensions[$target.peadm::certname()] |
52 | 66 | if ($exts[peadm::oid('peadm_availability_group')] in ['A', 'B']) { |
53 | 67 | $exts[peadm::oid('peadm_availability_group')] == 'B' |
|
60 | 74 | } |
61 | 75 | } |
62 | 76 | } else { |
63 | | - $legacy_compiler_a_targets = $legacy_compiler_targets |
| 77 | + $legacy_compiler_a_targets = $convert_legacy_compiler_targets |
64 | 78 | $legacy_compiler_b_targets = [] |
65 | 79 | } |
66 | 80 |
|
67 | | - $compiler_targets = peadm::get_targets(getvar('cluster.params.compiler_hosts')) |
68 | | - |
69 | 81 | wait([ |
70 | 82 | background('modify-compilers-certs') || { |
71 | 83 | run_plan('peadm::modify_certificate', $compiler_targets, |
|
98 | 110 | ]) |
99 | 111 |
|
100 | 112 | if $remove_pdb { |
101 | | - run_command('puppet resource service puppet ensure=stopped', $legacy_compiler_targets) |
102 | | - run_command('puppet resource service pe-puppetdb ensure=stopped enable=false', $legacy_compiler_targets) |
| 113 | + run_command('puppet resource service puppet ensure=stopped', $convert_legacy_compiler_targets) |
| 114 | + run_command('puppet resource service pe-puppetdb ensure=stopped enable=false', $convert_legacy_compiler_targets) |
103 | 115 | } |
104 | 116 |
|
105 | 117 | apply($primary_target) { |
|
121 | 133 | } |
122 | 134 | } |
123 | 135 |
|
124 | | - run_task('peadm::puppet_runonce', $legacy_compiler_targets) |
| 136 | + run_task('peadm::puppet_runonce', $convert_legacy_compiler_targets) |
125 | 137 | run_task('peadm::puppet_runonce', $compiler_targets) |
126 | 138 | run_task('peadm::puppet_runonce', $primary_target) |
127 | 139 | run_task('peadm::puppet_runonce', $all_targets) |
128 | 140 |
|
129 | 141 | if $remove_pdb { |
130 | | - run_command('puppet resource package pe-puppetdb ensure=purged', $legacy_compiler_targets) |
131 | | - run_command('puppet resource user pe-puppetdb ensure=absent', $legacy_compiler_targets) |
| 142 | + run_command('puppet resource package pe-puppetdb ensure=purged', $convert_legacy_compiler_targets) |
| 143 | + run_command('puppet resource user pe-puppetdb ensure=absent', $convert_legacy_compiler_targets) |
132 | 144 |
|
133 | | - run_command('rm -rf /etc/puppetlabs/puppetdb', $legacy_compiler_targets) |
134 | | - run_command('rm -rf /var/log/puppetlabs/puppetdb', $legacy_compiler_targets) |
135 | | - run_command('rm -rf /opt/puppetlabs/server/data/puppetdb', $legacy_compiler_targets) |
| 145 | + run_command('rm -rf /etc/puppetlabs/puppetdb', $convert_legacy_compiler_targets) |
| 146 | + run_command('rm -rf /var/log/puppetlabs/puppetdb', $convert_legacy_compiler_targets) |
| 147 | + run_command('rm -rf /opt/puppetlabs/server/data/puppetdb', $convert_legacy_compiler_targets) |
136 | 148 | } |
137 | 149 |
|
138 | | - run_command('systemctl start pe-puppetserver.service', $legacy_compiler_targets) |
139 | | - run_command('puppet resource service puppet ensure=running', $legacy_compiler_targets) |
| 150 | + run_command('systemctl start pe-puppetserver.service', $convert_legacy_compiler_targets) |
| 151 | + run_command('puppet resource service puppet ensure=running', $convert_legacy_compiler_targets) |
140 | 152 |
|
141 | | - return("Converted host ${legacy_compiler_targets} to legacy compiler.") |
| 153 | + return("Converted host ${convert_legacy_compiler_targets} to legacy compiler.") |
142 | 154 | } |
0 commit comments