0

I know how I can use resource ordering in Puppet to order built-in types (user, group, cron...) or classes, but I wonder how I can make it for specific instances of classes.

For example, I use puppetlabs/apt module and the apt::source defined type to push wheezy/updates/... apt sources. My code looks like

apt::source { 'debian_wheezy':
    location        => 'http://ftp.debian.org/debian/',
    release         => 'wheezy',
    repos           => 'main contrib non-free',
    include_src     => false,
}
apt::source { 'debian_wheezy_updates':
    location        => 'http://ftp.debian.org/debian/',
    release         => 'wheezy-updates',
    repos           => 'main contrib non-free',
    include_src     => false,
}

I want to make use of another module to configure HAProxy, but I need to define another apt::source to configure wheezy backports because haproxy is not available on the standard wheezy repository. So I want to indicate that my haproxy class depends of my apt::source type defining wheezy backports.

I have tried something naive like

Class['apt::source'] -> Class['haproxy']

but logically this does not make sense: I want to specify one specific instance of apt::source.

Do anybody knows how I can do that?

thanks

3

When you declare the haproxy class you can require it, e.g.:

class { 'haproxy':
  require => Apt::Source['debian_wheezy'],
}
  • Thanks. That works if my apt::source declaration is in my node file, but can't find how to do it if it's in a separate file (a 'profile' named profiles::apt::wheezy_backports). Any idea? – daks Apr 28 '15 at 13:52
  • That shouldn't matter. If you declare apt::source { 'whatever' you can require it via require => Apt::Source['whatever'], – faker Apr 28 '15 at 13:55
  • 1
    in fact... it works! Must have been a typo or something. thks – daks Apr 28 '15 at 14:01
0

You can put the relevant apt::source resource in it's own class. Example:

myapt:

require myapt::default
require myapt::backports

myapt::default:

apt::source { 'debian_wheezy':
    location        => 'http://ftp.debian.org/debian/',
    release         => 'wheezy',
    repos           => 'main contrib non-free',
    include_src     => false,
}
apt::source { 'debian_wheezy_updates':
    location        => 'http://ftp.debian.org/debian/',
    release         => 'wheezy-updates',
    repos           => 'main contrib non-free',
    include_src     => false,
}

myapt::backports:

apt::source { 'debian_wheezy_backports':
    location        => 'http://ftp.debian.org/debian/',
    release         => 'wheezy-backports',
    repos           => 'main contrib non-free',
    include_src     => false,
}

myhaproxy:

require myapt::backports
class { 'haproxy': }
  • I thought about creating a 'wrapper' class, but I prefer to find another solution. – daks Apr 28 '15 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.