> I've seen a couple of instances where a service resource has failed with an
> error because it's
> been evaluated before its corresponding package is installed. I can fix this
> by adding an explicit
> require to the service resource, or by just running puppet again, but I
> thought that there would be
> an implicit or automatic require from a service object to the associate
> service object.
That would be nice, but alas its not true. You have to build up the
dependencies between service and package yourself.
> Here's an example class where I've seen this, although it only happens when
> I have this class
> as part of a larger overall manifest and I'm commissioning a new system.
>
> class tftp_server {
>
> package { 'tftpd-hpa':
> ensure => installed,
> }
>
> service { 'tftpd-hpa':
> ensure => running,
> enable => true,
> hasstatus => true,
> hasrestart => true,
> }
>
> file { '/srv/tftp':
> ensure => 'directory',
> owner => 'root',
> group => 'root',
> mode => '0644',
> require => Package['tftpd-hpa'],
> source => 'puppet:///modules/tftp_server/tftp',
> recurse => true,
> purge => true,
> ignore => '.svn',
> }
> }
>
> Note that there is no notify/subscribe between the file object and the
> service object. Perhaps
> that's why I get the problem?
Yes. A notify/subscribe will restart the service if the file resource
changes (good for configuration files) AND build up the ordering so
this occur in the order you desire.
> What I see is:
>
> info: Applying configuration version '1358616112'
> ...
> err: /Stage[main]/Tftp_server/Service[tftpd-hpa]: Could not evaluate: Could
> not find init script for 'tftpd-hpa'
> ...
> notice: /Stage[main]/Tftp_server/Package[tftpd-hpa]/ensure: ensure changed
> 'purged' to 'present'
> ...
>
> In http://docs.puppetlabs.com/learning/ordering.html, it says "Some of
> Puppet’s resource types will notice
> when an instance is related to other resources, and they’ll set up automatic
> dependencies", but it doesn't
> state exactly what resources this relates to. I'd expected service/package
> to be one of the examples though.
Take a look at the Type reference, and search for 'Autorequires'.
http://docs.puppetlabs.com/references/latest/type.html
The more obvious and common autorequire cases are:
* user: groups defined in the user resource
* file: creates groups and users defined in owner, group parameters first
* cron: creates users defined in the cron resource first
* package: creates file resources, if the package is being installed
from a file (as apposed to something on the network)
ken.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.