Hiera Defined Types + MongoDB Module?

asked 2017-05-04 19:57:02 -0500

mikachewie gravatar image

I might be a bit confused about how Hiera works with defined types...

    - mongodb::service
    - mongodb::client

So here's where I start getting confused. I haven't had issues with Apache, which is similar.

In the puppetlabs module for MongoDB: https://forge.puppet.com/puppetlabs/m...

There is a mongodb::db defined type, that normally would look like the following:

mongodb::db { 'testdb':
  user          => 'user1',
  password_hash => 'a15fbfca5e3a758be80ceaf42458bcd8',

So in Hiera, I thought it would look like the following:

      user: 'user1'
      password: 'plaintextmaybe'

However-- the above doesn't work. I'm confused, because the $user and $password variables arein the mongodb::db class, so shouldn't they be getting picked up that I've called the mongodb::db?

edit retag flag offensive close merge delete


Are you using Hiera as an ENC (e.g. by using hiera_include)?

smarlow gravatar imagesmarlow ( 2017-05-05 10:52:18 -0500 )edit

@smarlow Yes. My workaround thus far is that I used profile/roles, so I created a MongoDB profile and then do the hiera lookup for "changeable" data from there. I just don't think that's right though, I feel like I must be doing something wrong with my Puppet DSL -> Hiera "translation" :( ...

mikachewie gravatar imagemikachewie ( 2017-05-05 13:22:08 -0500 )edit

Actually, that's how I would suggest going about things. hiera_include can only apply classes, so you need classes to contain other resources like files, users, defines, etc. I'd say definitely have profiles to contain those things, and either have roles or profiles applied via hiera_include.

smarlow gravatar imagesmarlow ( 2017-05-05 14:09:58 -0500 )edit