|
1 | 1 | # @summary Upgrade an Extra Large stack from one .z to the next
|
2 | 2 | #
|
3 | 3 | plan peadm::upgrade (
|
4 |
| - String[1] $master_host, |
5 |
| - String[1] $puppetdb_database_host, |
6 |
| - Optional[String[1]] $master_replica_host = undef, |
7 |
| - Optional[String[1]] $puppetdb_database_replica_host = undef, |
| 4 | + # Standard |
| 5 | + Peadm::SingleTargetSpec $master_host, |
| 6 | + Optional[Peadm::SingleTargetSpec] $master_replica_host = undef, |
8 | 7 |
|
9 |
| - String[1] $version, |
| 8 | + # Large |
| 9 | + Optional[TargetSpec] $compiler_hosts = undef, |
| 10 | + |
| 11 | + # Extra Large |
| 12 | + Optional[Peadm::SingleTargetSpec] $puppetdb_database_host = undef, |
| 13 | + Optional[Peadm::SingleTargetSpec] $puppetdb_database_replica_host = undef, |
| 14 | + |
| 15 | + String $version, |
10 | 16 |
|
11 | 17 | # This parameter exists to enable the use case of running peadm::upgrade over
|
12 | 18 | # the PCP transport. An orchestrator restart happens during provision
|
|
16 | 22 | Boolean $executing_on_master = false,
|
17 | 23 |
|
18 | 24 | String[1] $stagingdir = '/tmp',
|
19 |
| - String[1] $pe_source = "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-el-7-x86_64.tar.gz", |
20 | 25 | ) {
|
| 26 | + # Ensure input valid for a supported architecture |
| 27 | + $arch = peadm::validate_architecture( |
| 28 | + $master_host, |
| 29 | + $master_replica_host, |
| 30 | + $puppetdb_database_host, |
| 31 | + $puppetdb_database_replica_host, |
| 32 | + $compiler_hosts, |
| 33 | + ) |
21 | 34 |
|
22 |
| - # Allow for the upgrade task to be run local to the master. |
23 |
| - $master_target = $executing_on_master ? { |
24 |
| - true => "local://${master_host}", |
25 |
| - false => $master_host, |
26 |
| - } |
| 35 | + # Convert inputs into targets. |
| 36 | + $master_target = peadm::get_targets($master_host, 1) |
| 37 | + $master_replica_target = peadm::get_targets($master_replica_host, 1) |
| 38 | + $puppetdb_database_target = peadm::get_targets($puppetdb_database_host, 1) |
| 39 | + $puppetdb_database_replica_target = peadm::get_targets($puppetdb_database_replica_host, 1) |
| 40 | + $compiler_targets = peadm::get_targets($compiler_hosts) |
27 | 41 |
|
28 |
| - $ha_replica_target = [ |
29 |
| - $master_replica_host, |
30 |
| - ].peadm::flatten_compact() |
| 42 | + $all_targets = peadm::flatten_compact([ |
| 43 | + $master_target, |
| 44 | + $puppetdb_database_target, |
| 45 | + $master_replica_target, |
| 46 | + $puppetdb_database_replica_target, |
| 47 | + $compiler_targets, |
| 48 | + ]) |
31 | 49 |
|
32 |
| - $ha_database_target = [ |
33 |
| - $puppetdb_database_replica_host, |
34 |
| - ].peadm::flatten_compact() |
35 |
| - |
36 |
| - # Look up which hosts are compilers in the stack |
37 |
| - # We look up groups of CMs separately since when they are upgraded is determined |
38 |
| - # by which PDB PG host they are affiliated with |
39 |
| - $compiler_cluster_master_hosts = puppetdb_query(@("PQL")).map |$node| { $node['certname'] } |
40 |
| - resources[certname] { |
41 |
| - type = "Class" and |
42 |
| - title = "Puppet_enterprise::Profile::Puppetdb" and |
43 |
| - parameters.database_host = "${puppetdb_database_host}" and |
44 |
| - !(certname = "${master_host}") } |
45 |
| - | PQL |
46 |
| - |
47 |
| - $compiler_cluster_master_replica_hosts = puppetdb_query(@("PQL")).map |$node| { $node['certname'] } |
48 |
| - resources[certname] { |
49 |
| - type = "Class" and |
50 |
| - title = "Puppet_enterprise::Profile::Puppetdb" and |
51 |
| - parameters.database_host = "${puppetdb_database_replica_host}" and |
52 |
| - !(certname = "${master_replica_host}") } |
53 |
| - | PQL |
54 |
| - |
55 |
| - $all_hosts = [ |
| 50 | + $pe_installer_targets = peadm::flatten_compact([ |
56 | 51 | $master_target,
|
57 |
| - $puppetdb_database_host, |
58 |
| - $master_replica_host, |
59 |
| - $puppetdb_database_replica_host, |
60 |
| - $compiler_cluster_master_hosts, |
61 |
| - $compiler_cluster_master_replica_hosts, |
62 |
| - ].peadm::flatten_compact() |
| 52 | + $puppetdb_database_target, |
| 53 | + $puppetdb_database_replica_target, |
| 54 | + ]) |
63 | 55 |
|
64 |
| - # We need to make sure we aren't using PCP as this will go down during the upgrade |
65 |
| - $all_hosts.peadm::fail_on_transport('pcp') |
| 56 | + # Gather trusted facts from all systems |
| 57 | + $trusted_facts = run_task('peadm::trusted_facts', $all_targets).reduce({}) |$memo,$result| { |
| 58 | + $memo + { $result.target => $result['extensions'] } |
| 59 | + } |
66 | 60 |
|
67 |
| - # TODO: Do we need to update the pe.conf(s) with a console password? |
| 61 | + # Determine which compilers are associated with which HA group |
| 62 | + $compiler_m1_targets = $compiler_targets.filter |$target| { |
| 63 | + $trusted_facts[$target]['pp_cluster'] == $trusted_facts[$master_target[0]]['pp_cluster'] |
| 64 | + } |
68 | 65 |
|
69 |
| - # Download the PE tarball on the nodes that need it |
70 |
| - $upload_tarball_path = "/tmp/puppet-enterprise-${version}-el-7-x86_64.tar.gz" |
| 66 | + $compiler_m2_targets = $compiler_targets.filter |$target| { |
| 67 | + $trusted_facts[$target]['pp_cluster'] == $trusted_facts[$master_replica_target[0]]['pp_cluster'] |
| 68 | + } |
71 | 69 |
|
72 |
| - $download_hosts = [ |
73 |
| - $master_target, |
74 |
| - $puppetdb_database_host, |
75 |
| - $puppetdb_database_replica_host, |
76 |
| - ].peadm::flatten_compact() |
| 70 | + ########################################################################### |
| 71 | + # PREPARATION |
| 72 | + ########################################################################### |
| 73 | + |
| 74 | + # Support for running over the orchestrator transport is still TODO. For now, |
| 75 | + #fail the plan if the orchestrator is being used. |
| 76 | + $all_targets.peadm::fail_on_transport('pcp') |
77 | 77 |
|
78 |
| - run_task('peadm::download', $download_hosts, |
79 |
| - source => $pe_source, |
80 |
| - path => $upload_tarball_path, |
| 78 | + # Download the PE tarball on the nodes that need it |
| 79 | + $platform = run_task('peadm::precheck', $master_target).first['platform'] |
| 80 | + $tarball_filename = "puppet-enterprise-${version}-${platform}.tar.gz" |
| 81 | + $upload_tarball_path = "/tmp/${tarball_filename}" |
| 82 | + |
| 83 | + run_plan('peadm::util::retrieve_and_upload', $pe_installer_targets, |
| 84 | + source => "https://s3.amazonaws.com/pe-builds/released/${version}/${tarball_filename}", |
| 85 | + local_path => "${stagingdir}/${tarball_filename}", |
| 86 | + upload_path => $upload_tarball_path, |
81 | 87 | )
|
82 | 88 |
|
83 |
| - # Shut down Puppet on all infra hosts |
84 |
| - run_task('service', $all_hosts, |
| 89 | + # Shut down Puppet on all infra targets |
| 90 | + run_task('service', $all_targets, |
85 | 91 | action => 'stop',
|
86 | 92 | name => 'puppet',
|
87 | 93 | )
|
88 | 94 |
|
| 95 | + ########################################################################### |
| 96 | + # UPGRADE MASTER SIDE |
| 97 | + ########################################################################### |
| 98 | + |
89 | 99 | # Shut down PuppetDB on CMs that use the PM's PDB PG
|
90 |
| - run_task('service', $compiler_cluster_master_hosts, |
| 100 | + run_task('service', peadm::flatten_compact([ |
| 101 | + $master_target, |
| 102 | + $compiler_m1_targets, |
| 103 | + ]), |
91 | 104 | action => 'stop',
|
92 | 105 | name => 'pe-puppetdb',
|
93 | 106 | )
|
94 | 107 |
|
95 |
| - # Shut down pe-* services on the master. Only shutting down the ones |
96 |
| - # that have failover pairs on the master replica. |
97 |
| - ['pe-console-services', 'pe-nginx', 'pe-puppetserver', 'pe-puppetdb', 'pe-postgresql'].each |$service| { |
98 |
| - run_task('service', $master_target, |
99 |
| - action => 'stop', |
100 |
| - name => $service, |
101 |
| - ) |
102 |
| - } |
103 |
| - |
104 |
| - # TODO: Firewall up the master |
105 |
| - |
106 |
| - run_task('peadm::pe_install', $master_target, |
| 108 | + run_task('peadm::pe_install', $puppetdb_database_target, |
107 | 109 | tarball => $upload_tarball_path,
|
108 | 110 | )
|
109 | 111 |
|
110 |
| - # Upgrade the master PuppetDB PostgreSQL host. Note that installer-driven |
111 |
| - # upgrade will de-configure auth access for compilers. Re-run Puppet |
112 |
| - # immediately to fully re-enable |
113 |
| - run_task('peadm::pe_install', $puppetdb_database_host, |
| 112 | + run_task('peadm::pe_install', $master_target, |
114 | 113 | tarball => $upload_tarball_path,
|
115 | 114 | )
|
116 |
| - run_task('peadm::puppet_runonce', $puppetdb_database_host) |
117 | 115 |
|
118 |
| - # Stop PuppetDB on the master |
119 |
| - run_task('service', $master_target, |
120 |
| - action => 'stop', |
121 |
| - name => 'pe-puppetdb', |
122 |
| - ) |
| 116 | + # Installer-driven upgrade will de-configure auth access for compilers. |
| 117 | + # Re-run Puppet immediately to fully re-enable |
| 118 | + run_task('peadm::puppet_runonce', $puppetdb_database_target) |
123 | 119 |
|
124 |
| - # TODO: Unblock 8081 between the master and the master replica |
125 |
| - |
126 |
| - # Start PuppetDB on the master |
127 |
| - run_task('service', $master_target, |
128 |
| - action => 'start', |
129 |
| - name => 'pe-puppetdb', |
130 |
| - ) |
131 |
| - |
132 |
| - # TODO: Remove remaining firewall blocks |
133 | 120 |
|
134 | 121 | # Wait until orchestrator service is healthy to proceed
|
135 | 122 | run_task('peadm::orchestrator_healthcheck', $master_target)
|
136 | 123 |
|
137 |
| - # Upgrade the compiler group A hosts |
138 |
| - run_task('peadm::agent_upgrade', $compiler_cluster_master_hosts, |
139 |
| - server => $master_host, |
| 124 | + # Upgrade the compiler group A targets |
| 125 | + run_task('peadm::agent_upgrade', $compiler_m1_targets, |
| 126 | + server => $master_target.peadm::target_name(), |
140 | 127 | )
|
141 | 128 |
|
142 |
| - # Shut down PuppetDB on CMs that use the PMR's PDB PG |
143 |
| - run_task('service', $compiler_cluster_master_replica_hosts, |
| 129 | + ########################################################################### |
| 130 | + # UPGRADE REPLICA SIDE |
| 131 | + ########################################################################### |
| 132 | + |
| 133 | + # Shut down PuppetDB on compilers that use the repica's PDB PG |
| 134 | + run_task('service', peadm::flatten_compact([ |
| 135 | + $master_replica_target, |
| 136 | + $compiler_m2_targets, |
| 137 | + ]), |
144 | 138 | action => 'stop',
|
145 | 139 | name => 'pe-puppetdb',
|
146 | 140 | )
|
147 | 141 |
|
148 |
| - # Run the upgrade.sh script on the master replica host |
149 |
| - run_task('peadm::agent_upgrade', $ha_replica_target, |
150 |
| - server => $master_host, |
| 142 | + run_task('peadm::pe_install', $puppetdb_database_replica_target, |
| 143 | + tarball => $upload_tarball_path, |
151 | 144 | )
|
152 | 145 |
|
153 |
| - # Upgrade the master replica's PuppetDB PostgreSQL host |
154 |
| - run_task('peadm::pe_install', $ha_database_target, |
155 |
| - tarball => $upload_tarball_path, |
| 146 | + # Installer-driven upgrade will de-configure auth access for compilers. |
| 147 | + # Re-run Puppet immediately to fully re-enable |
| 148 | + run_task('peadm::puppet_runonce', $puppetdb_database_replica_target) |
| 149 | + |
| 150 | + # Run the upgrade.sh script on the master replica target |
| 151 | + run_task('peadm::agent_upgrade', $master_replica_target, |
| 152 | + server => $master_target.peadm::target_name(), |
156 | 153 | )
|
157 |
| - run_task('peadm::puppet_runonce', $ha_database_target) |
158 | 154 |
|
159 |
| - # Upgrade the compiler group B hosts |
160 |
| - run_task('peadm::agent_upgrade', $compiler_cluster_master_replica_hosts, |
161 |
| - server => $master_host, |
| 155 | + # Upgrade the compiler group B targets |
| 156 | + run_task('peadm::agent_upgrade', $compiler_m2_targets, |
| 157 | + server => $master_target.peadm::target_name(), |
162 | 158 | )
|
163 | 159 |
|
164 |
| - # Ensure Puppet running on all infrastructure hosts |
165 |
| - run_task('service', $all_hosts, |
| 160 | + ########################################################################### |
| 161 | + # FINALIZE UPGRADE |
| 162 | + ########################################################################### |
| 163 | + |
| 164 | + # Ensure Puppet running on all infrastructure targets |
| 165 | + run_task('service', $all_targets, |
166 | 166 | action => 'start',
|
167 | 167 | name => 'puppet',
|
168 | 168 | )
|
|
0 commit comments