有没有更好的格式化我的hiera数据的方法?
我想避免出现“两次编写所有内容”的问题。
这是我现在所拥有的:
[root@puppet-el7-001 ~]# cat example.yaml
---
controller_ips:
- 10.0.0.51
- 10.0.0.52
- 10.0.0.53
controller::horizon_cache_server_ip:
- 10.0.0.51:11211
- 10.0.0.52:11211
- 10.0.0.53:11211
我想知道hiera中是否有像Perl的map函数一样可用的功能。
如果是这样,那么我可以做类似的事情:
controller::horizon_cache_server_ip: "%{hiera_map( {"$_:11211"}, %{hiera('controller_ips')})}"
谢谢
最佳答案
突变是一个问题。借助YAML的引用功能,使用相同的数据更简单。
controller_ips: &CONTROLLERS
- 10.0.0.51
- 10.0.0.52
- 10.0.0.53
controller::horizon_cache_server_ip: *CONTROLLERS
您将需要更多逻辑,以便可以独立存储端口。
controller::horizon_cache_server_port: 11211
清单的结构必须允许您将IP与端口组合在一起。
关于puppet - 如何避免在Hiera数据中“两次写入所有内容”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30084576/