Skip to content

Commit

Permalink
Merge pull request #565 from treydock/fix-ipmi-sudo
Browse files Browse the repository at this point in the history
Fix IPMI exporter sudo config, add dependency on saz/sudo
  • Loading branch information
ghoneycutt authored Jun 24, 2021
2 parents 2c33272 + b7c633a commit a0d1c2e
Show file tree
Hide file tree
Showing 5 changed files with 10 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
6 changes: 2 additions & 4 deletions spec/acceptance/ipmi_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

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
# TODO: Update to newer release once > 6.0.0 is released with https://github.com/saz/puppet-sudo/pull/268
on hosts, puppet('module', 'install', 'saz-sudo', '--version', '4.1.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 a0d1c2e

Please sign in to comment.