我在一个虚拟主机上安装了木偶,以便进行试驾。 我正在使用epel 2.6.18的最新版本。 为简单起见,此testing安装将使服务器和客户端在同一个系统上运行。
安装木偶后,我跑了puppet master --mkusers用户启动服务器。 都好。
–configtest显示我的模块目录是默认的/etc/puppet/modules文件夹。
我创build了文件夹结构/ etc / puppet / modules / ntp / manifests /,然后创build一个ntp.pp文件,如下所示:
class ntp { package {'ntp': ensure => present } service {'ntp': ensure => running, } } include ntp
发布puppet --parseonly /etc/puppet/modules/ntp/manifests/ntp.pp返回干净。 没有错误。
接下来,我发问
puppet agent --test --server=`hostname
回去吧
info: Caching catalog for localhost.localdomain info: Applying configuration version '1256130640' notice: Finished catalog run in 1.23 seconds
我已经确认ntp没有通过rpm -qa ntp检查来安装
发布puppet --configprint all确认上面的模块path。
我究竟做错了什么?
您没有使用正确的文件结构和命名约定,以便Puppet自动加载器正确地查找和应用您的模块清单。 您的ntp.pp应该被称为init.pp并且您的服务器应该有一个include ntp的节点定义。
意思是你应该有这样的目录结构:
$ tree /etc/puppet /etc/puppet ├── manifests │ └── site.pp └── modules └── ntp └── manifests └── init.pp
site.pp :
# cat /etc/puppet/manifests/site.pp node somenode { include 'ntp' }
init.pp :
# cat /etc/puppet/modules/ntp/manifests/init.pp class ntp { package { 'ntp': ensure => present } service { 'ntp': ensure => running } }
之后,你的puppet agent --test运行应该如你puppet agent --test 。
您的下一站是Learning Puppet学习文档: http : //docs.puppetlabs.com/learning/index.html
编辑:请注意,木偶2.6.18是古老的,很久以前就已经结束了。 即使木偶2.7.x将于10月1日到达EOL。 如果你使用Puppet进行testing,请使用当前的Puppet 3.2.x系列。 每个主要操作系统和发行版都可以使用软件包,对于RHEL / CentOS,请参阅http://yum.puppetlabs.com/ 。