Skip to content

Commit 7afda4d

Browse files
committed
Add cli option to disable the default global zones
When setting up Icinga 2 agents, in most cases, the default global zones are not needed, but have to be removed manually or automatically whith tools outside of Icinga 2 from the configuration. This seems like unnecessary work, since the node setup command does everything else. This commit introduces a new option for the node setup command ("--no-default-global-zones") to exclude the default global zones.
1 parent d551eae commit 7afda4d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/cli/nodesetupcommand.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ void NodeSetupCommand::InitParameters(boost::program_options::options_descriptio
5050
("accept-config", "Accept config from parent node")
5151
("accept-commands", "Accept commands from parent node")
5252
("master", "Use setup for a master instance")
53-
("global_zones", po::value<std::vector<std::string> >(), "The names of the additional global zones to 'global-templates' and 'director-global'.")
53+
("global_zones", po::value<std::vector<std::string> >(), "The names of the additional global zones to add to the default ones (if not deactivated).")
54+
("no-default-global-zones", "Do not add the default global-zones 'global-templates' and 'director-global'")
5455
("disable-confd", "Disables the conf.d directory during the setup");
5556

5657
hiddenDesc.add_options()
@@ -148,7 +149,10 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v
148149
/* write zones.conf and update with zone + endpoint information */
149150
Log(LogInformation, "cli", "Generating zone and object configuration.");
150151

151-
std::vector<String> globalZones { "global-templates", "director-global" };
152+
std::vector<String> globalZones {};
153+
if (!vm.count("no-default-global-zones")) {
154+
globalZones = {"global-templates", "director-global"};
155+
}
152156
std::vector<std::string> setupGlobalZones;
153157

154158
if (vm.count("global_zones"))
@@ -493,7 +497,11 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
493497
if (vm.count("parent_zone"))
494498
parentZoneName = vm["parent_zone"].as<std::string>();
495499

496-
std::vector<String> globalZones { "global-templates", "director-global" };
500+
std::vector<String> globalZones {};
501+
if (!vm.count("no-default-global-zones")) {
502+
globalZones = {"global-templates", "director-global"};
503+
}
504+
497505
std::vector<std::string> setupGlobalZones;
498506

499507
if (vm.count("global_zones"))

0 commit comments

Comments
 (0)