V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
JasonH
V2EX  ›  Puppet

关于 Puppet 的 include 语法的问题

  •  
  •   JasonH · 2013-03-19 23:39:09 +08:00 · 4312 次点击
    这是一个创建于 4027 天前的主题,其中的信息可能已经有所发展或是发生改变。
    刚装好 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 语法是不能这样用么?
    7 条回复    1970-01-01 08:00:00 +08:00
    ericFork
        1
    ericFork  
       2013-03-20 00:55:20 +08:00   ❤️ 1
    是,建议把这些东西写在一个文件里,比如 nodes.pp,在 site.pp 里 include nodes.pp
    JasonH
        2
    JasonH  
    OP
       2013-03-20 01:17:34 +08:00
    @ericFork 谢谢,关于 Puppet 项目的文件组织方式,能不能推荐一些比较好的 example proejct 呢?
    vvoody
        3
    vvoody  
       2013-03-20 03:28:00 +08:00
    在modulepath里的东西才能被直接include吧?
    看这个tut http://docs.puppetlabs.com/learning/modules1.html
    JasonH
        4
    JasonH  
    OP
       2013-03-20 12:41:44 +08:00
    @vvoody 我试过在 modules 下面建立这样的结构:

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

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

    原来是我把 import 和 include 看成同一个东西了。低级错误。
    goinaction
        7
    goinaction  
       2013-03-21 16:34:18 +08:00
    @JasonH 刚开始很正常嘛,更详细可以看官方文档
    http://docs.puppetlabs.com/puppet/3/reference/lang_import.html
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5317 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:15 · PVG 15:15 · LAX 00:15 · JFK 03:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.