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

Exporters: Reload service if user has changed attributes #474

Merged
merged 1 commit into from
Jul 21, 2020
Merged
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
8 changes: 8 additions & 0 deletions manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,19 @@
}
}
if $manage_user {
# if we manage the service, we need to reload it if our user changes
# important for cases where another group gets added
if $manage_service {
$notify = $notify_service
} else {
$notify = undef
}
Comment on lines +140 to +144
Copy link
Member

Choose a reason for hiding this comment

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

Untested, but wouldn't it be better to use:

if $manage_service {
  User[$user] ~> $notify_service
}

Copy link
Member Author

Choose a reason for hiding this comment

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

mhm, that could work as well

Copy link
Member Author

Choose a reason for hiding this comment

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

# lid  bird-exporter
 bird(gid=484)
 bird6(gid=483)
 bird-exporter(gid=482)
# usermod -G bird-exporter bird-exporter
# lid  bird-exporter
 bird-exporter(gid=482)
# puppet agent -t --environment testenv
Info: Using configured environment 'testenv'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for testnode
Info: Applying configuration version '1595330160'
Notice: /Stage[main]/Prometheus::Bird_exporter/Prometheus::Daemon[bird_exporter]/User[bird-exporter]/groups: groups changed bird-exporter to ['bird', 'bird-exporter', 'bird6'] (corrective)
Info: /Stage[main]/Prometheus::Bird_exporter/Prometheus::Daemon[bird_exporter]/User[bird-exporter]: Scheduling refresh of Service[bird_exporter]
Notice: /Stage[main]/Prometheus::Bird_exporter/Prometheus::Daemon[bird_exporter]/Service[bird_exporter]: Triggered 'refresh' from 1 event
Notice: Applied catalog in 42.21 seconds
#

I will create a PR

ensure_resource('user', [ $user ], {
ensure => 'present',
system => true,
groups => $extra_groups,
shell => $usershell,
notify => $notify,
})

if $manage_group {
Expand Down