Skip to content

Instantly share code, notes, and snippets.

@benagricola
Created May 1, 2013 12:04
Show Gist options
  • Save benagricola/5494926 to your computer and use it in GitHub Desktop.
Save benagricola/5494926 to your computer and use it in GitHub Desktop.
Profiles and Roles with Hiera / Puppet 3
---
:backends:
- yaml
- gpg
:gpg:
:datadir: '/etc/puppet/hiera'
:yaml:
:datadir: '/etc/puppet/hiera'
:logger: console
:hierarchy:
- nodes/%{::clientcert}-%{calling_module}
- role/%{calling_class}
- profile/%{calling_class}
- common/%{calling_module}
- common/common
class profile {
$roles = hiera_array('profile::roles',[])
include $roles
}
class profile::puppetmaster inherits profile {}
class profile::dedicated-db inherits profile {}
---
roles:
- puppetmaster
- puppetdb
- webserver
class role {
$classes = hiera_array('role::classes',[])
include $classes
}
class role::puppetmaster inherits role {}
class role::puppetdb inherits role {}
---
role::classes:
- puppet::db
- postgresql
- psql_tools
node default {
include $::profile
}
@supriyawishesu
Copy link

Hi ,

Raw

12345 ---
roles:

  • puppetmaster
  • puppetdb
  • webserver

I don't think this is correct. one node can only have one role wright. How can you specify multiple roles in puppetmaster.yaml file

Let me know

@seanhagen
Copy link

I don't know if it's a bug with the version of Puppet ( 3.7.1 ) or Hiera ( 1.3.4 ) that I'm using, but calling_class doesn't seem to be working properly.

For example, when I set up manifests and hiera similar to what you've got here, and I assign the role 'role::puppetmaster' to a node, Hiera pulls the data from roles/role.yaml, not roles/role::puppetmaster.yaml. It seems like calling_class is the class where the hiera_* call is made, not the subclass.

@linuxdan
Copy link

Did you try module_name ?
I had better luck with it than calling_class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment