Skip to content

Commit 8b72662

Browse files
committed
Revert "Use Bolt's "apply" functionality for node_manager"
This reverts commit de462a7. Using Bolt's apply functionality over PCP doesn't work. It produces errors like the following: undefined method `error_hash' for #<Array:0x0000000003d72e38> This is a bug that prevents the real error from being shown. Unpacking that it a bit can eventually lead to: The apply_catalog task does not exist in environment production Reverting back to the task-based methodology until I can figure out with the Puppet Tasks team what's happening here and how to make "apply" work over PCP.
1 parent de462a7 commit 8b72662

File tree

5 files changed

+241
-88
lines changed

5 files changed

+241
-88
lines changed

Diff for: docs/basic_usage.md

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ The reference implementation uses trusted facts to put nodes in the right groups
2424
1. Ensure the hostname of each system is set correctly, to the same value that will be used to connect to the system, and refer to the system as. If the hostname is not set as expected the installation plan will refuse to continue.
2525
2. Install Bolt on a jumphost. This can be the primary master, or any other system.
2626
3. Download or git clone the pe\_xl module and put it somewhere on the jumphost, e.g. ~/modules/pe\_xl.
27-
4. Install the pe\_xl module's dependencies, [puppetlabs/stdlib](https://forge.puppet.com/puppetlabs/stdlib) and [WhatsARanjit/node\_manager](https://forge.puppet.com/WhatsARanjit/node_manager), in the same modules directory as pe\_xl
2827
4. Create an inventory file with connection information. Example included below. Available Bolt configuration options are documented here.
2928
5. Create a parameters file. Example included below. Note at the top of the file are arguments which dictate which plans should be run, such as install+configure.
3029
6. Run the pe\_xl plan with the inputs created. Example:

Diff for: manifests/node_manager.pp

+16-78
Original file line numberDiff line numberDiff line change
@@ -25,92 +25,29 @@
2525
# PE INFRASTRUCTURE GROUPS
2626
##################################################
2727

28-
# We modify this group's rule such that all PE infrastructure nodes will be
29-
# members.
3028
node_group { 'PE Infrastructure Agent':
31-
rule => ['and', ['~', ['trusted', 'extensions', 'pp_role'], '^pe_xl::']],
29+
rule => ['and', ['~', ['trusted', 'extensions', 'pp_role'], '^pe_xl::']],
3230
}
3331

34-
# We modify this group to add, as data, the compile_master_pool_address only.
35-
# Because the group does not have any data by default this does not impact
36-
# out-of-box configuration of the group.
3732
node_group { 'PE Master':
38-
rule => ['or',
33+
rule => ['or',
3934
['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master']],
4035
['=', 'name', $primary_master_host],
4136
],
42-
data => {
37+
data => {
4338
'pe_repo' => { 'compile_master_pool_address' => $compile_master_pool_address },
4439
},
4540
}
4641

47-
# We need to pre-create this group so that the primary master replica can be
48-
# identified as running PuppetDB, so that Puppet will create a pg_ident
49-
# authorization rule for it on the PostgreSQL nodes.
50-
node_group { 'PE HA Replica':
51-
ensure => 'present',
52-
parent => 'PE Infrastructure',
53-
rule => ['or', ['=', 'name', $primary_master_replica_host]],
54-
classes => {
55-
'puppet_enterprise::profile::primary_master_replica' => { }
56-
},
57-
}
58-
59-
# Create data-only groups to store PuppetDB PostgreSQL database configuration
60-
# information specific to the primary master and primary master replica nodes.
61-
node_group { 'PE Master A':
62-
ensure => present,
63-
parent => 'PE Infrastructure',
64-
rule => ['and',
65-
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::primary_master'],
66-
['=', ['trusted', 'extensions', 'pp_cluster'], 'A'],
67-
],
68-
data => {
69-
'puppet_enterprise::profile::primary_master_replica' => {
70-
'database_host_puppetdb' => $puppetdb_database_host,
71-
},
72-
'puppet_enterprise::profile::puppetdb' => {
73-
'database_host' => $puppetdb_database_host,
74-
},
75-
},
76-
}
77-
78-
node_group { 'PE Master B':
79-
ensure => present,
80-
parent => 'PE Infrastructure',
81-
rule => ['and',
82-
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::primary_master'],
83-
['=', ['trusted', 'extensions', 'pp_cluster'], 'B'],
84-
],
85-
data => {
86-
'puppet_enterprise::profile::primary_master_replica' => {
87-
'database_host_puppetdb' => $puppetdb_database_replica_host,
88-
},
89-
'puppet_enterprise::profile::puppetdb' => {
90-
'database_host' => $puppetdb_database_replica_host,
91-
},
92-
},
93-
}
94-
95-
# Configure the compile masters for HA, grouped into two pools, each pool
96-
# having an affinity for one "availability zone" or the other. Even with an
97-
# affinity, note that data from each compile master is replicated to both
98-
# "availability zones".
9942
node_group { 'PE Compile Master Group A':
10043
ensure => 'present',
10144
parent => 'PE Master',
10245
rule => ['and',
10346
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master'],
10447
['=', ['trusted', 'extensions', 'pp_cluster'], 'A'],
105-
],
106-
classes => {
107-
'puppet_enterprise::profile::puppetdb' => {
108-
'database_host' => $puppetdb_database_host,
109-
},
110-
'puppet_enterprise::profile::master' => {
111-
'puppetdb_host' => ['${clientcert}', $primary_master_replica_host],
112-
'puppetdb_port' => [8081],
113-
}
48+
],
49+
data => {
50+
'puppet_enterprise::profile::primary_master_replica' => {'database_host_puppetdb' => $puppetdb_database_host }
11451
},
11552
}
11653

@@ -120,18 +57,19 @@
12057
rule => ['and',
12158
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master'],
12259
['=', ['trusted', 'extensions', 'pp_cluster'], 'B'],
123-
],
124-
classes => {
125-
'puppet_enterprise::profile::puppetdb' => {
126-
'database_host' => $puppetdb_database_replica_host,
127-
},
128-
'puppet_enterprise::profile::master' => {
129-
'puppetdb_host' => ['${clientcert}', $primary_master_host],
130-
'puppetdb_port' => [8081],
131-
}
60+
],
61+
data => {
62+
'puppet_enterprise::profile::primary_master_replica' => {'database_host_puppetdb' => $puppetdb_database_replica_host }
13263
},
13364
}
13465

66+
node_group { 'PE PuppetDB':
67+
rule => ['or',
68+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::primary_master'],
69+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master'],
70+
],
71+
}
72+
13573
# This class has to be included here because puppet_enterprise is declared
13674
# in the console with parameters. It is therefore not possible to include
13775
# puppet_enterprise::profile::database in code without causing a conflict.

Diff for: plans/configure.pp

+12-9
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@
1111
String[1] $stagingdir = '/tmp',
1212
) {
1313

14+
# Retrieve and deploy Puppet modules from the Forge so that they can be used
15+
# for ensuring some configuration (node groups)
16+
pe_xl::install_module($primary_master_host, 'WhatsARanjit-node_manager', '0.7.1', $stagingdir)
17+
pe_xl::install_module($primary_master_host, 'puppetlabs-stdlib', '5.0.0', $stagingdir)
18+
1419
# Set up the console node groups to configure the various hosts in their
1520
# roles
16-
apply($primary_master_host) {
17-
class { 'pe_xl::node_manager':
18-
primary_master_host => $primary_master_host,
19-
primary_master_replica_host => $primary_master_replica_host,
20-
puppetdb_database_host => $puppetdb_database_host,
21-
puppetdb_database_replica_host => $puppetdb_database_replica_host,
22-
compile_master_pool_address => $compile_master_pool_address,
23-
}
24-
}
21+
run_task('pe_xl::configure_node_groups', $primary_master_host,
22+
primary_master_host => $primary_master_host,
23+
primary_master_replica_host => $primary_master_replica_host,
24+
puppetdb_database_host => $puppetdb_database_host,
25+
puppetdb_database_replica_host => $puppetdb_database_replica_host,
26+
compile_master_pool_address => $compile_master_pool_address,
27+
)
2528

2629
# Run Puppet in no-op on the compile masters so that their status in PuppetDB
2730
# is updated and they can be identified by the puppet_enterprise module as

Diff for: tasks/configure_node_groups.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"description": "Configure console node groups for a new install",
3+
"parameters": {
4+
"primary_master_host": {
5+
"type": "String",
6+
"description": "The certname of the primary master"
7+
},
8+
"primary_master_replica_host": {
9+
"type": "String",
10+
"description": "The certname of the primary master replica"
11+
},
12+
"puppetdb_database_host": {
13+
"type": "String",
14+
"description": "The certname of the PuppetDB database"
15+
},
16+
"puppetdb_database_replica_host": {
17+
"type": "String",
18+
"description": "The certname of the PuppetDB database replica"
19+
},
20+
"compile_master_pool_address": {
21+
"type": "String",
22+
"description": "The service name to use for the compile master pool"
23+
}
24+
},
25+
"input_method": "environment",
26+
"implementations": [
27+
{"name": "configure_node_groups.pp"}
28+
]
29+
}

Diff for: tasks/configure_node_groups.pp

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
#!/opt/puppetlabs/bin/puppet apply
2+
function param($name) { inline_template("<%= ENV['PT_${name}'] %>") }
3+
4+
class configure_node_groups (
5+
String[1] $primary_master_host = param('primary_master_host'),
6+
String[1] $primary_master_replica_host = param('primary_master_replica_host'),
7+
String[1] $puppetdb_database_host = param('puppetdb_database_host'),
8+
String[1] $puppetdb_database_replica_host = param('puppetdb_database_replica_host'),
9+
String[1] $compile_master_pool_address = param('compile_master_pool_address'),
10+
Pattern[/\A[a-z0-9_]+\Z/] $default_environment = 'production',
11+
Array[Pattern[/\A[a-z0-9_]+\Z/]] $environments = ['production'],
12+
) {
13+
14+
##################################################
15+
# PE INFRASTRUCTURE GROUPS
16+
##################################################
17+
18+
# We modify this group's rule such that all PE infrastructure nodes will be
19+
# members.
20+
node_group { 'PE Infrastructure Agent':
21+
rule => ['and', ['~', ['trusted', 'extensions', 'pp_role'], '^pe_xl::']],
22+
}
23+
24+
# We modify this group to add, as data, the compile_master_pool_address only.
25+
# Because the group does not have any data by default this does not impact
26+
# out-of-box configuration of the group.
27+
node_group { 'PE Master':
28+
rule => ['or',
29+
['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master']],
30+
['=', 'name', $primary_master_host],
31+
],
32+
data => {
33+
'pe_repo' => { 'compile_master_pool_address' => $compile_master_pool_address },
34+
},
35+
}
36+
37+
# We need to pre-create this group so that the primary master replica can be
38+
# identified as running PuppetDB, so that Puppet will create a pg_ident
39+
# authorization rule for it on the PostgreSQL nodes.
40+
node_group { 'PE HA Replica':
41+
ensure => 'present',
42+
parent => 'PE Infrastructure',
43+
rule => ['or', ['=', 'name', $primary_master_replica_host]],
44+
classes => {
45+
'puppet_enterprise::profile::primary_master_replica' => { }
46+
},
47+
}
48+
49+
# Create data-only groups to store PuppetDB PostgreSQL database configuration
50+
# information specific to the primary master and primary master replica nodes.
51+
node_group { 'PE Master A':
52+
ensure => present,
53+
parent => 'PE Infrastructure',
54+
rule => ['and',
55+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::primary_master'],
56+
['=', ['trusted', 'extensions', 'pp_cluster'], 'A'],
57+
],
58+
data => {
59+
'puppet_enterprise::profile::primary_master_replica' => {
60+
'database_host_puppetdb' => $puppetdb_database_host,
61+
},
62+
'puppet_enterprise::profile::puppetdb' => {
63+
'database_host' => $puppetdb_database_host,
64+
},
65+
},
66+
}
67+
68+
node_group { 'PE Master B':
69+
ensure => present,
70+
parent => 'PE Infrastructure',
71+
rule => ['and',
72+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::primary_master'],
73+
['=', ['trusted', 'extensions', 'pp_cluster'], 'B'],
74+
],
75+
data => {
76+
'puppet_enterprise::profile::primary_master_replica' => {
77+
'database_host_puppetdb' => $puppetdb_database_replica_host,
78+
},
79+
'puppet_enterprise::profile::puppetdb' => {
80+
'database_host' => $puppetdb_database_replica_host,
81+
},
82+
},
83+
}
84+
85+
# Configure the compile masters for HA, grouped into two pools, each pool
86+
# having an affinity for one "availability zone" or the other. Even with an
87+
# affinity, note that data from each compile master is replicated to both
88+
# "availability zones".
89+
node_group { 'PE Compile Master Group A':
90+
ensure => 'present',
91+
parent => 'PE Master',
92+
rule => ['and',
93+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master'],
94+
['=', ['trusted', 'extensions', 'pp_cluster'], 'A'],
95+
],
96+
classes => {
97+
'puppet_enterprise::profile::puppetdb' => {
98+
'database_host' => $puppetdb_database_host,
99+
},
100+
'puppet_enterprise::profile::master' => {
101+
'puppetdb_host' => ['${clientcert}', $primary_master_replica_host],
102+
'puppetdb_port' => [8081],
103+
}
104+
},
105+
}
106+
107+
node_group { 'PE Compile Master Group B':
108+
ensure => 'present',
109+
parent => 'PE Master',
110+
rule => ['and',
111+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::compile_master'],
112+
['=', ['trusted', 'extensions', 'pp_cluster'], 'B'],
113+
],
114+
classes => {
115+
'puppet_enterprise::profile::puppetdb' => {
116+
'database_host' => $puppetdb_database_replica_host,
117+
},
118+
'puppet_enterprise::profile::master' => {
119+
'puppetdb_host' => ['${clientcert}', $primary_master_host],
120+
'puppetdb_port' => [8081],
121+
}
122+
},
123+
}
124+
125+
# This class has to be included here because puppet_enterprise is declared
126+
# in the console with parameters. It is therefore not possible to include
127+
# puppet_enterprise::profile::database in code without causing a conflict.
128+
node_group { 'PE Database':
129+
ensure => present,
130+
parent => 'PE Infrastructure',
131+
environment => 'production',
132+
override_environment => false,
133+
rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']],
134+
classes => {
135+
'puppet_enterprise::profile::database' => { },
136+
},
137+
}
138+
139+
##################################################
140+
# ENVIRONMENT GROUPS
141+
##################################################
142+
143+
node_group { 'All Environments':
144+
ensure => present,
145+
description => 'Environment group parent and default',
146+
environment => $default_environment,
147+
override_environment => true,
148+
parent => 'All Nodes',
149+
rule => ['and', ['~', 'name', '.*']],
150+
}
151+
152+
node_group { 'Agent-specified environment':
153+
ensure => present,
154+
description => 'This environment group exists for unusual testing and development only. Expect it to be empty',
155+
environment => 'agent-specified',
156+
override_environment => true,
157+
parent => 'All Environments',
158+
rule => [ ],
159+
}
160+
161+
$environments.each |$env| {
162+
$title_env = capitalize($env)
163+
164+
node_group { "${title_env} environment":
165+
ensure => present,
166+
environment => $env,
167+
override_environment => true,
168+
parent => 'All Environments',
169+
rule => ['and', ['=', ['trusted', 'extensions', 'pp_environment'], $env]],
170+
}
171+
172+
node_group { "${title_env} one-time run exception":
173+
ensure => present,
174+
description => "Allow ${env} nodes to request a different puppet environment for a one-time run",
175+
environment => 'agent-specified',
176+
override_environment => true,
177+
parent => "${title_env} environment",
178+
rule => ['and', ['~', ['fact', 'agent_specified_environment'], '.+']],
179+
}
180+
}
181+
182+
}
183+
184+
include configure_node_groups

0 commit comments

Comments
 (0)