Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1067519
  • 博文数量: 186
  • 博客积分: 4939
  • 博客等级: 上校
  • 技术积分: 2075
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-08 17:15
文章分类

全部博文(186)

文章存档

2018年(1)

2017年(3)

2016年(11)

2015年(42)

2014年(21)

2013年(9)

2012年(18)

2011年(46)

2010年(35)

分类: 系统运维

2015-04-01 17:41:52


# tree modules/foo

modules/foo

└── manifests

    └── init.pp


class foo (


    $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 


具体解释 Converts a hash into a set of resources and adds them to the catalog.




阅读(1165) | 评论(0) | 转发(0) |
0

上一篇:记录Tomcat 的coredump

下一篇:Puppet Define测试

给主人留下些什么吧!~~