Ask Your Question

Some questions about r10k with hiera

asked 2016-07-16 08:33:39 -0600

nobody gravatar image

Hi all! I newbie in use puppet + hiera + r10k and i have some questions:

1) Double declarations. For example, i have 2 hiera files: puppet.local.yaml and common.yaml . In both i write

     - ntp

and, as expected, i get an error

    Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Class[Ntp] is already declared; cannot redeclare at /etc/puppetlabs/code/environments/production/site/profile/manifests/base.pp:2 at /etc/puppetlabs/code/environments/production/site/profile/manifests/base.pp:2:3 on node puppetdb.local

So, i can trace and rectify this 2 files, then clear all double declarations, but what can i do, if this files - 1000 and many more?

2) R10k modules dependings. How to install modules dependings with r10k & Puppetfile? For example, i want to install puppetdb and i write my Puppetfile for r10k:

mod 'puppetlabs/puppetdb', :latest

But it does not install any dep's

    Warning: Missing dependency 'puppetlabs-firewall':
      'puppetlabs-puppetdb' (v5.1.2) requires 'puppetlabs-firewall' (>= 1.1.3 <2.0.0)
    Warning: Missing dependency 'puppetlabs-inifile':
      'puppetlabs-puppetdb' (v5.1.2) requires 'puppetlabs-inifile' (>= 1.1.3 <2.0.0)
    Warning: Missing dependency 'puppetlabs-postgresql':
      'puppetlabs-puppetdb' (v5.1.2) requires 'puppetlabs-postgresql' (>= 4.0.0 <5.0.0)

and i dont know what it's needed. So, i can somehow say to him, what he must install puppetdb and all dependency?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-16 13:59:55 -0600

lupin gravatar image

updated 2016-07-16 14:01:03 -0600

Answer #1) No, you only need to declare a class in one place. You then adjust your Hiera hierarchy definition. For example if you have classes specific for distro and other classes common to all, the hierarachy on hiera.yaml would look like this:


and then on your <osfamily>.yaml and common.yaml will have these contents:

  - ntp

    - common_class
    - class_foo
    - class_bar

Question #2) You need to find the dependent modules and include it in your Puppetfile. Usually module will have their dependency define in metadata like this.

edit flag offensive delete link more


Just to follow up on question 2. librarian-puppet will install dependencies, as will puppet module install foo, but r10k requires you to explicitly declare all your dependencies in the Puppetfile.

DarylW gravatar imageDarylW ( 2016-07-18 22:09:23 -0600 )edit

1) yep, i know what i _must_ declare a class in only one place, but why puppet can't track and rectify, or ignore, or used "last declaration logic", or something else? If i have over 10000 manifests - it is difficult to keep track it all. 2)

nobody gravatar imagenobody ( 2016-07-19 10:02:08 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-07-16 08:33:39 -0600

Seen: 306 times

Last updated: Jul 16 '16