Re: [Puppet Users] Inter-Module Dependency

2011-02-18 Thread Felix Frank
On 02/16/2011 11:30 AM, Derek J. Balling wrote:
 For what it is worth, for an extremely well known interface like
 /etc/resolv.conf I would subscribe to the file resource, but for most
 cases I prefer to depend on the class.  So, I think both answers are
 right, and I didn't explain why I chose the apparently tighter binding
 this time around.
 
 FWIW, we've chosen to do both, if for no other reason than so that the app in 
 question won't be processed until after the resolv.conf is updated, so we 
 can minimize the number of restarts, etc., as necessary.
 
 The next issue which follows, for me, is that random_app is puppet-agent, 
 because it refuses to notice changes to resolv.conf, and has to be restarted 
 to pick them up. Likely this is because it's using its own resolver library 
 instead of the system calls, but this is a real PITA, since the only clean 
 way to restart the puppet agent, from within puppet, essentially amounts to 
 issuing `/etc/init.d/puppet restart`in the middle of a catalog-run, which 
 sucks for all the obvious reasons you would think it does.

Yes.

Ugly workaround: Schedule the restart using atd from within the catalog
run. (I've used at now+2min and it works so far).

Cheers,
Felix

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



Re: [Puppet Users] Inter-Module Dependency

2011-02-16 Thread Derek J. Balling
 For what it is worth, for an extremely well known interface like
 /etc/resolv.conf I would subscribe to the file resource, but for most
 cases I prefer to depend on the class.  So, I think both answers are
 right, and I didn't explain why I chose the apparently tighter binding
 this time around.

FWIW, we've chosen to do both, if for no other reason than so that the app in 
question won't be processed until after the resolv.conf is updated, so we can 
minimize the number of restarts, etc., as necessary.

The next issue which follows, for me, is that random_app is puppet-agent, 
because it refuses to notice changes to resolv.conf, and has to be restarted to 
pick them up. Likely this is because it's using its own resolver library 
instead of the system calls, but this is a real PITA, since the only clean 
way to restart the puppet agent, from within puppet, essentially amounts to 
issuing `/etc/init.d/puppet restart`in the middle of a catalog-run, which sucks 
for all the obvious reasons you would think it does.

D

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



[Puppet Users] Inter-Module Dependency

2011-02-15 Thread Derek J. Balling
I tried looking in the language tutorial for this, but I couldn't find a 
reference for how to do it, but I'm sure it must be possible.

So I've got two modules, one for random_app and one for dns_config. 
dns_config has a file resource resolv.conf which is just what the name 
implies.

I want service 'foo' in my random_app module to subscribe to dns_config's 
resolv.conf, and if the resolv.conf changes, to restart. (Because, it's a 
misbehaving app who doesn't just use gethostbyname() calls, but runs its own 
resolver and never looks at resolv.conf again after it starts up.)

I would have thought it'd just be subscribing the service to 
File['dns_config::resolv.conf'] but clearly that didn't work.

... Could not find dependency File[dns_config::resolv.conf] 

Any ideas on what I need to do to make that work?

Cheers,
D


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



Re: [Puppet Users] Inter-Module Dependency

2011-02-15 Thread Daniel Pittman
On Tue, Feb 15, 2011 at 11:05, Derek J. Balling dr...@megacity.org wrote:

[…]
 So I've got two modules, one for random_app and one for dns_config. 
 dns_config has a file resource resolv.conf which is just what the name 
 implies.

 I want service 'foo' in my random_app module to subscribe to dns_config's 
 resolv.conf, and if the resolv.conf changes, to restart. (Because, it's a 
 misbehaving app who doesn't just use gethostbyname() calls, but runs its own 
 resolver and never looks at resolv.conf again after it starts up.)

 I would have thought it'd just be subscribing the service to 
 File['dns_config::resolv.conf'] but clearly that didn't work.

service { foo: require = File[/etc/resolv.conf] }

That will happily cross modules, completely ignoring that boundary.
(Match the name of the file you give in the other module, obviously.
:)

Regards,
Daniel
-- 
⎋ Puppet Labs Developer – http://puppetlabs.com
✉ Daniel Pittman dan...@puppetlabs.com
✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775
♲ Made with 100 percent post-consumer electrons

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



Re: [Puppet Users] Inter-Module Dependency

2011-02-15 Thread Nan Liu
On Tue, Feb 15, 2011 at 2:09 PM, Daniel Pittman dan...@puppetlabs.com wrote:
 On Tue, Feb 15, 2011 at 11:05, Derek J. Balling dr...@megacity.org wrote:

 […]
 So I've got two modules, one for random_app and one for dns_config. 
 dns_config has a file resource resolv.conf which is just what the name 
 implies.

 I want service 'foo' in my random_app module to subscribe to dns_config's 
 resolv.conf, and if the resolv.conf changes, to restart. (Because, it's a 
 misbehaving app who doesn't just use gethostbyname() calls, but runs its own 
 resolver and never looks at resolv.conf again after it starts up.)

 I would have thought it'd just be subscribing the service to 
 File['dns_config::resolv.conf'] but clearly that didn't work.

 service { foo: require = File[/etc/resolv.conf] }

 That will happily cross modules, completely ignoring that boundary.
 (Match the name of the file you give in the other module, obviously.
 :)

You can also create class level dependency so it is less tightly
coupled to a specific resource which may benefit you in the long run
should you need to refactor dns_config class.

class random_app {
  require dns_config
  ...
}

Thanks,

Nan

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



Re: [Puppet Users] Inter-Module Dependency

2011-02-15 Thread Gabriel Filion
On 11-02-15 05:25 PM, Nan Liu wrote:
 You can also create class level dependency so it is less tightly
 coupled to a specific resource which may benefit you in the long run
 should you need to refactor dns_config class.
 
 class random_app {
   require dns_config
   ...
 }

hmm this actually binds the OP's 'random_app' module to the 'dns_config'
one while Daniel's suggestion can find the File resource even though it
is moved from one module to another.

-- 
Gabriel Filion

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



Re: [Puppet Users] Inter-Module Dependency

2011-02-15 Thread Daniel Pittman
On Tue, Feb 15, 2011 at 17:11, Gabriel Filion lelu...@gmail.com wrote:
 On 11-02-15 05:25 PM, Nan Liu wrote:
 You can also create class level dependency so it is less tightly
 coupled to a specific resource which may benefit you in the long run
 should you need to refactor dns_config class.

 class random_app {
   require dns_config
   ...
 }

 hmm this actually binds the OP's 'random_app' module to the 'dns_config'
 one while Daniel's suggestion can find the File resource even though it
 is moved from one module to another.

For what it is worth, for an extremely well known interface like
/etc/resolv.conf I would subscribe to the file resource, but for most
cases I prefer to depend on the class.  So, I think both answers are
right, and I didn't explain why I chose the apparently tighter binding
this time around.

Daniel
-- 
⎋ Puppet Labs Developer – http://puppetlabs.com
✉ Daniel Pittman dan...@puppetlabs.com
✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775
♲ Made with 100 percent post-consumer electrons

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