用puppetpipe理ssh_known_hosts

我是Puppet (开源版)的新手,有一个相对直接的问题。

当我启动一个新的主机时,我想让puppet将新主机的公共rsa密钥添加到/ etc / ssh / ssh_known_hosts中,所以更新后的ssh_known_hosts文件将被puppet代理提取。

我试过了sshkey资源:

 # /etc/puppet/modules/ssh/manifests/client.pp sshkey { $hostname: ensure => present, type => "rsa", key => $sshrsakey, } 

但是,ssh_known_hosts似乎没有在puppetmaster或代理上进行修改。 我的清单通过语法validation,当我运行puppet parser validate client.pp和运行puppet agent --test代理不报告任何问题。

为了使用sshkey资源,我必须设置Stored Configs吗? 我喜欢存储configuration的function,但它似乎是我所需要的矫枉过正,似乎增加了大量的开销。 我的另一个select是将$sshrsakey事实吐到一个file ,但是它需要检查公钥的存在,所以它不会被添加多次。

是的,您需要启用存储的configuration。

在每个主机上,您需要将密钥收集到存储的configuration数据库中(请注意@@ ):

 @@sshkey { $hostname: ensure => present, type => "rsa", key => $sshrsakey, } 

然后,您还需要将它们写入每个主机上的文件。

 Sshkey <<| |>>