[icinga-checkins] icinga.org: chef-icinga2/master: Add create_endpoints/ create_zones in env provider

git at icinga.org git at icinga.org
Sat Jul 16 19:49:34 CEST 2016


Module: chef-icinga2
Branch: master
Commit: 5b02eff8eb80aa5af8eaa3a1182c4d05d5328d77
URL:    https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=5b02eff8eb80aa5af8eaa3a1182c4d05d5328d77

Author: Thomas Peitz <thomas.peitz at invision.de>
Date:   Wed Jun  1 12:12:03 2016 +0200

Add create_endpoints/create_zones in env provider

---

 libraries/provider_environment.rb |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/libraries/provider_environment.rb b/libraries/provider_environment.rb
index f03d8da..1ecadc1 100644
--- a/libraries/provider_environment.rb
+++ b/libraries/provider_environment.rb
@@ -121,6 +121,8 @@ class Chef
           notifies :reload, 'service[icinga2]'
         end
         return true if hosts_template.updated? || create_hostgroups(env_resources)
+        return true if hosts_template.updated? || create_endpoints(env_resources)
+        return true if hosts_template.updated? || create_zones(env_resources)
       end
 
       def create_hostgroups(env_resources)
@@ -142,6 +144,33 @@ class Chef
 
         hostgroup_template.updated?
       end
+
+      def create_endpoints(env_resources)
+        nodes = env_resources['nodes']
+        env_endpoints = nodes.map {|n| n[1]['fqdn'] }
+
+        endpoint_template = icinga2_envendpoint new_resource.environment do
+          endpoints env_endpoints
+          port new_resource.endpoint_port
+          log_duration new_resource.endpoint_log_duration
+          zone new_resource.zone
+        end
+
+        endpoint_template.updated?
+      end
+
+      def create_zones(env_resources)
+        nodes = env_resources['nodes']
+        env_zones = nodes.map {|n| n[1]['fqdn'] }
+
+        zone_template = icinga2_envzone new_resource.environment do
+          zones env_zones
+          parent new_resource.zone_parent
+          zone new_resource.zone
+        end
+
+        zone_template.updated?
+      end
     end
   end
 end



More information about the icinga-checkins mailing list