代码之家  ›  专栏  ›  技术社区  ›  leoOrion

即使文件存在,傀儡类也会丢失。

  •  0
  • leoOrion  · 技术社区  · 7 年前

    puppet repo的目录结构如下:

    .
    |-- data
    |   |-- common.yaml
    |-- environment
    |   |-- environment.conf
    |   `-- hiera.yaml
    |-- files
    |   `-- cdn
    |-- hiera
    |   `-- hiera.yaml
    |-- hiera.global.yaml
    |-- manifests
    |   `-- site.pp
    |-- modules
    |   
    `-- site
        |-- profile
        |   |-- files
        |   `-- manifests
        |       |-- appliance
        |       |   |-- base.pp
        `-- role
            `-- manifests
                |-- README.md
                `-- role1
                    `-- appliance.pp
    

    site.pp文件如下:

    File { backup => false }
    
    
    if $::custom_facts['appliance_type'] == 'Delivery' {
      include role::role0::app
    }
    
    if $::custom_facts['appliance_type'] == 'Appliance' {
      include role::role1::appliance **// line where error is occuring**
    }
    
    node default {
    }
    

    当我运行puppet apply命令时失败,出现以下错误:

    Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::role::role1::appliance for default-puppetmaster-centos-7.vagrantup.com (file: /tmp/kitchen/manifests/site.pp, line: 9, column: 3) on node default-puppetmaster-centos-7.vagrantup.com

    应用的puppet命令:

    sudo -E /opt/puppetlabs/bin/puppet apply /tmp/kitchen/manifests/site.pp --modulepath=/tmp/kitchen/modules --fileserverconfig=/tmp/kitchen/fileserver.conf --environment=kitchen_vagrant_puppet --environmentpath=/etc/puppetlabs/code/environments --hiera_config=/tmp/kitchen/hiera.global.yaml

    我搞不懂木偶为什么找不到这个班。类位于角色文件夹中。目录结构是否错误?

    编辑:

    添加的内容 envirnment.conf 文件:

    modulepath          = site:modules:$basemodulepath
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Jon    7 年前

    这仅仅是因为modulepath需要包括 site ? 你的清单在 网站 而不是 modules .

    sudo -E /opt/puppetlabs/bin/puppet apply /tmp/kitchen/manifests/site.pp \
        --modulepath=/tmp/kitchen/modules:/tmp/kitchen/site \
        --fileserverconfig=/tmp/kitchen/fileserver.conf \
        --environment=kitchen_vagrant_puppet \
        --environmentpath=/etc/puppetlabs/code/environments \
        --hiera_config=/tmp/kitchen/hiera.global.yaml
    

    我查一下 modulepath 在里面 environment.conf 也是,以防万一。