Discussion:
[Puppet Users] file / notify / exec / subscribe
Arnau Bria
2008-11-18 10:00:19 UTC
Permalink
Hi all,

Hi have something like:

file { "/opt/localconf/gLite3.1/yaim":
ensure => directory,
recurse => "true",
owner => "root",
group => "root",
mode => "755",
source => "puppet://gridinstall01.pic.es/files/opt/localconf/gLite3.1/yaim",
notify => Exec["yaim_conf"],
}

exec { "yaim_conf":
command => "/opt/glite/yaim/bin/yaim -c -s /opt/localconf/gLite3.1/yaim/pic/site-info.def -n glite-WN",
subscribe => File["/opt/localconf/gLite3.1/yaim"],
timeout => "-1",
}

And I'm trying to run yaim_conf ONLY if something changes in
files /opt/localconf/gLite3.1/yaim.

In the example I have notify and subscribe, but I've been playing with
only one, with only the other and both, and ALWAYS exec "yaim_conf" is
executed.
subscribe

One or more objects that this object depends on. Changes in the subscribed to objects result in the dependent objects being refreshed (e.g., a service will get restarted). For instance:
[...]
Currently the exec, mount and service type support refreshing.

SO exec should work, am I wrong?


notify

This parameter is the opposite of subscribe -- it sends events to the specified object:
[...]
This will restart the sshd service if the sshd config file changes.

It only talks about services, but is exec also supported?


**When doing something like:
notify => Service[sshd],
it di not work, I had to change to service[sshd] (notice no capital
letter in Services)... which is the correct syntax?



TIA,
Arnau

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-11-18 10:22:40 UTC
Permalink
Hi
Post by Arnau Bria
[...]
[...]
Currently the exec, mount and service type support refreshing.
SO exec should work, am I wrong?
it does. However exec execs every time puppet runs, unless you specify
certain conditions. Like unless, onlyif or refreshonly.

And the latter is what you want. From:
http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec

"refreshonly

The command should only be run as a refresh mechanism for when a
dependent object is changed. It only makes sense to use this option when
this command depends on some other object;"

and afterwards exactly the example you'd like to do is listed.

greets pete

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Arnau Bria
2008-11-18 10:36:05 UTC
Permalink
On Tue, 18 Nov 2008 11:22:40 +0100
Post by Peter Meier
Hi
[...]
Post by Peter Meier
it does. However exec execs every time puppet runs, unless you specify
certain conditions. Like unless, onlyif or refreshonly.
Ok, I tried to define a unless condition, but I had no good ideas for
that (it's not as easy as rpm -qa|grep whatever)...
Post by Peter Meier
http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec
"refreshonly
The command should only be run as a refresh mechanism for when a
dependent object is changed. It only makes sense to use this option
when this command depends on some other object;"
and afterwards exactly the example you'd like to do is listed.
Works fine!



Thanks Pete, too much doc in few days, I mix parameters from diff
types! :-)

Sorry for not seeing that in type ref.
Post by Peter Meier
greets pete
Cheers,
Arnau

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Thomas Bellman
2008-11-18 10:32:32 UTC
Permalink
Post by Arnau Bria
In the example I have notify and subscribe, but I've been playing with
only one, with only the other and both, and ALWAYS exec "yaim_conf" is
executed.
You are missing the refreshonly parameter to the exec type.

(Nice to see other LCG sites using Puppet, by the way. :-)
Post by Arnau Bria
notify => Service[sshd],
it di not work, I had to change to service[sshd] (notice no capital
letter in Services)... which is the correct syntax?
The correct syntax is with a capital letter. I get a warning message
when I try with a lower case letter:

warning: Deprecation notice: Resource references should now be
capitalized on line 6 in file /home/bellman/puppet/TEST/test.pp

What version of Puppet are you using?


/Bellman

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Arnau Bria
2008-11-18 11:15:43 UTC
Permalink
On Tue, 18 Nov 2008 11:32:32 +0100
Post by Thomas Bellman
Post by Arnau Bria
In the example I have notify and subscribe, but I've been playing
with only one, with only the other and both, and ALWAYS exec
"yaim_conf" is executed.
You are missing the refreshonly parameter to the exec type.
(Nice to see other LCG sites using Puppet, by the way. :-)
We're trying.
Do you have all your worker nodes under puppet? other services? any wiki
I could take a look?

Maybe we could contact off-list.
Post by Thomas Bellman
The correct syntax is with a capital letter. I get a warning message
warning: Deprecation notice: Resource references should now be
capitalized on line 6 in file /home/bellman/puppet/TEST/test.pp
What version of Puppet are you using?
# rpm -qa|grep puppet
puppet-0.24.5-1.el4.x86_64

I've been playing with ssh and it only worked with "service":
I'll double-check.
Post by Thomas Bellman
/Bellman
Arnau

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...