Perhaps make it a defined type and use the create resources function. I 
can't really think of any other way to correctly scope the various 
parameters. You'd have to tweak your yaml slightly...

---
#icecast
type: vanilla

          icecast_clients: 

  client1:
    cid: 999
    cid_hostname: icecast1
    cid_ipaddress: 192.168.254.12
    password: WhatYoSay?
    port: 200
    concurrency: 50
    num_encoders: 2
  client2:
    cid: 998
    cid_hostname: icecast2
    cid_ipaddress: 192.168.254.13
    password: NoWay!
    port: 201
    concurrency: 25
    num_encoders: 3



define icecast_client($cid, $cid_hostname, $cid_ipaddress, $password, 
$port, $concurrency, num_encoders) {
  file { "/home/icecast/${cid}.icecast.xml":
    ensure => file,
    content => template('icecast/icecast.xml.erb'),
  }
}

$icecast_clients = hiera('icecast_clients')
create_resources(icecast_client, $icecast_clients)

You could use hiera_hash if you wanted to merge multiple levels of your 
hierarchy.
You could also use the cid in place of client1, client2, etc, then you 
could remove the $cid parameter in the defined type and just use $title.

On Friday, September 27, 2013 11:52:09 AM UTC-7, Greg Coit wrote:
>
> Hi all,
>
> I've started testing with using Hiera for storing configs and I have a 
> noobish question.
>
> Here's an example of my yaml file (/etc/puppet/hieradata/vertname.yaml):
>
> ---
> #icecast
> type: vanilla
> client1:
>   cid: 999
>   cid_hostname: icecast1
>   cid_ipaddress: 192.168.254.12
>   password: WhatYoSay?
>   port: 200
>   concurrency: 50
>   num_encoders: 2
> client2:
>   cid: 998
>   cid_hostname: icecast2
>   cid_ipaddress: 192.168.254.13
>   password: NoWay!
>   port: 201
>   concurrency: 25
>   num_encoders: 3
>
>
> Now, I'd like to be able to create a config file for each client:
>
> file { '/home/icecast/${cid}.icecast.xml':
>   ensure  => file
>   content => template('icecast/icecast.xml.erb'),
> }
>
>
> The question is how do I put the above into a loop which iterates over the 
> client arrays in the hiera file (each client config file should get a 
> unique cid, cid_hostname, etc)?
>
> Thanks in advance!!
>
> Greg
>
>
>

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to