[Puppet Users] map/reduce local variables

2019-06-05 Thread Albert Shih
Hi


I try to write a code to delete some key inside a hash. So I got this


  $_dataset = reduce($dataset.map |$key, $value| { {$key => 
delete($value,['remove_key1','remove_key2','remove_key3'])} }) | $result, 
$value | { deep_merge($result, $value)}

so if

  $dataset = {
name1 => {
  attr1 =>
  attr2 =>
  remove_key1 =>
  remove_key2 =>
  remove_key3 =>
  attr3 =>
  }
  }

it will end up

  $_dataset = {
name1 => {
  attr1 =>
  attr2 =>
  attr3 =>
  }
  }

So it's working.

But why this *not* working ?

class  (
  Optional[Hash] $remove_key = ['remove_key1','remove_key2','remove_key3'],
  )
  {

  $_dataset = reduce($dataset.map |$key, $value| { {$key => 
delete($value,$remove_key)} }) | $result, $value | { deep_merge($result, 
$value)}

  }

The problem are some key will be remove, some other not. I'm unable to
understand the difference or find out why it delete some key (event not in
the remove_key array), and keep some other.

Regards.






--
Albert SHIH
DIO bātiment 15
Observatoire de Paris
xmpp: j...@obspm.fr
Heure local/Local time:
Wed 05 Jun 2019 04:57:36 PM CEST

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20190605150914.GA7441%40io.chezmoi.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: [ACTION] Changes to release package links

2019-06-05 Thread Michael Watters
Hello,

I see the puppetlabs-release-pc1 package is available on yum.puppetlabs.com 
however it doesn't actually show as an available update when running "yum 
update".

For example, here's the output on one of our servers.

```
[root@server1 yum.repos.d]# yum update puppetlabs-release-pc1
Loaded plugins: auto-update-debuginfo, fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
 * elrepo: reflector.westga.edu
 * epel-debuginfo: mirror.uic.edu
No packages marked for update
```

I *was* able to update the package using the rpm command directly however 
I'd like to avoid doing this on hundreds of nodes.


On Tuesday, June 4, 2019 at 12:37:21 PM UTC-4, Molly Waggett wrote:
>
> Hi all,
>
> We have enabled repositories on release-archives.puppet.com.
>
> If you're using Puppet 3, install the puppet-archives-release-* packages.
> If you're using Puppet 4, install the puppetlabs-release-pc1-* packages.
>
> We do not yet have a timeline for when these packages will be re-archived 
> from the main {yum,apt}.puppet.com sites, but we'll let you know when we 
> do. 
> Nonetheless, we recommend switching to these archive repositories as soon 
> as possible.
>
> Thanks for bearing with us!
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/71411a67-f71e-47df-8e6e-915cebcc6e2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: [ACTION] Changes to release package links

2019-06-05 Thread Molly Waggett
Hi Michael,

The puppetlabs-release-pc1 packages on yum.puppetlabs.com are the ones we
plan to re-archive. You will need to install new release packages from
http://release-archives.puppet.com/yum/ if you want to continue using the
PC1 repository. Neither of these repos will receive future updates.

If you have additional questions, please let me know!

On Wed, Jun 5, 2019 at 10:36 AM Michael Watters  wrote:

> Hello,
>
> I see the puppetlabs-release-pc1 package is available on
> yum.puppetlabs.com however it doesn't actually show as an available
> update when running "yum update".
>
> For example, here's the output on one of our servers.
>
> ```
> [root@server1 yum.repos.d]# yum update puppetlabs-release-pc1
> Loaded plugins: auto-update-debuginfo, fastestmirror, langpacks,
> versionlock
> Loading mirror speeds from cached hostfile
>  * elrepo: reflector.westga.edu
>  * epel-debuginfo: mirror.uic.edu
> No packages marked for update
> ```
>
> I *was* able to update the package using the rpm command directly however
> I'd like to avoid doing this on hundreds of nodes.
>
>
> On Tuesday, June 4, 2019 at 12:37:21 PM UTC-4, Molly Waggett wrote:
>>
>> Hi all,
>>
>> We have enabled repositories on release-archives.puppet.com.
>>
>> If you're using Puppet 3, install the puppet-archives-release-* packages.
>> If you're using Puppet 4, install the puppetlabs-release-pc1-* packages.
>>
>> We do not yet have a timeline for when these packages will be re-archived
>> from the main {yum,apt}.puppet.com sites, but we'll let you know when we
>> do.
>> Nonetheless, we recommend switching to these archive repositories as soon
>> as possible.
>>
>> Thanks for bearing with us!
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/71411a67-f71e-47df-8e6e-915cebcc6e2b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Molly Waggett*
she/her/hers
Release Engineer @ Puppet, Inc.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAFOE68CGTA%2B0Rt%3DMN2Hzicq4-m%2BOc4SROUmHE8Pne7LFQRuTiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] map/reduce local variables

2019-06-05 Thread chengkai liang
I believed you made thing overly complicated. You only have one hash table,
and try to remove the entries that has remove_ of it. Not sure why you need
to use reduce and map. You can use `each` to go through first key of the
hash table, then use filter to filter out unwanted keys like,

# this class is use to setup owner and group
class reduce_test {
  $hash = {
attribute1 => 1,
attribute2 => 2,
attribute3 => 3,
remove1=> 4,
remove2=> 5,
attribute4 => 6,
attribute5 => 7,
  }
  notice("hash table => ${hash}")
  $h = $hash.filter | $items | {
$items[0] !~ /^remove/
  }
  notice("hash table after filtering out 'remove*' key = ${h}")
}

For the each part, I will left for you to figure out.

-CK

On Wed, Jun 5, 2019 at 8:09 AM Albert Shih  wrote:

> Hi
>
>
> I try to write a code to delete some key inside a hash. So I got this
>
>
>   $_dataset = reduce($dataset.map |$key, $value| { {$key =>
> delete($value,['remove_key1','remove_key2','remove_key3'])} }) | $result,
> $value | { deep_merge($result, $value)}
>
> so if
>
>   $dataset = {
> name1 => {
>   attr1 =>
>   attr2 =>
>   remove_key1 =>
>   remove_key2 =>
>   remove_key3 =>
>   attr3 =>
>   }
>   }
>
> it will end up
>
>   $_dataset = {
> name1 => {
>   attr1 =>
>   attr2 =>
>   attr3 =>
>   }
>   }
>
> So it's working.
>
> But why this *not* working ?
>
> class  (
>   Optional[Hash] $remove_key = ['remove_key1','remove_key2','remove_key3'],
>   )
>   {
>
>   $_dataset = reduce($dataset.map |$key, $value| { {$key =>
> delete($value,$remove_key)} }) | $result, $value | { deep_merge($result,
> $value)}
>
>   }
>
> The problem are some key will be remove, some other not. I'm unable to
> understand the difference or find out why it delete some key (event not in
> the remove_key array), and keep some other.
>
> Regards.
>
>
>
>
>
>
> --
> Albert SHIH
> DIO bātiment 15
> Observatoire de Paris
> xmpp: j...@obspm.fr
> Heure local/Local time:
> Wed 05 Jun 2019 04:57:36 PM CEST
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/20190605150914.GA7441%40io.chezmoi.fr
> .
> For more options, visit https://groups.google.com/d/optout.
>

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