FAQ
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!!

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/eb3a0a3e-1ac4-45f6-b83b-3c1ff7f7b124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Andy Parker at Sep 13, 2014 at 12:19 am

    On Wed, Sep 10, 2014 at 12:55 PM, Juan Andres Ramirez 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

    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.
    Hi Juan,

    You can either change the format of your data to something that is
    consumable by create_resources. For example:

    sitedefinition:
       "site.one.com":
         ipaddress: "192.168.0.2"
         protocol: "http"
         port: "80"
       "site.two.com":
         ipaddress: "192.168.0.2"
         protocol: "http"
         port: "80"

    Then you use create_resources like so

    create_resources('site', $general)

    if you have a defined type like

    define site($ipaddress, $protocol, $port) {
       # make whatever resources you need here based on the parameters
    }

    You could also use the future parser and iterate across your array with
    something like:

    $general.each |$site| {
       # make whatever resources you need in here based on the $site hash
    }

    The above is broken in puppet 3.7.0, but 3.7.1 should be released soon to
    fix this.

    Thanks alot!!
    --
    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+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/puppet-users/eb3a0a3e-1ac4-45f6-b83b-3c1ff7f7b124%40googlegroups.com
    <https://groups.google.com/d/msgid/puppet-users/eb3a0a3e-1ac4-45f6-b83b-3c1ff7f7b124%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.


    --
    Andrew Parker
    andy@puppetlabs.com
    Freenode: zaphod42
    Twitter: @aparker42
    Software Developer

    *Join us at **PuppetConf 2014, **September 20-24 in San Francisco - *
    www.puppetconf.com

    --
    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+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CANhgQXuRod2HYsZtDSS%2BoNuktJbfLQ%2BWE3gEA6fjE%2BMekKgpNQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 11, '14 at 4:13a
activeSep 13, '14 at 12:19a
posts2
users2
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase