On 16/04/12 21:08, puppetguest wrote:> Hi,
>
> if possible can someone post a working example please ?
>
> I am using hiera => puppet => augeas.
>
> cat myserver.yaml
> ---
> myserver:
> "Birthday": ''1''
> "Debug": ''5''
>
> The no. of settings will change, so i would like to use a hash here.
>
>
> The hiera lookup works already:
>
>> hiera -c /etc/puppet/hiera.yaml -h myserver
> {"Debug"=>"5",
"Birthday"=>"1"}
>
>
> I can save a single value via hiera => puppet => augeas sucessfully
> when i know its variable name.
>
> What i am searching for is the proper syntax to use
''hiera_hash''
> and save all settings into augeas with ''set $name $value''
coming from
> the yaml-file.
>
> In perl it would be have been like this:
> foreach $key (keys %hash){
> print "$key $hash{$key}\n";
> }
>
> Thank you
Just to jump on you before you start, Puppet has no concept of loops, so
your Perl example doesn''t translate. However, there are some other
approaches to the problem.
What would suit you best is the create_resources function:
http://docs.puppetlabs.com/references/2.7.9/function.html#createresources
Your manifest would look something like this:
******
define augeas_wrapper (key, value) {
augeas{ "some_file":
changes => [ "set $key $val" ]
}
}
$augeas_hash = hiera_hash($fqdn)
create_resources(''augeas_wrapper'', $augeas_hash)
******
Make sure that hiera_hash returns a hash in the format that
create_resources is expecting.
-Luke
--
Luke Bigum
Information Systems
Ph: +44 (0) 20 3192 2520
luke.bigum@lmax.com | http://www.lmax.com
LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN
FX and CFDs are leveraged products that can result in losses exceeding
your deposit. They are not suitable for everyone so please ensure you
fully understand the risks involved. The information in this email is not
directed at residents of the United States of America or any other
jurisdiction where trading in CFDs and/or FX is restricted or prohibited
by local laws or regulations.
The information in this email and any attachment is confidential and is
intended only for the named recipient(s). The email may not be disclosed
or used by any person other than the addressee, nor may it be copied in
any way. If you are not the intended recipient please notify the sender
immediately and delete any copies of this message. Any unauthorised
copying, disclosure or distribution of the material in this e-mail is
strictly forbidden.
LMAX operates a multilateral trading facility. Authorised and regulated
by the Financial Services Authority (firm registration number 509778) and
is registered in England and Wales (number 06505809).
Our registered address is Yellow Building, 1A Nicholas Road, London, W11
4AN.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.