Data from Hiera

27 views
Skip to first unread message

Juan Andres Ramirez

unread,
Sep 11, 2014, 9:18:16 AM9/11/14
to puppe...@googlegroups.com
Hello,
       I have data in machine.yaml :

sitedefinition:
    - website: "site.one.com"
      ipadress: "192.168.0.2"
      protocol: "http"
      port    : "80"
    - website : "site.two.com"
      ipadress : "192.168.0.2"
      protocol : "http"
      port     : "80"

Well if I try get the data in a module in puppet I can in this way:

 $ipadress = $general[0]['ipadress']  -> this way I can get specify IP

$siteswebs = $general = hiera_array("sitedefinition")  ->  here get all the data, the result would be:
port80ipadress192.168.0.1websitesite.one.comprotocolhttpport80ipadress192.168.0.2websitesite.two.comprotocolhttp

well my question is, how can I get or how can go all the array??,
because it is possible not know how many websites exist.

Thanks alot!!

Ben Ford

unread,
Sep 17, 2014, 7:27:02 PM9/17/14
to puppe...@googlegroups.com
On Thu, Sep 11, 2014 at 6:18 AM, Juan Andres Ramirez <jandr...@gmail.com> wrote:
Hello,
       I have data in machine.yaml :

sitedefinition:
    - website: "site.one.com"
      ipadress: "192.168.0.2"
      protocol: "http"
      port    : "80"
    - website : "site.two.com"
      ipadress : "192.168.0.2"
      protocol : "http"
      port     : "80"

Well if I try get the data in a module in puppet I can in this way:

 $ipadress = $general[0]['ipadress']  -> this way I can get specify IP

$siteswebs = $general = hiera_array("sitedefinition")  ->  here get all the data, the result would be:
port80ipadress192.168.0.1websitesite.one.comprotocolhttpport80ipadress192.168.0.2websitesite.two.comprotocolhttp


This is the string representation of an array. $siteswebs is an array.

This should also be posted to puppet-users instead. This is a list for people building or extending Puppet.




well my question is, how can I get or how can go all the array??,
because it is possible not know how many websites exist.

Thanks alot!!

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/1d05d805-edfd-40a0-a651-c13aab943270%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ben Ford | Training Solutions Engineer 
Puppet Labs, Inc.
926 NW 13th Ave, Suite #210
Portland, OR 97209

509.592.7291
ben....@puppetlabs.com

Reply all
Reply to author
Forward
0 new messages