diff --git a/components/cluster/cluster-type.conf b/components/cluster/cluster-type.conf index 406118e71..b15a817d5 100644 --- a/components/cluster/cluster-type.conf +++ b/components/cluster/cluster-type.conf @@ -48,6 +48,14 @@ type Endpoint { %attribute string "*" }, + %attribute array "config_files_recursive" { + %attribute string "*", + %attribute dictionary "*" { + %attribute string "path", + %attribute string "pattern" + } + }, + %attribute array "accept_config" { %attribute name(Endpoint) "*" } diff --git a/components/cluster/clusterlistener.cpp b/components/cluster/clusterlistener.cpp index 729fb6c97..3b51c5ee3 100644 --- a/components/cluster/clusterlistener.cpp +++ b/components/cluster/clusterlistener.cpp @@ -538,6 +538,23 @@ void ClusterListener::NewClientHandler(const Socket::Ptr& client, TlsRole role) } } + Array::Ptr configFilesRecursive = endpoint->GetConfigFilesRecursive(); + + if (configFilesRecursive) { + ObjectLock olock(configFilesRecursive); + BOOST_FOREACH(const Value& configFile, configFilesRecursive) { + if (configFile.IsObjectType()) { + Dictionary::Ptr configFileDict = configFile; + String path = configFileDict->Get("path"); + String pattern = configFileDict->Get("pattern"); + Utility::GlobRecursive(path, pattern, boost::bind(&ClusterListener::ConfigGlobHandler, boost::cref(config), _1, false), GlobFile); + } else { + String configFilePath = configFile; + Utility::GlobRecursive(configFilePath, "*.conf", boost::bind(&ClusterListener::ConfigGlobHandler, boost::cref(config), _1, false), GlobFile); + } + } + } + Log(LogInformation, "cluster", "Sending " + Convert::ToString(static_cast(config->GetLength())) + " config files to endpoint '" + endpoint->GetName() + "'."); Dictionary::Ptr params = make_shared(); diff --git a/components/cluster/endpoint.ti b/components/cluster/endpoint.ti index b54b464cb..4b4e7757e 100644 --- a/components/cluster/endpoint.ti +++ b/components/cluster/endpoint.ti @@ -8,6 +8,7 @@ class Endpoint : DynamicObject [config] String host; [config] String port; [config] Array::Ptr config_files; + [config] Array::Ptr config_files_recursive; [config] Array::Ptr accept_config; [state] double seen; diff --git a/doc/4.3-object-types.md b/doc/4.3-object-types.md index b684a0cff..4128f5c29 100644 --- a/doc/4.3-object-types.md +++ b/doc/4.3-object-types.md @@ -873,6 +873,13 @@ Example: object Endpoint "icinga-c2" { host = "192.168.5.46", port = 7777, + + config_files = [ "/etc/icinga2/cluster.d/*" ], + + config_files_recursive = [ + "/etc/icinga2/cluster2", + { path = "/etc/icinga2/cluster3", pattern = "*.myconf" } + ] } Attributes: @@ -882,6 +889,7 @@ Attributes: host |**Required.** The hostname/IP address of the remote Icinga 2 instance. port |**Required.** The service name/port of the remote Icinga 2 instance. config\_files |**Optional.** A list of configuration files sent to remote peers (wildcards possible). + config_files_recursive |**Optional.** A list of configuration files sent to remote peers. Array elements can either be a string (in which case all files in that directory matching the pattern *.conf are included) or a dictionary with elements "path" and "pattern". accept\_config |**Optional.** A list of endpoint names from which this endpoint accepts configuration files. ### Domain