Ask Your Question

Problem with exec behaviour

asked 2014-09-26 08:52:03 -0600

wubbrubb gravatar image


I use a function to install several libraries to my VM right now. However for some reason it always executes the chown exec even when the create exec is not used (because the library is already installed).

Is my understanding of subscribe wrong? I thought the second exec will only be executed when the one subscribed to is.

define add (
$lib_version = undef,
$lib_version_prefix = undef,
$lib_name = undef,
$user_path = "/usr/bin:/usr/sbin:/bin",
file {
    mode    => $php::folder_mode,
    owner   => $php::folder_owner,
    group   => $php::folder_group,
    ensure  => directory
exec {
    cwd     => "/var/www/lib/$lib_name",
    command => "xxx",
    creates => "/var/www/lib/$lib_name/$lib_version",
exec {
    cwd => "/var/www/lib",
    command => "chown xxx",
    path => $user_path,
    subscribe => Exec["create-$lib_name"],

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-26 12:09:23 -0600

ramindk gravatar image

updated 2014-09-26 15:13:38 -0600

Your understanding of the subscribe metaparameter is indeed wrong. Subscribe only sets the relationship. You need to add refreshonly into your second Exec if you want a notify event like subscribe to trigger your Exec.

exec { "chown-${lib_name}":
    cwd         => '/var/www/lib',
    command     => 'chown xxx',
    path        => $user_path,
    subscribe   => Exec["create-${lib_name}"],
    refreshonly => true,

As a side note you should put curly braces around variables when they are within a string as I've done above. It's safer. If you're using puppet-lint, it'll catch that usage.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-09-26 08:52:03 -0600

Seen: 128 times

Last updated: Sep 26 '14