]> granicus.if.org Git - icinga2/commitdiff
Add global zone identifier for global object/template configuration.
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 10 Jun 2014 09:40:43 +0000 (11:40 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 11 Jun 2014 14:49:30 +0000 (16:49 +0200)
Refs #6254

doc/4-monitoring-remote-systems.md
etc/icinga2/zones.conf
lib/remote/apilistener-sync.cpp
lib/remote/apilistener.hpp
lib/remote/remote-type.conf
lib/remote/zone.ti

index 376000053c84d59eea2a79c1cb51f028cce32202..a3bb3e4072a8beca0c71b038c5b3a845fde98f59 100644 (file)
@@ -344,6 +344,35 @@ process.
 > determines the required include directory. This can be overridden using the
 > [global constant](#global-constants) `ZonesDir`.
 
+#### <a id="zone-synchronisation-permissions"></a> Global configuration zone
+
+If your zone configuration setup shares the same templates, groups, commands, timeperiods, etc.
+you would have to duplicate quite a lot of configuration objects making the merged configuration
+on your configuration master unique.
+
+That is not necessary by defining a global zone shipping all those templates. By settting
+`global = true` you ensure that this zone configuration template will be synchronized to all
+involved nodes (only if they accept configuration though).
+
+    /etc/icinga2/zones.d
+      global-templates/
+        templates.conf
+        groups.conf
+      master
+        health.conf
+      checker
+        health.conf
+        demo.conf
+
+In this example, the global zone is called `global-templates` and must be defined in
+your zone configuration visible to all nodes.
+
+    object Zone "global-templates" {
+      global = true
+    }
+
+If you don't require any global configuration, skip this setting.
+
 #### <a id="zone-synchronisation-permissions"></a> Zone Configuration Permissions
 
 Each [ApiListener](#objecttype-apilistener) object must have the `accept_config` attribute
index e7a1d99ce484af5b0b329c8b184628e0c4cd9d14..6ad1537cc6de4273e0867d5ff5aab9e74223be37 100644 (file)
@@ -12,6 +12,16 @@ object Zone ZoneName {
   endpoints = [ NodeName ]
 }
 
+/*
+ * Defines a global zone containing templates,
+ * etc. synced to all nodes, if they accept
+ * configuration.
+ */
+
+object Zone "global-templates" {
+  global = true
+}
+
 /*
  * Read the documentation on how to configure
  * a cluster setup with multiple zones.
index 6c13711fe9f16d5136fe097d6338ca8690667a45..81ce77be9cadf8398e5f1edc0f35c14f7f04bca7 100644 (file)
@@ -126,6 +126,12 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
 void ApiListener::SyncZoneDirs(void) const
 {
        BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
+               /* always sync global zone dirs */
+               if (zone->GetGlobal()) {
+                       SyncZoneDir(zone);
+                       continue;
+               }
+
                if (!IsConfigMaster(zone))
                        continue;
 
index 5cd0c041151de50bfc7054d0dbd91bc69008b5bf..cac4f93b9c112ff84a0439331e4c767d5b54d520 100644 (file)
@@ -105,8 +105,10 @@ private:
 
        static Dictionary::Ptr LoadConfigDir(const String& dir);
        static bool UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictionary::Ptr& newConfig, const String& configDir);
+
        void SyncZoneDirs(void) const;
        void SyncZoneDir(const Zone::Ptr& zone) const;
+
        bool IsConfigMaster(const Zone::Ptr& zone) const;
        static void ConfigGlobHandler(const Dictionary::Ptr& config, const String& path, const String& file);
        void SendConfigUpdate(const ApiClient::Ptr& aclient);
index a4abff727d880a71e7986dad9ee0625ef2b96cd5..c59a8e9187480a2cb52506581bbadfae69db658a 100644 (file)
@@ -47,5 +47,7 @@
 
        %attribute %array "endpoints" {
                %attribute %name(Endpoint) "*"
-       }
+       },
+
+       %attribute %number "global"
 }
index d2f3433f047e93af80278f20bac21f73d0024e56..743f8cb991637413064eac52845c5239980507d2 100644 (file)
@@ -7,6 +7,7 @@ class Zone : DynamicObject
 {
        [config] String parent (ParentRaw);
        [config] Array::Ptr endpoints (EndpointsRaw);
+       [config] bool global;
 };
 
 }