即使文件存在,Puppet class 也会丢失

Puppet class missing even when file exists

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

我不明白为什么 puppet 找不到 class。 class 在角色文件夹中。是不是目录结构错了?

编辑:

正在添加 envirnment.conf 文件的内容:

modulepath          = site:modules:$basemodulepath

这仅仅是因为模块路径需要包含site吗?您的清单在 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

我也会检查 environment.conf 中的 modulepath,以防万一。