CLI: Fix updates for NodeName/ZoneName constants

fixes #7117
This commit is contained in:
Michael Friedrich 2019-05-06 10:19:56 +02:00
parent edaaaae1e8
commit 4197bc9bcd
2 changed files with 16 additions and 15 deletions

View File

@ -210,13 +210,13 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v
Utility::RenameFile(tempApiPath, apipath);
/* 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);
@ -500,13 +500,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";

View File

@ -86,7 +86,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
*/
@ -544,14 +544,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";
@ -777,8 +777,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);