Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change - Update requirements for the snmp::client class #98

Merged
merged 1 commit into from
May 20, 2017
Merged

Change - Update requirements for the snmp::client class #98

merged 1 commit into from
May 20, 2017

Conversation

blackknight36
Copy link
Contributor

To avoid missing directory errors on Redhat based systems the net-snmp
package needs to be installed before the snmp.conf file is created.

@razorsedge razorsedge self-requested a review April 26, 2017 02:53
@razorsedge razorsedge self-assigned this Apr 26, 2017
@razorsedge razorsedge added the bug Something isn't working label Apr 26, 2017
Copy link
Contributor

@razorsedge razorsedge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the CONTRIBUTING.md file, could you please resubmit from the develop branch?

}

$req = $::osfamily ? {
'RedHat' => [Package[$snmp::params::package_name], Package['snmp-client']],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package[$snmp::params::package_name] will work so long as no one does include ::snmp::client without include ::snmp (which is completely valid).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snmp::client inherits snmp::params so it shouldn't be necessary to include ::snmp at all.

)}

it { should contain_package('snmp-client').that_comes_before('File[snmp.conf]') }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes some testing functionality. It may be better to just add to the :require below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I wanted to use $snmp::params::package_name because the package name may change in future RedHat releases but I could also just set it statically to 'net-snmp'.

I also tried updating the :require => line but that causes the automated tests to fail. If there's a way to make the spec file accept an array value then I can fix the tests to make it work.

@blackknight36 blackknight36 changed the base branch from master to develop April 26, 2017 14:11
To avoid missing directory errors on Redhat based systems the net-snmp
package needs to be installed before the snmp.conf file is created.
@blackknight36
Copy link
Contributor Author

I've rebased on the develop branch and all tests are passing now.

@razorsedge
Copy link
Contributor

@blackknight36 Will be merging this week once I page back in previous state.

@razorsedge razorsedge merged commit 0cb19ae into voxpupuli:develop May 20, 2017
}

$req = $::osfamily ? {
'RedHat' => [Package['snmp-client'], Package[$snmp::params::package_name]],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can reference this as Package['snmpd'] since it already contains the logic that you're replicating

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elisiano I considered that but I wanted to avoid hard coding the package name since it may change in the future and it's a lot easier update everything in params.pp (or hiera) when needed. IMO the first requirement should also be changed to Package[$snmp::params::client_package however I wanted to make as few changes as possible with this commit.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not hardcoded. 'snmpd' is just the name of the resource, the real package name given with the name parameter:

  package { 'snmpd':
    ensure => $package_ensure,
    name   => $package_name,
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I guess you could submit a PR to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package[$snmp::params::client_package_name] is not defined and should throw an error.

Package['snmpd'] is not defined in Class['::snmp::client'] and cannot be depended upon to exist.

Package['snmp-client'] is the only one directly declared in Class['::snmp::client']. Which makes me wonder if I am completely wrong or if the code won't work. @blackknight36, have you tested this on real systems with only class {'::snmp::client'} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@razorsedge Looks like you are correct. I've made a couple changes and submitted a new PR which should fix these issues. In the end it may be simpler to just create a file resource that ensures /etc/snmp exists. Installing the net-snmp package on systems that don't really need it is a bit of a waste.

@elisiano
Copy link

Disclaimer: I did not test this patch.
In my codebase I did the change on the init.pp. when including snmp::client I make it require the snmp package (which is defined in init.pp)

@blackknight36
Copy link
Contributor Author

I did some testing today and there were errors when a node only includes snmp::client and not the main snmp class. The snmpd package must be defined or the catalog will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants