分类: 系统运维
2015-04-01 17:41:52
# tree modules/foo
modules/foo
└── manifests
└── init.pp
$a = 'aaa',
$b = 'bbb',
$c = 'ccc',
) {
notify { "\na=${a}\nb=${b}\nc=${c} ": }
}
执行结果
# puppet apply --modulepath=modules production/production.pp
Notice: Compiled catalog for xxxx in environment production in 0.02 seconds
Notice:
a=aaa
b=bbb
c=ccc
......
Notice: Finished catalog run in 0.01 seconds.
现在来实现override参数化类的default值。
cat production/production.pp
node default {
class { foo:
a => 'tom',
b => 'jerry',
c => 'None'
}
}
结果为 :message: defined 'message' as '
a=tom
b=jerry
c=None '
现在实现create_resources的案例。
production.pp
node default {
$foo_params = { foo => { a => 'alan', b => 'bill', c => 'carl' } }
create_resources('class', $foo_params)
}
a=alan
b=bill
c=carl