Given the following example:
[root@puppet ~]# cat notify_test.pp
define test (
Boolean $condition = false,
) {
if $condition {
notify { "Debug Output of Test[${title}]": }
}
}
$test_resource_name_a = 'A'
test { $test_resource_name_a:
condition => true,
}
$test_resource_name_b = 'B'
test { $test_resource_name_b: }
exec { 'TestExec':
refreshonly => true,
command => '/usr/bin/echo "Mock Service Refresh"',
logoutput => true,
subscribe => Test[$test_resource_name_a, $test_resource_name_b],
}
Which should only print something to the agent but appearently refreshes all subscribing resources becaus of resource containment (see https://puppet.com/docs/puppet/4.10/lang_containment.html). Unwanted result:
[root@puppet ~]# puppet apply notify_test.pp
Notice: Compiled catalog for puppet in environment production in 0.10 seconds
Notice: Debug Output of Test[A]
Notice: /Stage[main]/Main/Test[A]/Notify[Debug Output of Test[A]]/message: defined 'message' as 'Debug Output of Test[A]'
Notice: /Stage[main]/Main/Exec[TestExec]/returns: Mock Service Refresh
Notice: /Stage[main]/Main/Exec[TestExec]: Triggered 'refresh' from 1 events
Notice: Applied catalog in 1.53 seconds
So whenever the condition is met (e.g. my custom function which uses an HTTP Client to get data from REST APIs which I use is my manifests but dont have real impact on the catalog compilation) all subscribers (e.g. services) would restart every 30 minutes.
This behaviour is unacceptable, so how can I print something to the puppet agent (puppet agent -t
) without notifying/refreshing auto-contained resources?