Skip to content

Commit

Permalink
add parameter for workers to server class
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Apr 22, 2021
1 parent 6331d38 commit 6c6241f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

class { '::icinga::agent':
ca_server => '192.168.5.13',
ca_server => '192.168.5.13',
parent_endpoints => { 'debian10.localdomain' => { 'host' => '192.168.5.23', }, 'centos8.localdomain' => { 'host' => '192.168.5.13', } },
global_zones => [ 'linux-commands' ],
global_zones => [ 'linux-commands' ],
}
1 change: 1 addition & 0 deletions examples/server1st.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
ca => true,
config_server => true,
colocation_endpoints => { 'debian10.localdomain' => { 'host' => '192.168.5.23', } },
workers => { 'dmz' => { 'endpoints' => { 'debian9.localdomain' => { 'host' => '192.168.5.22' }}, }},
global_zones => [ 'global-templates', 'linux-commands', 'windows-commands' ],
}
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
# @param [Boolean] ca
# Enables a CA on this node.
#
# @param [String] ticket_salt
# Set the constants `TicketSalt` if `ca` is set to `true`. Otherwise the set value is used
# to authenticate the certificate request againt the CA on host `ca_server`.
#
# @param [String] this_zone
# Name of the Icinga zone.
#
Expand All @@ -28,15 +24,19 @@
# @param [Optional[Stdlib::Host]] ca_server
# The CA to send the certificate request to.
#
# @param [Optional[String]] ticket_salt
# Set the constants `TicketSalt` if `ca` is set to `true`. Otherwise the set value is used
# to authenticate the certificate request againt the CA on host `ca_server`.
#
class icinga(
Boolean $ca,
String $ticket_salt,
String $this_zone,
Hash[String, Hash] $zones,
Enum['dsa','ecdsa','ed25519','rsa'] $ssh_key_type = 'rsa',
Optional[String] $ssh_private_key = undef,
Optional[String] $ssh_pub_key = undef,
Optional[Stdlib::Host] $ca_server = undef,
Optional[String] $ticket_salt = undef,
) {

assert_private()
Expand Down
14 changes: 12 additions & 2 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# When the zone includes more than one endpoint, set here the additional endpoint(s).
# Icinga supports two endpoints per zone only.
#
# @param [Hash[String,Hash]] workers
# All worker zones with key 'endpoints' for
# endpoint objects.
#
# @param [Array[String]] global_zones
# List of global zones to configure.
#
Expand All @@ -31,6 +35,7 @@
Boolean $config_server = false,
String $zone = 'main',
Hash[String,Hash] $colocation_endpoints = {},
Hash[String,Hash] $workers = {},
Array[String] $global_zones = [],
Optional[Stdlib::Host] $ca_server = undef,
Optional[String] $ticket_salt = undef,
Expand All @@ -48,13 +53,18 @@
$_config_server = $config_server
}

# inject parent zone
$_workers = parseyaml(inline_template(
'<%= @workers.inject({}) {|h, (x,y)| h[x] = y.merge({"parent" => @zone}); h}.to_yaml %>'
))

class { '::icinga':
ca => $_ca,
ca_server => $ca_server,
this_zone => $zone,
zones => {
zones => merge({
'ZoneName' => { 'endpoints' => { 'NodeName' => {}} + $colocation_endpoints },
},
}, $_workers),
ticket_salt => $ticket_salt,
}

Expand Down

0 comments on commit 6c6241f

Please sign in to comment.