Skip to content

Commit 136ae26

Browse files
authored
Merge pull request #28 from puppetlabs/use-node_group-apply
Use node group apply
2 parents be81fd7 + c2a2d3f commit 136ae26

File tree

7 files changed

+65
-266
lines changed

7 files changed

+65
-266
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Puppet::Functions.create_function(:'pe_xl::node_manager_yaml_location') do
2+
dispatch :nm_yaml_location do
3+
end
4+
5+
def nm_yaml_location()
6+
File.join(Puppet.settings['confdir'], 'node_manager.yaml')
7+
end
8+
end

Diff for: manifests/setup/node_manager.pp

+15-12
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,21 @@
6161
variables => { 'pe_master' => true },
6262
}
6363

64-
# This class has to be included here because puppet_enterprise is declared
65-
# in the console with parameters. It is therefore not possible to include
66-
# puppet_enterprise::profile::database in code without causing a conflict.
67-
node_group { 'PE Database':
68-
ensure => present,
69-
parent => 'PE Infrastructure',
70-
environment => 'production',
71-
override_environment => false,
72-
rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']],
73-
classes => {
74-
'puppet_enterprise::profile::database' => { },
75-
},
64+
# Create the database group if a database host is external
65+
if ($puppetdb_database_host != $master_host) {
66+
# This class has to be included here because puppet_enterprise is declared
67+
# in the console with parameters. It is therefore not possible to include
68+
# puppet_enterprise::profile::database in code without causing a conflict.
69+
node_group { 'PE Database':
70+
ensure => present,
71+
parent => 'PE Infrastructure',
72+
environment => 'production',
73+
override_environment => false,
74+
rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']],
75+
classes => {
76+
'puppet_enterprise::profile::database' => { },
77+
},
78+
}
7679
}
7780

7881
# Create data-only groups to store PuppetDB PostgreSQL database configuration

Diff for: plans/unit/configure.pp

+34-20
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,42 @@
3737
$compiler_hosts,
3838
)
3939

40-
# Retrieve and deploy Puppet modules from the Forge so that they can be used
41-
# for ensuring some configuration (node groups)
42-
[ ['WhatsARanjit-node_manager', '0.7.1'],
43-
['puppetlabs-stdlib', '5.0.0'],
44-
].each |$tuple| {
45-
run_plan('pe_xl::util::install_module',
46-
nodes => $master_target,
47-
module => $tuple[0],
48-
version => $tuple[1],
49-
stagingdir => $stagingdir,
50-
)
51-
}
52-
5340
# Set up the console node groups to configure the various hosts in their
5441
# roles
55-
run_task('pe_xl::configure_node_groups', $master_target,
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(),
60-
compiler_pool_address => $compiler_pool_address,
61-
)
42+
43+
# Pending resolution of Bolt GH-1244, Target objects and their methods are
44+
# not accessible inside apply() blocks. Work around the limitation for now
45+
# by using string variables calculated outside the apply block. The
46+
# commented-out values should be used once GH-1244 is resolved.
47+
48+
# WORKAROUND: GH-1244
49+
$master_host_string = $master_target.pe_xl::target_host()
50+
$master_replica_host_string = $master_replica_target.pe_xl::target_host()
51+
$puppetdb_database_host_string = $puppetdb_database_target.pe_xl::target_host()
52+
$puppetdb_database_replica_host_string = $puppetdb_database_replica_target.pe_xl::target_host()
53+
54+
apply($master_target) {
55+
# Necessary to give the sandboxed Puppet executor the configuration
56+
# necessary to connect to the classifier`
57+
file { 'node_manager.yaml':
58+
ensure => file,
59+
mode => '0644',
60+
path => Deferred('pe_xl::node_manager_yaml_location'),
61+
content => epp('pe_xl/node_manager.yaml.epp', {
62+
server => $master_host_string,
63+
}),
64+
}
65+
66+
class { 'pe_xl::setup::node_manager':
67+
# WORKAROUND: GH-1244
68+
master_host => $master_host_string, # $master_target.pe_xl::target_host(),
69+
master_replica_host => $master_replica_host_string, # $master_replica_target.pe_xl::target_host(),
70+
puppetdb_database_host => $puppetdb_database_host_string, # $puppetdb_database_target.pe_xl::target_host(),
71+
puppetdb_database_replica_host => $puppetdb_database_replica_host_string, # $puppetdb_database_replica_target.pe_xl::target_host(),
72+
compiler_pool_address => $compiler_pool_address,
73+
require => File['node_manager.yaml'],
74+
}
75+
}
6276

6377
# Run Puppet in no-op on the compilers so that their status in PuppetDB
6478
# is updated and they can be identified by the puppet_enterprise module as

Diff for: plans/util/install_module.pp

-29
This file was deleted.

Diff for: tasks/configure_node_groups.json

-29
This file was deleted.

Diff for: tasks/configure_node_groups.sh

-176
This file was deleted.

Diff for: templates/node_manager.yaml.epp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<%- | String $server,
2+
| -%>
3+
---
4+
server: <%= $server %>
5+
port: 4433
6+
hostcert: /etc/puppetlabs/puppet/ssl/certs/<%= $server %>.pem
7+
hostprivkey: /etc/puppetlabs/puppet/ssl/private_keys/<%= $server %>.pem
8+
localcacert: /etc/puppetlabs/puppet/ssl/certs/ca.pem

0 commit comments

Comments
 (0)