Reputation: 481
I have the following two manifests:
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)
}
}
and
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'),
}
}
I want that profile::java
has completely finished before profile::maven
is executed.
The site.pp
looks as follows and should not be modified in order to comply with puppet's role-profile approach later (work in progress):
node 'gamma.localdomain' {
include 'profile::java'
include 'profile::maven'
}
After compilation the scripts starts with downloading the maven archive. Why does
require '::profile::java'
not ensure the execution order? Has someone an idea how to achieve the desired behavior?
Upvotes: 0
Views: 1437
Reputation: 488
Since at least Puppet 3.5 you can use "contain" to ensure that everything inside profile::java completes before profile::maven. The following addition to profile::java would be required:
class profile::java inherits profile::base {
...
contain '::maven::maven'
...
}
Answering this old, answered question as it comes up first when googling "puppet require does not work"
Upvotes: 1
Reputation: 8223
I believe that the problem here is that the require profile::java
is scoped to the profile::maven
class, so all resources declared in the latter class depend on profile::java
. However, this will not propagate to classes that profile::maven
declares, such as maven::maven
.
To achieve that, you can establish a dependency among those classes
include profile::java
include maven::maven
Class[profile::java] -> Class[maven::maven]
This can incur substantial complexity in the dependency graph, so be wary of that. This can be avoided using the Anchor Pattern.
Note that use of the require function is discouraged due to possible dependency cycle issues.
Upvotes: 1