2016-03-02 80 views
2

是否可以将hiera参数映射到另一个参数?Hiera参数映射

例如,如果在hiera中已经有一个参数“person :: shoe :: size”,并且puppet模块“other_module”需要像这样查找参数:hiera(person_shoe_size)。

是否可以告诉hiera参数“person_shoe_size”与“person :: shoe :: size”相同,hiera(person_shoe_size)实际上应该映射到hiera(person :: shoe :: size )?

回答

1

是的,你可以在你的价值内做一个hiera查找。

person::shoe::size: "7" 
person_shoe_size: "%{hiera('person::shoe::size')}" 

查找要么返回7。你也可以做这样的事情:

hostname: "cool-hostname" 
module::fully_qualified_name: "%{hiera('hostname')}.domain.tld" 

这里,fully_qualified_name参数将有cool-hostname.domain-tld值。

+0

太棒了!这正是我需要的。 – user921176

+0

徘徊如何获取数组,如果值是数组。使用上面的hiera()查找将返回字符串,而且由于某些原因,alias()不会返回任何内容。 – user921176

+0

对不起,你只能以这种方式返回一个字符串。 – daxlerod