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

Reduce configuration on agent service #711

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Sep 9, 2020

This avoids setting parameters as much as possible.

hasstatus and hasrestart have defaulted to true since Puppet 2.7 so there's no need to set those.

The systemd fact is defined as $fact['service_provider'] == 'systemd' so there's no need to set that either.

Then there's AIX left. It sets it this was because it allows users to override it in site.pp via service defaults. It now only sets the service_provider and not the path. This path is set in the provider since Puppet 4.6.0.

I didn't verify this and only did it by theory so review carefully.

@ekohl
Copy link
Member Author

ekohl commented Sep 9, 2020

@bjschafer you added AIX support in #665. Could you verify I don't break anything with this?

Copy link
Contributor

@igalic igalic left a comment

Choose a reason for hiding this comment

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

🙋🏻‍♀️

# Override the service provider on AIX
# Doing it this way allows overriding it on other platforms
if $facts['os']['name'] == 'AIX' {
Service[$servicename] { service_provider => 'init' }
Copy link
Contributor

Choose a reason for hiding this comment

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

given this documentation: https://puppet.com/docs/puppet/6.18/types/service.html#service-provider-init

true == begin
      os = Facter.value(:operatingsystem).downcase
      family = Facter.value(:osfamily).downcase
      !(os == 'debian' || os == 'ubuntu' || family == 'redhat')
  end

i'm sceptical that puppet will know the correct $service_path, so maybe let's bring this back.

Copy link
Member

Choose a reason for hiding this comment

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

I still dont get why we need to set the provider explicitly :(

Copy link
Member Author

Choose a reason for hiding this comment

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

that's why I'm hoping @bjschafer can answer that.

Copy link
Contributor

Choose a reason for hiding this comment

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

because the default service provider is src, but the zabbix package, i assume, provides an init style service file

Copy link
Member Author

Choose a reason for hiding this comment

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

I did see that, but I don't know if src can run init style service files.

@ekohl ekohl force-pushed the clean-zabbix-agent branch 2 times, most recently from 021fae4 to c473b30 Compare September 14, 2020 14:01
@igalic
Copy link
Contributor

igalic commented Sep 14, 2020

do we have anything to fix the test failures? https://travis-ci.org/github/voxpupuli/puppet-zabbix/jobs/727040802

This avoids setting parameters as much as possible.

hasstatus and hasrestart have defaulted to true since Puppet 2.7 so
there's no need to set those.

The systemd fact is defined as $fact['service_provider'] == 'systemd' so
there's no need to set that either.

Then there's AIX left. It sets it this was because it allows users to
override it in site.pp via service defaults. It now only sets the
service_provider and not the path. This path is set in the provider
since Puppet 4.6.0[1].

puppetlabs/puppet@34e45ab
@ekohl
Copy link
Member Author

ekohl commented Sep 14, 2020

That was bad code from my side. I tried to properly use that_requires (which does proper checking in the catalog) instead of with_require (that only checks the property) but made a typo.

end

it { is_expected.to contain_file(include_dir).with_ensure('directory') }
it { is_expected.to contain_zabbix__startup(service_name).with(require: "Package[#{package_name}]") }
Copy link
Member Author

Choose a reason for hiding this comment

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

This with_require style happens more often in this module. I just fixed it for this file

Copy link
Contributor

Choose a reason for hiding this comment

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

let's open an issue as reminder to do it in a next iteration

Copy link
Member

Choose a reason for hiding this comment

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

what's bad about it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Consider this code:

class myclass {
  package { 'mypackage':
  }

  file { '/etc/mypackage.conf':
    require => Package['mypackage'],
  }

  service { 'mypackage':
    subscribe => File['/etc/mypackage.conf'],
  }
}

Then the test code:

it { is_expected.not_to contain_service('mypackage').with_require('Package[mypackage]') }
it { is_expected.to contain_service('mypackage').that_requires('Package[mypackage]') }

What I'm trying to show is that one tests for a parameter on a resource and the other the relationship exists in the catalog. That takes transitive requirements into account.

@igalic
Copy link
Contributor

igalic commented Sep 18, 2020

can we merge this?

@igalic igalic merged commit 29042e9 into voxpupuli:master Sep 18, 2020
@ekohl ekohl deleted the clean-zabbix-agent branch September 18, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants