2014-06-26 42 views
0

我有以下两个清单不工作:木偶 “规定” 如预期

class profile::maven inherits profile::base { 
    # Hiera 
    $version = hiera('profile::maven::version', '3.2.1') 
    $settings = hiera_hash('profile::maven::settings', undef) 
    $environments = hiera_hash('profile::maven::environments', undef) 

    # Dependencies 
    require '::profile::java' 

    # Modules 
    class { '::maven::maven': 
    version => $version, 
    } 

    if ($settings) { 
    create_resources('::maven::settings', $settings) 
    } 

    if ($environments) { 
    create_resources('::maven::environments', $environments) 
    } 
} 

class profile::java inherits profile::base { 
    # Hiera 
    $distribution = hiera('profile::java::distribution', 'jdk') 
    $version = hiera('profile::java::version', 'present') 

    # Modules 
    class { '::java': 
    distribution => $distribution, 
    version  => $version, 
    } 

    # Parameters 
    $java_home = $::java::java_home 

    file { 'profile-script:java.sh': 
    ensure => present, 
    path => '/etc/profile.d/java.sh', 
    content => template('profile/java.sh.erb'), 
    } 

}

我要被执行profile::maven之前profile::java已经完全结束。

site.pp如下所示,不应该以符合木偶的角色的配置方式后(工作正在进行中)进行修改:

node 'gamma.localdomain' { 
    include 'profile::java' 
    include 'profile::maven' 
} 

编译后的脚本开始与下载Maven的档案。为什么

require '::profile::java' 

不确保执行顺序?有人有一个想法如何实现预期的行为?

回答

1

我认为,这里的问题是,require profile::java的作用范围是profile::maven类,所以所有资源在后一类中声明取决于profile::java。但是,这不会传播到profile::maven声明的类,例如maven::maven

要实现这一点,你可以建立这些类

include profile::java 
include maven::maven 

Class[profile::java] -> Class[maven::maven] 

之间的依赖这可以依赖图中蒙受重大复杂,所以要警惕这一点。这可以通过使用Anchor Pattern来避免。

请注意,使用require函数是discouraged due to possible dependency cycle issues

0

由于至少Puppet 3.5可以使用“contain”来确保profile :: java内的所有内容在profile :: maven之前完成。下面对个人资料:: java的将需要:

class profile::java inherits profile::base { 
    ... 
    contain '::maven::maven' 
    ... 
} 

回答这个时候,回答的问题,因为它谷歌搜索“傀儡要求不起作用”

当第一次出现