diff --git a/.fixtures.yml b/.fixtures.yml index 1c792230d..4ad397fb5 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,3 +3,4 @@ fixtures: archive: "https://github.com/voxpupuli/puppet-archive" stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib" systemd: "https://github.com/camptocamp/puppet-systemd" + sudo: "https://github.com/saz/puppet-sudo" diff --git a/README.md b/README.md index b46052d9b..1e2679af9 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ This module supports below Prometheus architectures: - i386 - armv71 (Tested on raspberry pi 3) +The `prometheus::ipmi_exporter` class has a dependency on [saz/sudo](https://forge.puppet.com/modules/saz/sudo) Puppet module. + ## Background This module automates the install and configuration of Prometheus monitoring tool: [Prometheus web site](https://prometheus.io/docs/introduction/overview/) diff --git a/manifests/ipmi_exporter.pp b/manifests/ipmi_exporter.pp index f9bf7d89b..2b96f6f45 100644 --- a/manifests/ipmi_exporter.pp +++ b/manifests/ipmi_exporter.pp @@ -116,12 +116,9 @@ if $unprivileged { # crazy workaround from https://github.com/soundcloud/ipmi_exporter#running-as-unprivileged-user - - file { "/etc/sudoers.d/${service_name}": - owner => 'root', - group => 'root', - mode => '0440', - content => join([ + sudo::conf { $service_name: + ensure => 'present', + content => join([ "${user} ALL = NOPASSWD: /usr/sbin/ipmimonitoring", "${user} ALL = NOPASSWD: /usr/sbin/ipmi-sensors", "${user} ALL = NOPASSWD: /usr/sbin/ipmi-dcmi", @@ -130,6 +127,7 @@ "${user} ALL = NOPASSWD: /usr/sbin/ipmi-chassis", "${user} ALL = NOPASSWD: /usr/sbin/ipmi-sel", ], "\n"), + sudo_file_name => $service_name, } file { "${script_dir}/ipmi-sudo.sh": diff --git a/spec/acceptance/ipmi_exporter_spec.rb b/spec/acceptance/ipmi_exporter_spec.rb index 6baf74681..8b864d3b7 100644 --- a/spec/acceptance/ipmi_exporter_spec.rb +++ b/spec/acceptance/ipmi_exporter_spec.rb @@ -2,10 +2,7 @@ describe 'prometheus ipmi exporter' do it 'ipmi_exporter works idempotently with no errors' do - # Debian does not automatically have /etc/sudoers.d during tests - if fact('os.family') == 'Debian' - on hosts, 'mkdir -p /etc/sudoers.d' - end + on hosts, puppet('module', 'install', 'saz-rsyslog', '--version', '6.0.0') pp = 'include prometheus::ipmi_exporter' apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) diff --git a/spec/default_module_facts.yml b/spec/default_module_facts.yml index 7f14e8fc2..38d097f9e 100644 --- a/spec/default_module_facts.yml +++ b/spec/default_module_facts.yml @@ -2,3 +2,4 @@ # if a same named fact exists in facterdb it will be overridden. --- prometheus_alert_manager_running: 'stopped' +sudoversion: '1.8.23'