From 6c6241f12f6640ef510320511a11db3e917472b2 Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Thu, 4 Mar 2021 08:28:54 +0100 Subject: [PATCH] add parameter for workers to server class --- examples/agent.pp | 4 ++-- examples/server1st.pp | 1 + manifests/init.pp | 10 +++++----- manifests/server.pp | 14 ++++++++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/examples/agent.pp b/examples/agent.pp index 1fcdcf1..ade1cd0 100644 --- a/examples/agent.pp +++ b/examples/agent.pp @@ -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' ], } diff --git a/examples/server1st.pp b/examples/server1st.pp index 8079fcc..4b945a5 100644 --- a/examples/server1st.pp +++ b/examples/server1st.pp @@ -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' ], } diff --git a/manifests/init.pp b/manifests/init.pp index 53ea5de..e7ec07f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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. # @@ -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() diff --git a/manifests/server.pp b/manifests/server.pp index fd46f9d..ab4b763 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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. # @@ -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, @@ -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, }