Ask Your Question

Having some issues/confusion regarding moving class definitions into hiera

asked 2016-04-18 15:51:00 -0600


I am having some confusion regarding 'moving' class definitions into hiera.

I am using the razorsedge/snmp module, and I am able to use it successfully by specifiying the following as class defnitions:

# SNMP Configuration
class profiles::os::linux::snmp {
  snmp::snmpv3_user { 'MYUSER':
    authpass => 'SomePassword',
    authtype => 'MD5',
  class { 'snmp':
    snmpd_config => [ 'rouser MYUSER auth' ],

It is my understanding that I can move this into hieradata, which would be ideal.

However, it seems that the only portion of the above code that I can successfully implement in hiera is:

   - 'rouser MYUSER auth'

The /var/snmpd/snmpd.config file contains the new line after a puppet agent run.

But, I cannot seem to implement the rest of it. If I do this:

        authpass: 'SomePassword'
        authtype: 'MD5'

it doesn't seem to work. I never get a new user named "MYUSER"

So here are my questions:

  • Am I doing this correctly?
  • Is it a valid assumption that module defintions can always be defined in hiera instead?



edit retag flag offensive close merge delete


is the above a literal copy/paste? You have a backtick (`) to the right of MYUSER instead of a single quote (')

DarylW gravatar imageDarylW ( 2016-04-20 07:56:07 -0600 )edit

Actually, is NOT a literal copy/paste. I was typing it over. Thanks for noticing. :-)

todd.seidenberg gravatar imagetodd.seidenberg ( 2016-04-20 09:10:55 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-19 03:28:40 -0600

Should be something like:

class profiles::os::linux::snmp (
) {
  include snmp
  create_resources(snmp::snmpv3_user, $snmp_snmpv3_users)

And in hiera

    authpass: 'SomePassword'
    authtype: 'MD5'

  - 'rouser MYUSER auth'
edit flag offensive delete link more


Using Alex's method is more explicit, you are tying your class definition to this profile, instead of simply using Automatic Parameter Lookup to place the values in the class.

DarylW gravatar imageDarylW ( 2016-04-20 07:57:53 -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-04-18 15:51:00 -0600

Seen: 50 times

Last updated: Apr 19 '16