Thanks for the reply.
I didn't understand what you are trying to say.
The code is something like this:
$array_inputs = []
$vm_data.each |$region| {
$hash_region = {
location => $region['location'],
vm_list => $region['vmlist'],
customer_id => "customer-${$region['location']}",
api_key => "api-${$region['location']}",
secret_key => "secret-${$region['location']}",
}
$array_inputs << $hash_region
}
return $array_inputs
}
I'm not able to add a new hash into the array after every iteration.
Can you please provide some resolution for this.
Thanks in advance
Raghuram Baisani
On Thursday, August 27, 2020 at 3:12:11 AM UTC+5:30 [email protected]
wrote:
> Hi Raghu,
>
> Yes this is possible. Your example looks workable, but don't forget to add
> commas after the values of the hash.
>
> Check out Puppet's 'reduce' function, it iterates over data and allows you
> to return a new structure after all the iteration which could be your new
> hash. Alternatively it might be worth writing something in Ruby if Puppet's
> immutable variables get in the way which may happen if you're heavily
> modifying your hash.
>
> On Thu, 27 Aug 2020, 3:45 am Raghu Ram Baisani, <[email protected]>
> wrote:
>
>> Hi Guys
>>
>> Some one help me solving this issue.
>> *Example:*
>> [
>> {
>> name => raghuram,
>> age => 22
>> },
>> {
>> name => vinay
>> age => 25
>> }
>> ]
>> the idea is to iterate through an existing hash and create new hash with
>> some modifications and add it to array.
>> Thanks in advance
>>
>> --
>> 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/32ee1353-0cd3-47fa-af66-c3ef976dcdean%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/puppet-users/32ee1353-0cd3-47fa-af66-c3ef976dcdean%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
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/79f3b6f2-bb70-492b-9818-6f35322c4573n%40googlegroups.com.