如何重用除maven之外的所有attributes部分
suites:
- name: DEV
attributes:
'ant': &ant
'version': '1.9.3'
'home': '/my/path/ant'
'maven':
'version': 3
'm2_home': '/my/path/maven'
'3':
'version': '3.2.1'
'maven_rc':
'opts': ''对于我的TESTING实例,我想继承上面所有的属性,除了maven,我想覆盖它(不同的版本):
- name: TESTING
attributes:
<<: *ant # re-use ant as it's the same configuration
'maven': # different version for TESTING
'version': 3
'm2_home': '/my/path/maven'
'3':
'version': '3.0.5'
'maven_rc':
'opts': ''发布于 2014-08-07 05:18:04
您将希望在该平台下编辑您的.kitchen.yml,以获得您希望成为通用属性的任何属性。如果您想要更改它们,那么只需将它们放在suites部分下,并使用不同的值。
platforms:
- name: ubuntu-12.04
driver_config:
box: ubuntu-12.04
run_list:
- recipe[apt::default]
attributes:
ant: &ant
version: '1.9.3'
home: '/my/path/ant'
maven:
version: 3
m2_home: '/my/path/maven'
3:
version: '3.2.1'
maven_rc:
opts: ''
suites:
- name: default
run_list:
- recipe[cookbook::default]
attributes:
- name: testing
run_list:
- recipe[cookbook::default]
attributes:
maven:
3:
version: '3.0.5'然后,您可以通过调用node['maven']['version']来访问配方中的属性,以检索当前值,该值将根据suites部分中是否被覆盖而更改。
发布于 2014-06-20 09:40:35
值得注意的是,您可以在kitchen.yml中使用Erb语法
<% my_attrs = {'foo' => 'bar'} %> suites: - name: one attributes: <%= my_attrs.to_yaml %> - name: two attributes: <%= my_attrs.merge('baz' => 'whatever').to_yaml %>
过度使用它可能很快导致无法读取的配置,但在适度的情况下,它可能是有用的。
https://stackoverflow.com/questions/23279320
复制相似问题