[Any suggestions on a better title are welcome]
For better or worse, I currently have a data structure like so (yaml)
servers:
server1.example.com:
private_ip: 10.0.0.1
public_ip: 22.33.44.1
server2.example.com:
private_ip: 10.0.0.2
public_ip: 22.33.44.2
global_roles:
nagios:
- server1
- server2
I can pull that into puppet and do things like:
$nagios_monitor = $global_roles['nagios'][0]
$private_ip["${nagios_monitor}.example.com"]['private_ip']
What I want is a way to get an array of the private IPs for all listed nagios servers. Is there a good way to do this with my existing data structure?
If the data structure needs to be changed, for this to work nicely, suggestions on a good way to present this data to puppet are also welcome. I suspect such a change would make life generally easier, but there's a fair bit of existing code that would need to changed, and I really wouldn't want any mis-steps.
Yes, there's a map function in puppet. https://docs.puppet.com/puppet/latest/reference/function.html#map
Something like this might be what you want to do:
It requires the future parser on 3.8 and is automatically included as of 4.0.