Puppet class 订单中断使用定义

Puppet class orders break using defines

我对应用模块的顺序有一定程度的依赖:

class build() {
    # define order
    Class['base'] -> Class['config'] -> Class['app'] -> Class['sso']

    class { 'base' : ... }
    class { 'config' : ... }
    # etc
}

class base::init.pp () {
    class { 'base::prereqs' : ... }
    class { 'base::worker' : 
        require => Class['base::prereqs']
        ... 
    }
}

# etc etc

错误发生在base::prereqs有:

define base::prereqs::file () { ... }

class base::prereqs () {
    $files = [ 'file_name', ... ]
    base::prereqs::file { $files : }
}

所需的顺序是 base::init --> base::prereqs --> base::worker --> config::init --> config::prepreqs --> config::worker --> app::init ...

但是使用定义的实际顺序变成了...

base::init --> base::prereqs(定义中创建的资源除外)--> config::init --> config::prereqs --> . .. --> base:prepreqs (define创建的资源) --> base::worker

base中的顺序是一致的,但是order中的上层似乎不知道prereqs中已经添加了资源并认为base完整.

有什么帮助吗?

Puppet v3.6.2 (Puppet Enterprise 3.3.2)

排序关系不超越使用 includeclass { 'title': } 的常见 class 声明。

在您的场景中解决此问题的最简单方法是 contain classes.

class base {
    contain base::prereqs
    contain base::worker
    Class['base::prereqs'] -> Class['base::worker']
}