我知道我可以如何使用Puppet中的资源sorting来订购内置types(用户,组,cron …)或类,但是我不知道如何才能将它用于类的特定实例。
例如,我使用puppetlabs / apt模块和apt :: source定义的types来推送wheezy / updates / … apt源代码。 我的代码看起来像
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, }
我想使用另一个模块来configurationHAProxy,但是我需要定义另一个apt :: source来configurationwheezy backports,因为haproxy在标准wheezy仓库中不可用。 所以我想指出我的haproxy类依赖于我的apt :: sourcetypes来定义wheezy backports。
我曾尝试过一些天真的事情
Class['apt::source'] -> Class['haproxy']
但从逻辑上讲,这是没有意义的:我想指定一个特定的实例的apt ::源。
有谁知道我该怎么做?
谢谢
当你声明haproxy类时,你可以要求它,例如:
class { 'haproxy': require => Apt::Source['debian_wheezy'], }
你可以把相关的apt::source资源放在它自己的类中。 例:
myapt:
require myapt::default require myapt::backports
myapt ::默认:
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 ::反向移植:
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': }