Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use node group apply #28

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/puppet/functions/pe_xl/node_manager_yaml_location.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Puppet::Functions.create_function(:'pe_xl::node_manager_yaml_location') do
dispatch :nm_yaml_location do
end

def nm_yaml_location()
File.join(Puppet.settings['confdir'], 'node_manager.yaml')
end
end
27 changes: 15 additions & 12 deletions manifests/setup/node_manager.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@
variables => { 'pe_master' => true },
}

# This class has to be included here because puppet_enterprise is declared
# in the console with parameters. It is therefore not possible to include
# puppet_enterprise::profile::database in code without causing a conflict.
node_group { 'PE Database':
ensure => present,
parent => 'PE Infrastructure',
environment => 'production',
override_environment => false,
rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']],
classes => {
'puppet_enterprise::profile::database' => { },
},
# Create the database group if a database host is external
if ($puppetdb_database_host != $master_host) {
# This class has to be included here because puppet_enterprise is declared
# in the console with parameters. It is therefore not possible to include
# puppet_enterprise::profile::database in code without causing a conflict.
node_group { 'PE Database':
ensure => present,
parent => 'PE Infrastructure',
environment => 'production',
override_environment => false,
rule => ['and', ['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::puppetdb_database']],
classes => {
'puppet_enterprise::profile::database' => { },
},
}
}

# Create data-only groups to store PuppetDB PostgreSQL database configuration
Expand Down
54 changes: 34 additions & 20 deletions plans/unit/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,42 @@
$compiler_hosts,
)

# Retrieve and deploy Puppet modules from the Forge so that they can be used
# for ensuring some configuration (node groups)
[ ['WhatsARanjit-node_manager', '0.7.1'],
['puppetlabs-stdlib', '5.0.0'],
].each |$tuple| {
run_plan('pe_xl::util::install_module',
nodes => $master_target,
module => $tuple[0],
version => $tuple[1],
stagingdir => $stagingdir,
)
}

# Set up the console node groups to configure the various hosts in their
# roles
run_task('pe_xl::configure_node_groups', $master_target,
master_host => $master_target.pe_xl::target_host(),
master_replica_host => $master_replica_target.pe_xl::target_host(),
puppetdb_database_host => $puppetdb_database_target.pe_xl::target_host(),
puppetdb_database_replica_host => $puppetdb_database_replica_target.pe_xl::target_host(),
compiler_pool_address => $compiler_pool_address,
)

# Pending resolution of Bolt GH-1244, Target objects and their methods are
# not accessible inside apply() blocks. Work around the limitation for now
# by using string variables calculated outside the apply block. The
# commented-out values should be used once GH-1244 is resolved.

# WORKAROUND: GH-1244
$master_host_string = $master_target.pe_xl::target_host()
$master_replica_host_string = $master_replica_target.pe_xl::target_host()
$puppetdb_database_host_string = $puppetdb_database_target.pe_xl::target_host()
$puppetdb_database_replica_host_string = $puppetdb_database_replica_target.pe_xl::target_host()

apply($master_target) {
# Necessary to give the sandboxed Puppet executor the configuration
# necessary to connect to the classifier`
file { 'node_manager.yaml':
ensure => file,
mode => '0644',
path => Deferred('pe_xl::node_manager_yaml_location'),
content => epp('pe_xl/node_manager.yaml.epp', {
server => $master_host_string,
}),
}

class { 'pe_xl::setup::node_manager':
# WORKAROUND: GH-1244
master_host => $master_host_string, # $master_target.pe_xl::target_host(),
master_replica_host => $master_replica_host_string, # $master_replica_target.pe_xl::target_host(),
puppetdb_database_host => $puppetdb_database_host_string, # $puppetdb_database_target.pe_xl::target_host(),
puppetdb_database_replica_host => $puppetdb_database_replica_host_string, # $puppetdb_database_replica_target.pe_xl::target_host(),
compiler_pool_address => $compiler_pool_address,
require => File['node_manager.yaml'],
}
}

# Run Puppet in no-op on the compilers so that their status in PuppetDB
# is updated and they can be identified by the puppet_enterprise module as
Expand Down
29 changes: 0 additions & 29 deletions plans/util/install_module.pp

This file was deleted.

29 changes: 0 additions & 29 deletions tasks/configure_node_groups.json

This file was deleted.

176 changes: 0 additions & 176 deletions tasks/configure_node_groups.sh

This file was deleted.

8 changes: 8 additions & 0 deletions templates/node_manager.yaml.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%- | String $server,
| -%>
---
server: <%= $server %>
port: 4433
hostcert: /etc/puppetlabs/puppet/ssl/certs/<%= $server %>.pem
hostprivkey: /etc/puppetlabs/puppet/ssl/private_keys/<%= $server %>.pem
localcacert: /etc/puppetlabs/puppet/ssl/certs/ca.pem