Hiera / YAML Hash question

25 views
Skip to first unread message

Christopher Fitchett

unread,
May 29, 2014, 3:08:53 PM5/29/14
to puppet...@googlegroups.com
Hi, I have a YAML file constructed like this:

servers:
server1:
host: 1.1.1.1
node: 1
server2:
host: 1.1.1.2
node: 2

I have an erb template that needs the node id where the it address belongs to the machine it is running on. Is there a way in ruby to select the node value the host matches a value returned from facter?

Christopher Wood

unread,
May 29, 2014, 4:59:27 PM5/29/14
to puppet...@googlegroups.com
Sounds like you want @servers[@hostname]['node'] ? If you want to match on the ip address that sounds like you'd have to loop over it or build an ip=>hostname mapping.

http://docs.puppetlabs.com/guides/templating.html#referencing-variables
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/72475b39-c846-4549-9f37-36a5995a4b93%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages