]> granicus.if.org Git - icinga2/commitdiff
CLI: Fix updates for NodeName/ZoneName constants
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 6 May 2019 08:19:56 +0000 (10:19 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 16 May 2019 13:23:35 +0000 (15:23 +0200)
fixes #7117

(cherry picked from commit 4197bc9bcd957a1edcf5cec80a9d03fcc4b6c313)

lib/cli/nodesetupcommand.cpp
lib/cli/nodewizardcommand.cpp

index 166c8425b4a9b965173d19989581392039b16cb3..a90d10c5584b8acacceea239f813c7e495b64723 100644 (file)
@@ -236,13 +236,13 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v
        }
 
        /* update constants.conf with NodeName = CN + TicketSalt = random value */
-       if (cn != Utility::GetFQDN()) {
+       if (endpointName != Utility::GetFQDN()) {
                Log(LogWarning, "cli")
-                       << "CN '" << cn << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires update for NodeName constant in constants.conf!";
+                       << "CN/Endpoint name '" <<  endpointName << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires update for NodeName constant in constants.conf!";
        }
 
-       NodeUtility::UpdateConstant("NodeName", cn);
-       NodeUtility::UpdateConstant("ZoneName", cn);
+       NodeUtility::UpdateConstant("NodeName", endpointName);
+       NodeUtility::UpdateConstant("ZoneName", zoneName);
 
        String salt = RandomString(16);
 
@@ -536,13 +536,14 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
        NodeUtility::GenerateNodeIcingaConfig(endpointName, zoneName, parentZoneName, vm["endpoint"].as<std::vector<std::string> >(), globalZones);
 
        /* update constants.conf with NodeName = CN */
-       if (cn != Utility::GetFQDN()) {
+       if (endpointName != Utility::GetFQDN()) {
                Log(LogWarning, "cli")
-                       << "CN '" << cn << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires an update for the NodeName constant in constants.conf!";
+                       << "CN/Endpoint name '" << endpointName << "' does not match the default FQDN '"
+                       << Utility::GetFQDN() << "'. Requires an update for the NodeName constant in constants.conf!";
        }
 
-       NodeUtility::UpdateConstant("NodeName", cn);
-       NodeUtility::UpdateConstant("ZoneName", vm["zone"].as<std::string>());
+       NodeUtility::UpdateConstant("NodeName", endpointName);
+       NodeUtility::UpdateConstant("ZoneName", zoneName);
 
        if (!ticket.IsEmpty()) {
                String ticketPath = ApiListener::GetCertsDir() + "/ticket";
index ea575930592cd5ee7fa6d3701afdf1391ad72e83..b9865b2f7e7687a106de3f91bd04f3f0d88a22aa 100644 (file)
@@ -103,7 +103,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm,
         * 8. copy key information to /var/lib/icinga2/certs
         * 9. enable ApiListener feature
         * 10. generate zones.conf with endpoints and zone objects
-        * 11. set NodeName = cn in constants.conf
+        * 11. set NodeName = cn and ZoneName in constants.conf
         * 12. disable conf.d directory?
         * 13. reload icinga2, or tell the user to
         */
@@ -570,14 +570,14 @@ wizard_global_zone_loop_start:
        /* Generate node configuration. */
        NodeUtility::GenerateNodeIcingaConfig(endpointName, zoneName, parentZoneName, endpoints, globalZones);
 
-       if (cn != Utility::GetFQDN()) {
+       if (endpointName != Utility::GetFQDN()) {
                Log(LogWarning, "cli")
-                       << "CN '" << cn << "' does not match the default FQDN '"
+                       << "CN/Endpoint name '" << endpointName << "' does not match the default FQDN '"
                        << Utility::GetFQDN() << "'. Requires update for NodeName constant in constants.conf!";
        }
 
-       NodeUtility::UpdateConstant("NodeName", cn);
-       NodeUtility::UpdateConstant("ZoneName", cn);
+       NodeUtility::UpdateConstant("NodeName", endpointName);
+       NodeUtility::UpdateConstant("ZoneName", zoneName);
 
        if (!ticket.IsEmpty()) {
                String ticketPath = ApiListener::GetCertsDir() + "/ticket";
@@ -821,8 +821,8 @@ wizard_global_zone_loop_start:
 
        NodeUtility::CreateBackupFile(NodeUtility::GetConstantsConfPath());
 
-       NodeUtility::UpdateConstant("NodeName", cn);
-       NodeUtility::UpdateConstant("ZoneName", cn);
+       NodeUtility::UpdateConstant("NodeName", endpointName);
+       NodeUtility::UpdateConstant("ZoneName", zoneName);
 
        String salt = RandomString(16);