Skip to content

Commit dee5e8d

Browse files
committed
Use apply block for configuring node groups
This commit is a WIP on the way to accomplishing the one-line commit message goal.
1 parent be81fd7 commit dee5e8d

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 8 additions & 0 deletions
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

plans/test.pp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
plan pe_xl::test (
2+
TargetSpec $nodes,
3+
) {
4+
$target = get_target($nodes)
5+
6+
$servername = $target.host
7+
apply($target) {
8+
9+
file { 'node_manager.yaml':
10+
ensure => file,
11+
mode => '0644',
12+
path => Deferred('pe_xl::node_manager_yaml_location'),
13+
content => epp('pe_xl/node_manager.yaml.epp', {
14+
server => $servername,
15+
}),
16+
}
17+
18+
Node_group {
19+
require => File['node_manager.yaml'],
20+
}
21+
22+
node_group { 'Test Group':
23+
ensure => present,
24+
parent => 'PE Infrastructure',
25+
rule => ['and',
26+
['=', ['trusted', 'extensions', 'pp_role'], 'pe_xl::master'],
27+
['=', ['trusted', 'extensions', 'pp_cluster'], 'B'],
28+
],
29+
}
30+
31+
}
32+
33+
}

templates/node_manager.yaml.epp

Lines changed: 8 additions & 0 deletions
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)