if (!vm.count("ticket")) {
Log(LogCritical, "cli")
<< "Please pass the ticket number generated on master\n"
- << "(Hint: 'icinga2 pki ticket --cn <masterhost> --salt <ticket_salt>').";
+ << "(Hint: 'icinga2 pki ticket --cn " << Utility::GetFQDN() << "').";
return 1;
}
return 1;
}
+ if (!vm.count("zone")) {
+ Log(LogCritical, "cli", "You need to specify the local zone (--zone).");
+ return 1;
+ }
+
String ticket = vm["ticket"].as<std::string>();
Log(LogInformation, "cli")
Log(LogInformation, "cli", "Generating zone and object configuration.");
- NodeUtility::GenerateNodeIcingaConfig(vm["endpoint"].as<std::vector<std::string> >(), cn);
+ NodeUtility::GenerateNodeIcingaConfig(vm["endpoint"].as<std::vector<std::string> >(), cn, vm["node"].as<std::string>());
/* update constants.conf with NodeName = CN */
if (cn != Utility::GetFQDN()) {
* Node Setup helpers
*/
-int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename)
+int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename, const String& zonename)
{
Array::Ptr my_config = make_shared<Array>();
static void UpdateConstant(const String& name, const String& value);
/* node setup helpers */
- static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename);
+ static int GenerateNodeIcingaConfig(const std::vector<std::string>& endpoints, const String& nodename, const String& zonename);
static int GenerateNodeMasterIcingaConfig(const String& nodename);
/* black/whitelist */
String cn = answer;
cn.Trim();
+ std::cout << "Please specifiy the local zone name [" << cn << "]: ";
+
+ std::getline(std::cin, answer);
+ boost::algorithm::to_lower(answer);
+
+ if (answer.empty())
+ answer = cn;
+
+ String local_zone = answer;
+ local_zone.Trim();
+
std::vector<std::string> endpoints;
String endpoint_buffer;
master_endpoint_name = tmp; //store the endpoint name for later
}
- std::cout << "Master endpoint port: ";
+ std::cout << "Master endpoint port (optional) []: ";
std::getline(std::cin, answer);
boost::algorithm::to_lower(answer);
endpoint_buffer += "," + answer;
}
-
endpoints.push_back(endpoint_buffer);
std::cout << "Add more master endpoints? [y/N]";
/* apilistener config */
std::cout << "Generating local zones.conf.\n";
- NodeUtility::GenerateNodeIcingaConfig(endpoints, cn);
+ NodeUtility::GenerateNodeIcingaConfig(endpoints, cn, local_zone);
if (cn != Utility::GetFQDN()) {
Log(LogWarning, "cli")