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

Fix IPMI exporter sudo config, add dependency on saz/sudo #565

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'