Mike Reed
2014-Oct-01 18:57 UTC
[Puppet Users] subscribe and refreshonly - expected behavior
Hello all, My thanks in advance to anybody with thoughts on this. I have a module in which I would like two resources to be applied/refreshed based on the change of their parent resource. The code looks something like this: exec {'assume_default_domain': command => "${pbis_bin_path}/config AssumeDefaultDomain true", subscribe => Exec['create_home_dir'], refreshonly => true, } exec {'user_domain_prefix': command => "${pbis_bin_path}/config UserDomainPrefix \"\" ", subscribe => Exec['assume_default_domain'], } When running a 'puppet agent -tvd' I get the following: Notice: /Stage[main]/Pbis::Config/Exec[assume_default_domain]: Triggered 'refresh' from 1 events Info: /Stage[main]/Pbis::Config/Exec[assume_default_domain]: Scheduling refresh of Exec[user_domain_prefix] Debug: /Stage[main]/Pbis::Config/Exec[assume_default_domain]: The container Class[Pbis::Config] will propagate my refresh event Debug: Exec[user_domain_prefix](provider=posix): Executing '/opt/pbis/bin/config UserDomainPrefix "" ' Debug: Executing '/opt/pbis/bin/config UserDomainPrefix "" ' Notice: /Stage[main]/Pbis::Config/Exec[user_domain_prefix]/returns: executed successfully Debug: /Stage[main]/Pbis::Config/Exec[user_domain_prefix]: The container Class[Pbis::Config] will propagate my refresh event Debug: Exec[user_domain_prefix](provider=posix): Executing '/opt/pbis/bin/config UserDomainPrefix "" ' Debug: Executing '/opt/pbis/bin/config UserDomainPrefix "" ' Notice: /Stage[main]/Pbis::Config/Exec[user_domain_prefix]: Triggered 'refresh' from 1 events Debug: /Stage[main]/Pbis::Config/Exec[user_domain_prefix]: The container Class[Pbis::Config] will propagate my refresh event Debug: Class[Pbis::Config]: The container Stage[main] will propagate my refresh event Debug: Class[Pbis::Config]: The container Class[Pbis] will propagate my refresh event Debug: Class[Pbis]: The container Stage[main] will propagate my refresh event Debug: Finishing transaction 25871380 Debug: Storing state Debug: Stored state in 0.06 seconds As you can see, the 'user_domain_prefix' resource is firing twice and I'm not sure why. If I change the resource and add a 'refreshonly', I get the desired result (resource only being applied once): exec {'user_domain_prefix': command => "${pbis_bin_path}/config UserDomainPrefix \"\" ", subscribe => Exec['assume_default_domain'], refreshonly => true, Notice: /Stage[main]/Pbis::Config/Exec[assume_default_domain]: Triggered 'refresh' from 1 events Info: /Stage[main]/Pbis::Config/Exec[assume_default_domain]: Scheduling refresh of Exec[user_domain_prefix] Debug: /Stage[main]/Pbis::Config/Exec[assume_default_domain]: The container Class[Pbis::Config] will propagate my refresh event Debug: Exec[user_domain_prefix](provider=posix): Executing '/opt/pbis/bin/config UserDomainPrefix "" ' Debug: Executing '/opt/pbis/bin/config UserDomainPrefix "" ' Notice: /Stage[main]/Pbis::Config/Exec[user_domain_prefix]: Triggered 'refresh' from 1 events Debug: /Stage[main]/Pbis::Config/Exec[user_domain_prefix]: The container Class[Pbis::Config] will propagate my refresh event Debug: Class[Pbis::Config]: The container Stage[main] will propagate my refresh event Debug: Class[Pbis::Config]: The container Class[Pbis] will propagate my refresh event Debug: Class[Pbis]: The container Stage[main] will propagate my refresh event Debug: Finishing transaction 29272600 Debug: Storing state Debug: Stored state in 0.06 seconds My understanding is that 'subscribe' will both create a dependency and will require the refreshing of the dependent object, based on the subscribed objects' state. I also understand 'refreshonly' to be a mechanism used when a dependent object is changed (sounds almost the same as subscribe except it doesn't create a dependency). Based on my example above, I would expect 'subscribe' alone to satisfy my needs and I don't understand why I get duplicate refresh events when something is simply 'subscribed' but only one refresh event when a resource is set to both 'subscribe' and 'refreshonly'. Would anybody have a quick explanation for this one? Thanks again for your help in advance. Cheers, Mike -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/adad7980-adc0-48eb-8ffa-d3b151f4a911%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.