Hi there,
Some information is missing, sorry for that, this is the correct yaml:
nodes:
host1:
ip: xxx.xxx.xxx
cdir: bbb.bbb.bbb
interface: aaa
host2:
ip: yyy.yyy.yyy
cdir: bbb.bbb.bbb
interface: aaa
This yaml is declarated on a Foreman, we use Foreman like Hiera, and it
uses for a template:
<%= @nodes[0][name] %> IPaddr2::<%= @nodes[0]['ip'] %>/<%= @nodes[0]['cidr']
%>/<%= @nodes[0]['interface'] -%>
And its defined on a manifest:
class heartbeat {
template_resources => 'site/heartbeat/resources.erb'
}
I only need the first element to apply, in this case. Thanks for the fast
answer.
Cheers
On Wednesday, 25 February 2015 15:15:50 UTC+1, LinuxDan wrote:
>
> More detail is needed to answer the question.
>
> Here are (I hope) some helpful suggestions:
>
> The data you list is a hash.
> How does one get the first "element" from a hash ?
>
> In what context are you trying to access the information ? Manifest ?
> Template ? No in Puppet at all ?
>
> One thing that caught my eye: The top-mose key of the hash is "node" while
> the template code says "nodes". That could be the problem.
>
> “Sometimes I think the surest sign that intelligent life exists elsewhere in
> the universe is that none of it has tried to contact us.” (Bill Waterson:
> Calvin & Hobbes)
>
>
> On Feb 25, 2015, at 08:52 AM, Fran Rodríguez <[email protected]
> <javascript:>> wrote:
>
> Hi group,
>
> Im trying to get one element from a yaml structure which come from
> Foreman, the yaml is like this:
>
> node :
> host1 :
> ip : xxx . xxx . xxx
> host2 :
> ip : xxx . xxx . xxx
>
>
> Those parameter are used to in a template:
>
> <%= @nodes [ 0 ][ name ] %> IPaddr2:: <%= @nodes [ 0 ][ 'ip' ] %>/ <%=
> @nodes [ 0 ][ 'cidr' ] %>/ <%= @nodes [ 0 ][ 'interface' ] - %>
>
>
>
> The question is that i only need the first parameter, i tried some ways to
> do it but without any luck, so if someone could put me on the correct way
> or tell me what i would have to do....
>
> Thanks.
>
>
> --
> 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 [email protected] <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/13ed1412-5807-424e-971e-284e588411c7%40googlegroups.com
>
> <https://groups.google.com/d/msgid/puppet-users/13ed1412-5807-424e-971e-284e588411c7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/c9398100-1076-4f40-bf2c-bc0378008534%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.