Ask Your Question
0

Having some issues/confusion regarding moving class definitions into hiera

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

Folks,

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:

 snmp::snmpd_config:
   - '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:

snmp::snmpv3_user:
      'MYUSER`:
        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?

Thanks,

Todd

edit retag flag offensive close merge delete

Comments

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 -0500 )edit

Actually, no...it 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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

Should be something like:

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

And in hiera

---
profiles::os::linux::snmp::snmp_snmpv3_users:
  'MYUSER':
    authpass: 'SomePassword'
    authtype: 'MD5'

snmp::snmpd_config:
  - 'rouser MYUSER auth'
edit flag offensive delete link more

Comments

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 -0500 )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

Stats

Asked: 2016-04-18 15:51:00 -0500

Seen: 36 times

Last updated: Apr 19 '16