|
11 | 11 | Optional[Peadm::SingleTargetSpec] $puppetdb_database_replica_host = undef,
|
12 | 12 |
|
13 | 13 | # Common Configuration
|
14 |
| - String $compiler_pool_address = $master_host, |
15 |
| - Array[String] $dns_alt_names = [ ], |
16 |
| - |
17 |
| - # Options |
18 |
| - Boolean $configure_node_groups = true, |
| 14 | + String $compiler_pool_address = $master_host, |
| 15 | + Optional[String] $internal_compiler_a_pool_address = undef, |
| 16 | + Optional[String] $internal_compiler_b_pool_address = undef, |
| 17 | + Array[String] $dns_alt_names = [ ], |
19 | 18 | ) {
|
20 | 19 | # TODO: read and validate convertable PE version
|
21 | 20 |
|
|
43 | 42 | $compiler_hosts,
|
44 | 43 | )
|
45 | 44 |
|
| 45 | + # Get trusted fact information for all compilers. Use peadm::target_name() as |
| 46 | + # the hash key because the apply block below will break trying to parse the |
| 47 | + # $compiler_extensions variable if it has Target-type hash keys. |
| 48 | + $cert_extensions = run_task('peadm::trusted_facts', $all_targets).reduce({}) |$memo,$result| { |
| 49 | + $memo + { $result.target.peadm::target_name() => $result['extensions'] } |
| 50 | + } |
| 51 | + |
46 | 52 | # Know what version of PE the current targets are
|
47 | 53 | $pe_version = run_task('peadm::read_file', $master_target,
|
48 | 54 | path => '/opt/puppetlabs/server/pe_version',
|
49 | 55 | )[0][content].chomp
|
50 | 56 |
|
51 |
| - # Get trusted fact information for all compilers. Use peadm::target_name() as |
52 |
| - # the hash key because the apply block below will break trying to parse the |
53 |
| - # $compiler_extensions variable if it has Target-type hash keys. |
54 |
| - $compiler_extensions = run_task('peadm::trusted_facts', $compiler_targets).reduce({}) |$memo,$result| { |
55 |
| - $memo + { $result.target.peadm::target_name() => $result['extensions'] } |
| 57 | + # Figure out if this PE deployment has been configured with peadm or pe_xl |
| 58 | + # before |
| 59 | + $previously_configured_by_peadm = $all_targets.any |$target| { |
| 60 | + $exts = $cert_extensions[$target.peadm::target_name()] |
| 61 | + $exts[peadm::oid('peadm_role')] or String($exts[peadm::oid('pp_role')]) =~ /pe_xl|peadm/ |
| 62 | + } |
| 63 | + |
| 64 | + if (!$previously_configured_by_peadm and (versioncmp($pe_version, '2019.7.0') > 0)) { |
| 65 | + fail_plan(@("EOL"/L)) |
| 66 | + PE deployment cannot be converted! PE deployment must be a deployment \ |
| 67 | + created by pe_xl, by an older version of peadm, or be PE version \ |
| 68 | + 2019.7.0 or newer. Detected PE version ${pe_version}, and did not detect \ |
| 69 | + signs that the deployment was previously created by peadm/pe_xl. |
| 70 | + | EOL |
56 | 71 | }
|
57 | 72 |
|
58 | 73 | # Clusters A and B are used to divide PuppetDB availability for compilers. If
|
59 | 74 | # the compilers given already have peadm_availability_group facts designating
|
60 | 75 | # them A or B, use that. Otherwise, divide them by modulus of 2.
|
61 | 76 | if $arch['high-availability'] {
|
62 | 77 | $compiler_a_targets = $compiler_targets.filter |$index,$target| {
|
63 |
| - $exts = $compiler_extensions[$target.peadm::target_name()] |
| 78 | + $exts = $cert_extensions[$target.peadm::target_name()] |
64 | 79 | $exts[peadm::oid('peadm_availability_group')] in ['A', 'B'] ? {
|
65 | 80 | true => $exts[peadm::oid('peadm_availability_group')] == 'A',
|
66 | 81 | false => $index % 2 == 0,
|
67 | 82 | }
|
68 | 83 | }
|
69 | 84 | $compiler_b_targets = $compiler_targets.filter |$index,$target| {
|
70 |
| - $exts = $compiler_extensions[$target.peadm::target_name()] |
| 85 | + $exts = $cert_extensions[$target.peadm::target_name()] |
71 | 86 | $exts[peadm::oid('peadm_availability_group')] in ['A', 'B'] ? {
|
72 | 87 | true => $exts[peadm::oid('peadm_availability_group')] == 'B',
|
73 | 88 | false => $index % 2 != 0,
|
|
79 | 94 | $compiler_b_targets = []
|
80 | 95 | }
|
81 | 96 |
|
82 |
| - if $pe_version =~ /^2018/ { |
| 97 | + # If PE version is older than 2019.7 |
| 98 | + if (versioncmp($pe_version, '2019.7.0') < 0) { |
83 | 99 | apply($master_target) {
|
84 |
| - include peadm::setup::convert_pe2018 |
| 100 | + include peadm::setup::convert_pre20197 |
85 | 101 | }
|
86 | 102 | }
|
87 | 103 |
|
|
146 | 162 | },
|
147 | 163 | )
|
148 | 164 |
|
149 |
| - # Create the necessary node groups in the console |
150 |
| - |
151 |
| - if $configure_node_groups { |
| 165 | + # Create the necessary node groups in the console, unless the PE version is |
| 166 | + # too old to support it pre-upgrade. In that circumstance, we trust that |
| 167 | + # the existing groups are correct enough to function until the upgrade is |
| 168 | + # performed. |
| 169 | + if (versioncmp($pe_version, '2019.7.0') >= 0) { |
152 | 170 | apply($master_target) {
|
153 | 171 | class { 'peadm::setup::node_manager_yaml':
|
154 | 172 | master_host => $master_target.peadm::target_name(),
|
155 | 173 | }
|
156 | 174 |
|
157 | 175 | class { 'peadm::setup::node_manager':
|
158 |
| - master_host => $master_target.peadm::target_name(), |
159 |
| - master_replica_host => $master_replica_target.peadm::target_name(), |
160 |
| - puppetdb_database_host => $puppetdb_database_target.peadm::target_name(), |
161 |
| - puppetdb_database_replica_host => $puppetdb_database_replica_target.peadm::target_name(), |
162 |
| - compiler_pool_address => $compiler_pool_address, |
163 |
| - require => Class['peadm::setup::node_manager_yaml'], |
| 176 | + master_host => $master_target.peadm::target_name(), |
| 177 | + master_replica_host => $master_replica_target.peadm::target_name(), |
| 178 | + puppetdb_database_host => $puppetdb_database_target.peadm::target_name(), |
| 179 | + puppetdb_database_replica_host => $puppetdb_database_replica_target.peadm::target_name(), |
| 180 | + compiler_pool_address => $compiler_pool_address, |
| 181 | + internal_compiler_a_pool_address => $internal_compiler_a_pool_address, |
| 182 | + internal_compiler_b_pool_address => $internal_compiler_b_pool_address, |
| 183 | + require => Class['peadm::setup::node_manager_yaml'], |
164 | 184 | }
|
165 | 185 | }
|
166 | 186 | }
|
| 187 | + else { |
| 188 | + out::message(@("EOL"/L)) |
| 189 | + NOTICE: Node groups not created/updated as part of convert because PE \ |
| 190 | + version is too old to support them. Node groups will be updated when \ |
| 191 | + the peadm::upgrade plan is run. |
| 192 | + | EOL |
| 193 | + } |
167 | 194 |
|
168 | 195 | # Run Puppet on all targets to ensure catalogs and exported resources fully
|
169 | 196 | # up-to-date
|
|
0 commit comments