# Problem with exec behaviour

Hi,

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 {
"/var/www/lib/$lib_name": mode =>$php::folder_mode,
owner   => $php::folder_owner, group =>$php::folder_group,
ensure  => directory
}
exec {
"create-$lib_name": cwd => "/var/www/lib/$lib_name",
command => "xxx",
creates => "/var/www/lib/$lib_name/$lib_version",
}
exec {
"chown-$lib_name": cwd => "/var/www/lib", command => "chown xxx", path =>$user_path,
subscribe => Exec["create-$lib_name"], } }  Thanks in advance edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted 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.

more