|
1 | 1 | # @summary Configure first-time classification and HA setup
|
2 | 2 | #
|
3 | 3 | plan pe_xl::unit::configure (
|
4 |
| - String[1] $master_host, |
5 |
| - Array[String[1]] $compiler_hosts = [ ], |
6 |
| - |
7 |
| - Optional[String[1]] $puppetdb_database_host = undef, |
8 |
| - Optional[String[1]] $master_replica_host = undef, |
9 |
| - Optional[String[1]] $puppetdb_database_replica_host = undef, |
10 |
| - |
11 |
| - # This parameter exists primarily to enable the use case of running |
12 |
| - # pe_xl::configure over the PCP transport. An orchestrator restart happens |
13 |
| - # during provision replica. Running `bolt plan run` directly on the master |
14 |
| - # and using local transport for that node will let the plan to run to |
15 |
| - # completion without failing due to being disconnected from the orchestrator. |
16 |
| - Boolean $executing_on_master = false, |
17 |
| - |
18 |
| - String[1] $compiler_pool_address = $master_host, |
19 |
| - Optional[String[1]] $token_file = undef, |
20 |
| - Optional[String[1]] $deploy_environment = undef, |
21 |
| - |
22 |
| - String[1] $stagingdir = '/tmp', |
| 4 | + # Large |
| 5 | + Pe_xl::SingleTargetSpec $master_host, |
| 6 | + Optional[TargetSpec] $compiler_hosts = undef, |
| 7 | + Optional[Pe_xl::SingleTargetSpec] $master_replica_host = undef, |
| 8 | + |
| 9 | + # Extra Large |
| 10 | + Optional[Pe_xl::SingleTargetSpec] $puppetdb_database_host = undef, |
| 11 | + Optional[Pe_xl::SingleTargetSpec] $puppetdb_database_replica_host = undef, |
| 12 | + |
| 13 | + # Common Configuration |
| 14 | + String $compiler_pool_address = $master_host, |
| 15 | + Optional[String] $token_file = undef, |
| 16 | + Optional[String] $deploy_environment = undef, |
| 17 | + |
| 18 | + # Other |
| 19 | + String $stagingdir = '/tmp', |
23 | 20 | ) {
|
| 21 | + # Convert inputs into targets. |
| 22 | + $master_target = pe_xl::get_targets($master_host, 1) |
| 23 | + $master_replica_target = pe_xl::get_targets($master_replica_host, 1) |
| 24 | + $puppetdb_database_replica_target = pe_xl::get_targets($puppetdb_database_replica_host, 1) |
| 25 | + $compiler_targets = pe_xl::get_targets($compiler_hosts) |
| 26 | + $puppetdb_database_target = $puppetdb_database_host ? { |
| 27 | + undef => $master_target, |
| 28 | + default => pe_xl::get_targets($puppetdb_database_host, 1) |
| 29 | + } |
24 | 30 |
|
25 |
| - $ha_hosts = [ |
| 31 | + # Ensure input valid for a supported architecture |
| 32 | + $arch = pe_xl::validate_architecture( |
| 33 | + $master_host, |
26 | 34 | $master_replica_host,
|
| 35 | + $puppetdb_database_host, |
27 | 36 | $puppetdb_database_replica_host,
|
28 |
| - ].pe_xl::flatten_compact() |
29 |
| - |
30 |
| - # Ensure valid input for HA |
31 |
| - $ha = $ha_hosts.size ? { |
32 |
| - 0 => false, |
33 |
| - 2 => true, |
34 |
| - default => fail('Must specify either both or neither of master_replica_host, puppetdb_database_replica_host'), |
35 |
| - } |
36 |
| - |
37 |
| - # Ensure primary external database host for HA |
38 |
| - if $ha { |
39 |
| - if ! $puppetdb_database_host { |
40 |
| - fail('Must specify puppetdb_database_host for HA environment') |
41 |
| - } |
42 |
| - } |
43 |
| - |
44 |
| - # Allow for the configure task to be run local to the master. |
45 |
| - $master_target = $executing_on_master ? { |
46 |
| - true => "local://${master_host}", |
47 |
| - false => $master_host, |
48 |
| - } |
49 |
| - |
50 |
| - $puppetdb_database_target = $puppetdb_database_host ? { |
51 |
| - undef => $master_host, |
52 |
| - default => $puppetdb_database_host, |
53 |
| - } |
| 37 | + $compiler_hosts, |
| 38 | + ) |
54 | 39 |
|
55 | 40 | # Retrieve and deploy Puppet modules from the Forge so that they can be used
|
56 | 41 | # for ensuring some configuration (node groups)
|
|
68 | 53 | # Set up the console node groups to configure the various hosts in their
|
69 | 54 | # roles
|
70 | 55 | run_task('pe_xl::configure_node_groups', $master_target,
|
71 |
| - master_host => $master_host, |
72 |
| - master_replica_host => $master_replica_host, |
73 |
| - puppetdb_database_host => $puppetdb_database_target, |
74 |
| - puppetdb_database_replica_host => $puppetdb_database_replica_host, |
| 56 | + master_host => $master_target.pe_xl::target_host(), |
| 57 | + master_replica_host => $master_replica_target.pe_xl::target_host(), |
| 58 | + puppetdb_database_host => $puppetdb_database_target.pe_xl::target_host(), |
| 59 | + puppetdb_database_replica_host => $puppetdb_database_replica_target.pe_xl::target_host(), |
75 | 60 | compiler_pool_address => $compiler_pool_address,
|
76 | 61 | )
|
77 | 62 |
|
78 | 63 | # Run Puppet in no-op on the compilers so that their status in PuppetDB
|
79 | 64 | # is updated and they can be identified by the puppet_enterprise module as
|
80 | 65 | # CMs
|
81 |
| - run_task('pe_xl::puppet_runonce', [$compiler_hosts, $master_replica_host].pe_xl::flatten_compact, |
| 66 | + run_task('pe_xl::puppet_runonce', pe_xl::flatten_compact([ |
| 67 | + $compiler_targets, |
| 68 | + $master_replica_target, |
| 69 | + ]), |
82 | 70 | noop => true,
|
83 | 71 | )
|
84 | 72 |
|
85 | 73 | # Run Puppet on the PuppetDB Database hosts to update their auth
|
86 | 74 | # configuration to allow the compilers to connect
|
87 |
| - run_task('pe_xl::puppet_runonce', [ |
| 75 | + run_task('pe_xl::puppet_runonce', pe_xl::flatten_compact([ |
88 | 76 | $puppetdb_database_target,
|
89 |
| - $puppetdb_database_replica_host, |
90 |
| - ].pe_xl::flatten_compact) |
| 77 | + $puppetdb_database_replica_target, |
| 78 | + ])) |
91 | 79 |
|
92 | 80 | # Run Puppet on the master to ensure all services configured and
|
93 | 81 | # running in prep for provisioning the replica. This is done separately so
|
94 | 82 | # that a service restart of pe-puppetserver doesn't cause Puppet runs on
|
95 | 83 | # other nodes to fail.
|
96 | 84 | run_task('pe_xl::puppet_runonce', $master_target)
|
97 | 85 |
|
98 |
| - if $ha { |
| 86 | + if $arch['high-availability'] { |
99 | 87 | # Run the PE Replica Provision
|
100 | 88 | run_task('pe_xl::provision_replica', $master_target,
|
101 |
| - master_replica => $master_replica_host, |
102 |
| - token_file => $token_file, |
| 89 | + master_replica => $master_replica_target.pe_xl::target_host(), |
| 90 | + token_file => $token_file, |
103 | 91 | )
|
104 | 92 |
|
105 | 93 | # Run the PE Replica Enable
|
106 | 94 | run_task('pe_xl::enable_replica', $master_target,
|
107 |
| - master_replica => $master_replica_host, |
108 |
| - token_file => $token_file, |
| 95 | + master_replica => $master_replica_target.pe_xl::target_host(), |
| 96 | + token_file => $token_file, |
109 | 97 | )
|
110 | 98 | }
|
111 | 99 |
|
112 | 100 | # Run Puppet everywhere to pick up last remaining config tweaks
|
113 |
| - run_task('pe_xl::puppet_runonce', [ |
| 101 | + run_task('pe_xl::puppet_runonce', pe_xl::flatten_compact([ |
114 | 102 | $master_target,
|
115 | 103 | $puppetdb_database_target,
|
116 |
| - $compiler_hosts, |
117 |
| - $master_replica_host, |
118 |
| - $puppetdb_database_replica_host, |
119 |
| - ].pe_xl::flatten_compact) |
| 104 | + $compiler_targets, |
| 105 | + $master_replica_target, |
| 106 | + $puppetdb_database_replica_target, |
| 107 | + ])) |
120 | 108 |
|
121 | 109 | # Deploy an environment if a deploy environment is specified
|
122 | 110 | if $deploy_environment {
|
|
125 | 113 | )
|
126 | 114 | }
|
127 | 115 |
|
128 |
| - return('Configuration of Puppet Enterprise with replica succeeded.') |
| 116 | + return("Configuration of Puppet Enterprise ${arch['architecture']} succeeded.") |
129 | 117 | }
|
0 commit comments