关于 Puppet 的 include 语法的问题

2013-03-19 23:39:09 +08:00
 JasonH
刚装好 Puppet Enterprise,然后在 /etc/puppetlabs/puppet/manifests 下建了 nodes 目录,里面是每个 node 的 definition,然后在 site.pp 里 include 'nodes/*.pp',但是配置失败,在 node 上用 puppet agent -t 看到的错误输出是:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class nodes/*.pp for node01 at /etc/puppetlabs/puppet/manifests/site.pp:93 on node node01
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run

include 语法是不能这样用么?
4341 次点击
所在节点    Puppet
7 条回复
ericFork
2013-03-20 00:55:20 +08:00
是,建议把这些东西写在一个文件里,比如 nodes.pp,在 site.pp 里 include nodes.pp
JasonH
2013-03-20 01:17:34 +08:00
@ericFork 谢谢,关于 Puppet 项目的文件组织方式,能不能推荐一些比较好的 example proejct 呢?
vvoody
2013-03-20 03:28:00 +08:00
在modulepath里的东西才能被直接include吧?
看这个tut http://docs.puppetlabs.com/learning/modules1.html
JasonH
2013-03-20 12:41:44 +08:00
@vvoody 我试过在 modules 下面建立这样的结构:

- modules:
-- nodes:
--- node01.pp
--- node02.pp

然后在 site.pp 里 include 'nodes/*.pp' 但是错误消息还是一样的。
goinaction
2013-03-20 14:18:09 +08:00
不应该是 import 'nodes/*.pp'吗
JasonH
2013-03-20 17:53:44 +08:00
@goinaction 多谢。

原来是我把 import 和 include 看成同一个东西了。低级错误。
goinaction
2013-03-21 16:34:18 +08:00
@JasonH 刚开始很正常嘛,更详细可以看官方文档
http://docs.puppetlabs.com/puppet/3/reference/lang_import.html

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/63467

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX