Skip to content

Commit

Permalink
Fix IPMI exporter sudo config, add dependency on saz/sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Jun 24, 2021
1 parent 2c33272 commit d62614c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
10 changes: 4 additions & 6 deletions manifests/ipmi_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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":
Expand Down
5 changes: 1 addition & 4 deletions spec/acceptance/ipmi_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/default_module_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit d62614c

Please sign in to comment.