V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
JasonH
V2EX  ›  Puppet

关于 Puppet 的 include 语法的问题

  •  
  •   JasonH · Mar 19, 2013 · 5290 views
    This topic created in 4789 days ago, the information mentioned may be changed or developed.
    刚装好 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 replies    1970-01-01 08:00:00 +08:00
    ericFork
        1
    ericFork  
       Mar 20, 2013   ❤️ 1
    是,建议把这些东西写在一个文件里,比如 nodes.pp,在 site.pp 里 include nodes.pp
    JasonH
        2
    JasonH  
    OP
       Mar 20, 2013
    @ericFork 谢谢,关于 Puppet 项目的文件组织方式,能不能推荐一些比较好的 example proejct 呢?
    vvoody
        3
    vvoody  
       Mar 20, 2013
    在modulepath里的东西才能被直接include吧?
    看这个tut http://docs.puppetlabs.com/learning/modules1.html
    JasonH
        4
    JasonH  
    OP
       Mar 20, 2013
    @vvoody 我试过在 modules 下面建立这样的结构:

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

    然后在 site.pp 里 include 'nodes/*.pp' 但是错误消息还是一样的。
    goinaction
        5
    goinaction  
       Mar 20, 2013   ❤️ 3
    不应该是 import 'nodes/*.pp'吗
    JasonH
        6
    JasonH  
    OP
       Mar 20, 2013
    @goinaction 多谢。

    原来是我把 import 和 include 看成同一个东西了。低级错误。
    goinaction
        7
    goinaction  
       Mar 21, 2013
    @JasonH 刚开始很正常嘛,更详细可以看官方文档
    http://docs.puppetlabs.com/puppet/3/reference/lang_import.html
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2567 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 12:31 · PVG 20:31 · LAX 05:31 · JFK 08:31
    ♥ Do have faith in what you're doing.