我想通过Puppet设置Icinga2远程客户端,但是官方文档的整个页面都谈到了使用他们的真棒 CLI向导,这需要手动运行。
任何解决方法? 也许我应该回到Nagios?
我遇到过同样的问题。 这是我从icinga2节点向导代码中提取逻辑之后使用的。
variables您将需要:
$pki_dir - /etc/icinga2/pki in the default installation $fqdn - fully host+domain name of the client. $icinga2_master - resolvable fqdn of the master $icinga2_master_port - the port the master is connectable on. $ticket - generated on the master via 'icinga2 pki ticket --cn $fqdn'
代码:
mkdir icinga:icinga 0700 $pki_dir icinga2 pki new-cert --cn $fqdn --key $pki_dir/$fqdn.key --cert $pki_dir/$fqdn.crt icinga2 pki save-cert --key $pki_dir/$fqdn.key --cert $pki_dir/$fqdn.crt --trustedcert $pki_dir/trusted-master.crt --host $icinga2_master icinga2 pki request --host $icinga2_master --port $icinga2_master_port --ticket $ticket --key $pki_dir/$fqdn.key --cert $pki_dir/$fqdn.crt --trustedcert $pki_dir/trusted-master.crt --ca $pki_dir/ca.key icinga2 node setup --ticket $ticket --endpoint $icinga2_master --zone $fqdn --master_host $icinga2_master --trustedcert $pki_dir/trusted-master.crt systemctl restart icinga2 # or however you restart your icinga
这就像TryTryAgain写的。 最新的文档描述了两种不同的方式。 自顶向下远程命令执行和自上而下configuration同步
这种方法的不同之处在于, 远程命令执行将触发来自主机的所有命令,而configuration同步会将位于/etc/icinga2/zones.d中的所有configuration文件同步到子节点(卫星和客户机)并直接触发命令执行在端点上。
我更喜欢使用自顶向下configuration同步方法,因为即使主服务器失去与孩子的连接,客户端也会运行检查。
您必须在所有节点上启用APIfunction。
# /etc/icinga2/features-enabled/api.conf object ApiListener "api" { cert_path = "/etc/ssl/{{ hostname }}.pem" key_path = "/etc/ssl/{{ hostname }}-key.pem" ca_path = "/etc/ssl/rootca.pem" // only on satelites and clients accept_config = true }
现在创build一个区域文件并将其复制到所有节点
# /etc/icinga2/zones.conf // global zone used for zone overlapping configs object Zone "global" { global = true } // endpoints object Endpoint "fqdn1.of.host" { host = "fqdn1.of.host" } object Endpoint "fqdn2.of.host" { host = "fqdn2.of.host" } // for each endpoint one zone object Zone "fqdn1.of.host" { endpoints = [ "fqdn1.of.host" ] } object Zone "fqdn2.of.host" { endpoints = [ "fqdn2.of.host" ] parent = "fqdn1.of.host" }
最佳做法是使用节点的fqdn作为端点名称以及区域名称。 切记 :将这些zones.conf复制到所有节点。
下一步是定义/etc/icinga2/zones.d/所有服务,模板和组以及每个主机在它自己的hosts.conf里面的zone目录。
# /etc/icinga2/zones.d/global/templates.conf template Host "generic-host" { max_check_attempts = 3 check_interval = 1m retry_interval = 30s check_command = "hostalive" } # /etc/icinga2/zones.d/fqdn1.of.host/hosts.conf // this is the master object Host "fqdn1.of.host" { import "generic-host" address = "fqdn1.of.host" } # /etc/icinga2/zones.d/fqdn2.of.host/hosts.conf // this is a satelite/client object Host "fqdn2.of.host" { import "generic-host" address = "fqdn2.of.host" }
我的方法是防止使用/etc/icinga2/conf.d的configuration,因为我在/etc/icinga2/conf.d添加了所有通用(和全局使用)的东西,而在/etc/icinga2/zones.d/fqdnX.of.host中/etc/icinga2/zones.d/global了特定于主机的东西/etc/icinga2/zones.d/fqdnX.of.host
最后但并非最不重要的是,您必须删除conf.d的include语句
# /etc/icinga2/icinga2.conf [...] // include_recursive "conf.d"
而已。 此设置需要手动pipe理您的证书或使用您select的configurationpipe理。 它不会生成它,而不是使用icinga pki。 没有任何理由为什么我应该使用工具特定的pki,只要有特定的工具。