FAQ
Hi,
I was thinking about a conceptual thing and I will try to explain with a
concrete example.

In the puppetlabs-lvm module
there is code like this in the logical_volume provider

if mount( '-f', '--guess-fstype', path) =~ /ext[34]/
resize2fs( path) || ...
end

The resize2fs command is in the e2fsprogs package (well it is more
complicated, but this is another topic), so this package has to be
installed or an error will thrown.

I was thinking about how to ensure that the package is installed.
I realize that I could do just

package { 'e2fsprogs': }
logical_volume { 'bla':
fs_type => 'ext3',
require => Package['e2fsprogs']
}

Is it possible to hide this dependency in the custom type?
Is it possible to include another class from within a custom type? After
the other class is included autorequire could do its job. I think it is
some kind of autoinclude that I am after.
--
Kind Regards, Markus Falb

Search Discussions

  • Jcbollinger at May 21, 2012 at 1:39 pm

    On May 20, 6:17 am, Markus Falb wrote:
    Hi,
    I was thinking about a conceptual thing and I will try to explain with a
    concrete example.

    In the puppetlabs-lvm module
    there is code like this in the logical_volume provider

    if mount( '-f', '--guess-fstype', path) =~ /ext[34]/
    resize2fs( path) || ...
    end

    The resize2fs command is in the e2fsprogs package (well it is more
    complicated, but this is another topic), so this package has to be
    installed or an error will thrown.

    I was thinking about how to ensure that the package is installed.
    I realize that I could do just

    package { 'e2fsprogs': }
    logical_volume { 'bla':
    fs_type => 'ext3',
    require => Package['e2fsprogs']

    }

    Is it possible to hide this dependency in the custom type?

    It depends on what exactly you mean by that, but the "confine"
    function in your provider code expresses providers' requirements on
    external resources. It will cause Puppet to find the provider
    unsuitable if the expressed requirements are not met.

    Is it possible to include another class from within a custom type?

    No. The native type and provider framework cannot modify the
    catalog. This is as it should be, for the type should not know the
    requirements (that's the provider's job), whereas the master does not
    know at catalog compilation time what provider will be used.

    After
    the other class is included autorequire could do its job. I think it is
    some kind of autoinclude that I am after.

    You can do something like that with a defined type, but not with a
    custom (native) type. This is the sort of problem that run stages
    were originally conceived to solve, but the idea mutated along the
    way, and the actual implementation of run stages in 2.6 and 2.7 does
    not solve it.


    John

    --
    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.
  • Stefan Schulte at May 21, 2012 at 4:26 pm

    On Sun, May 20, 2012 at 01:17:57PM +0200, Markus Falb wrote:
    Hi,
    I was thinking about a conceptual thing and I will try to explain with a
    concrete example.

    In the puppetlabs-lvm module
    there is code like this in the logical_volume provider

    if mount( '-f', '--guess-fstype', path) =~ /ext[34]/
    resize2fs( path) || ...
    end

    The resize2fs command is in the e2fsprogs package (well it is more
    complicated, but this is another topic), so this package has to be
    installed or an error will thrown.

    I was thinking about how to ensure that the package is installed.
    I realize that I could do just

    package { 'e2fsprogs': }
    logical_volume { 'bla':
    fs_type => 'ext3',
    require => Package['e2fsprogs']
    }

    Is it possible to hide this dependency in the custom type?
    The custom type "logical_volume" could specify an autorequire:

    in logical_volume.rb:

    autorequire(:package) do
    'e2fsprogs'
    end

    This way every logical_volume will depend on Package['e2fsprogs'] but
    only if such a package is present in the catalog.

    But what version of puppet are you using? Not sure if

    http://projects.puppetlabs.com/issues/6907

    already covers your case.

    -Stefan

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedMay 20, '12 at 11:18a
activeMay 21, '12 at 4:26p
posts3
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase