FAQ
Hi Puppet users,

I've been using Hiera's deep merge feature on class parameters for months,
however when I try to pair it with the create_resources function things get
ugly.

Situation:
I want to deploy a set of Unix users on all my machines. They have standard
rights by default and get access to the wheel group on a per-server basis
depending on their needs.

In my module I have:

manifests/user.pp
class environment::users ( $users = hiera_hash('user_list') {
create_resources('user', $users)
}
And in Hiera:

hiera/common.yaml
---
user_list:
foo:
ensure: present
uid: '1001'
gid: '1001'
groups: []
comment: Doctor Foo
bar:
ensure: present
uid: '1002'
gid: '1002'
groups: []
comment: Mister Bar

*It works great so far.* All my users are deployed on all machines.

Now I try to add the user foo to the wheel group on dev_server:

hiera/dev_server.example.com.yaml
---
user_list:
foo:
groups: wheel
Since the deeper
<http://docs.puppetlabs.com/hiera/1/lookup_types.html#deep-merging-in-hiera--120>
merge bahavior is enabled this should merge my user list just fine.
But... BANG! It all breaks apart:
*Error: Could not retrieve catalog from remote server: Error 400 on
SERVER: Must pass uid to User[foo] on node *

*dev_server.example.comWarning: Not using cache on failed catalogError:
Could not retrieve catalog; skipping run*
However, if I query Hiera from the shell, it returns the expected user hash:

$ hiera --hash user_list ::clientcert=dev_server.example.com
{"foo"=>
{"ensure"=>"present",
"gid"=>"1001",
"groups"=>"wheel",
"comment"=>"Mister Foo",
"uid"=>"1001"},
"bar"=>
{"ensure"=>"present",
"gid"=>"1002",
"groups"=>"[]",
"comment"=>"Doctor Bar",
"uid"=>"1002"}}

Corruption? Madness? Did I miss something crucial when reading through the
documentation?

Thank you in advance for the hints :)

*Toni*

-----------------------------------------------------------------------------------------------

Just for your information:

    - Puppet 3.6.2
    - Hiera 1.3.4
    - deep_merge gem 1.0.1

Here is my hiera.yaml file (Puppet and the command line tool use strictly
the same file)

hiera.yaml
---
:backends:
- yaml
:hierarchy:
- "%{::clientcert}"
- common
:merge_behavior: deeper
:yaml:
:datadir: /etc/puppet/hiera
--
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/59f5015d-073f-4b9b-ae89-7fb911cbf90d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Antoine Cotten at Jul 25, 2014 at 10:55 am
    *Btw, please ignore the typo (missing parenthesis) in the manifest, trust
    me it's not here in the real manifest.*

    Funny fact I just discovered: if I move the $user parameter INSIDE the code
    of the class, and get rid of the class parameter (of course) it works just
    fine. So why would the hiera_hash function not work properly when called in
    class parameters?

    --
    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/bb6c1714-88ed-4d4e-928a-f86df3e55743%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Antoine Cotten at Jul 25, 2014 at 11:14 am
    I actually found the answer in another topic
    <https://groups.google.com/forum/#!searchin/puppet-users/Puppet$203.1.1$2C$20hiera$20and$20parameter$20autoload/puppet-users/FezqytcHBeA/BC5xKG5e78cJ>
    .

    I changed my variable name to $unixusers instead of $users and it started
    working. I suspect a naming conflict within my class, since another $users
    variable was declared at a higher level.

    --
    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/ecd350c9-82b3-4e81-862c-99a031127f1c%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJul 25, '14 at 10:31a
activeJul 25, '14 at 11:14a
posts3
users1
websitepuppetlabs.com

1 user in discussion

Antoine Cotten: 3 posts

People

Translate

site design / logo © 2022 Grokbase