FAQ
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.

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?

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.

I'm running puppet 2.6.2 on Debian Squeeze with Ruby 1.8.7.

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

Search Discussions

  • Nan Liu at Jan 19, 2013 at 8:01 pm

    On Sat, Jan 19, 2013 at 12:03 PM, royhills wrote:

    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.

    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?

    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.
    This is not an auto dependency. They are all documented in the resource
    type document by searching autorequires:
    http://docs.puppetlabs.com/references/latest/type.html

    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+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Ken Barber at Jan 19, 2013 at 8:02 pm

    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 puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Royhills at Jan 20, 2013 at 9:14 am
    Thanks for the responses. The pointer to the autorequires sections in the
    type reference is what
    I was looking for.

    It might be a good idea to add this pointer to the autorequire section in
    the docs here:
    http://docs.puppetlabs.com/learning/ordering.html

    This is what I read first, and it doesn't mention where to find out the
    details. Here's what
    it says:

    "Don’t sweat much about the details of autorequiring; it’s fairly
    conservative and should
    generally do the right thing without getting in your way. If you forget
    it’s there and make
    explicit dependencies, your code will still work."

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJan 19, '13 at 6:04p
activeJan 20, '13 at 9:14a
posts4
users3
websitepuppetlabs.com

3 users in discussion

Royhills: 2 posts Ken Barber: 1 post Nan Liu: 1 post

People

Translate

site design / logo © 2022 Grokbase