2014-12-13 48 views
0

我是傀儡新手,并希望避免一些常见问题,我看到并摆脱使用导入语句,因为他们被弃用。我从创建一个将文件复制到单个puppet代理的类的非常简单的任务开始。木偶类与环境目录

所以我有这样的高手:

/etc/puppet/environments/production 
/etc/puppet/environments/production/modules 
/etc/puppet/environments/production/mainfests 
/etc/puppet/environments/production/files 

我试图在一个叫nodes.pp在清单目录中的文件创建节点定义和使用,我已经定义一个类(类是test_monitor)在一个模块调用测试:

node /^web\d+.*.net/ { 
    include test_monitor 
    } 

然而,当我运行木偶-t代理人在代理我得到:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class test_monitor for server on node server 
Warning: Not using cache on failed catalog 
Error: Could not retrieve catalog; skipping run 

什么是正确的方式来配置它工作。我想在一个或多个文件中拥有节点定义,这些文件可以访问我在自定义模块中构建的类。

这里是我的puppet.conf:

[main] 
environmentpath = $confdir/environments 
default_manifest = $confdir/environments/production/manifests 
vardir=/var/lib/puppet 
ssldir=/var/lib/puppet/ssl 
factpath=$vardir/lib/facter 

[master] 
ssl_client_header = SSL_CLIENT_S_DN 
ssl_client_verify_header = SSL_CLIENT_VERIFY 

我知道这可能是一些愚蠢的事,我没有做正确或者错误配置,但我似乎无法得到它的工作。任何帮助表示赞赏!要明确我只是想保持干净,并在具有特定节点类型的单独文件中的类也存在于它们自己的文件中。我有一个小到中等大小的环境。 (约150个在数据中心的服务器)

回答

0

,那就是如添加适当的模块路径puppet.conf

basemodulepath = $confdir/environments/production/modules 
+0

这更是一个解决办法,真的。 'environmentpath'应该满足所有常规需求。 – 2014-12-14 14:16:35

+0

是的,你是对的,我已经从puppet.conf中删除了它。这就是我把课堂本身称为问题的方式。我按照上面的建议重新组织了模块目录,因为它似乎遵循傀儡文档的一般流程,并且对于这个项目有意义。然而,Hiera并不是必需的,我也没有实施这种改变。 – user1499 2014-12-14 21:25:18

1

让我猜,也许test模块有错误的结构简单。你需要文件夹下的一些子文件夹和modules

└── test 
    ├── files 
    ├── manifests 
    │   ├── init.pp 
    │   └── monitor.pp 
    └── tests 
     └── init.pp 

我建议改变从test_monitor到测试::监视,是有意义的我,如果你需要使用test_monitor,你需要一个test_monitor模块或test_monitor.pp文件。

node /^web\d+.*.net/ { 
    include test::monitor 
    } 

然后把监视的任务在monitor.pp文件

+0

我会投票,但有几点我不明白。你怎么知道OP的模块结构不合理?为什么需要Hiera?为什么这个特定的层次 – 2014-12-14 14:22:58

+0

感谢这一点,我更新了我的答案,因为我必须猜测我的经历会发生什么。 – BMW 2014-12-14 21:19:42

+0

对于你为什么需要OP来诚实地安装和配置Hiera仍然感到困惑。我同意这通常是一个好主意(我已经[有记录](https://www.packtpub.com/networking-and-servers/puppet-essentials));但它不涉及问题在我看来。 – 2014-12-15 16:12:16