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

verify whether alert_manager is running #101

Merged
merged 6 commits into from
Nov 21, 2017

Conversation

tuxmea
Copy link
Member

@tuxmea tuxmea commented Nov 1, 2017

fixes #55

@@ -0,0 +1,6 @@
Facter.add('prometheus_alert_manager_running') do
setcode do
svc_status = Facter::Core::Execution.exec('puppet resource service alert_manager | grep ensure')
Copy link
Member

Choose a reason for hiding this comment

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

do you have experience with calling puppet in a fact? Are there situations where it could deadlock? I am a bit scared that this will slow down all puppet run on each system in a environment.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just puppet resource, not puppet apply or puppet agent. I tested the fact on some systems without any difficulties. I prefer to use puppet resource service as this is generic to all platforms. We can of course confine this to only run on linux platforms.
I am happy to accept any other, more smart idea.
Besides this: I was about to change this on Monday to puppet resource --yaml service ... to allow smarter data parsing.

@bastelfreak bastelfreak added the bug Something isn't working label Nov 10, 2017
@tuxmea
Copy link
Member Author

tuxmea commented Nov 21, 2017

Tests are green (after hitting the restart job button several times). @bastelfreak @scottybrisbane @skarip please review

@@ -0,0 +1,6 @@
Facter.add('prometheus_alert_manager_running') do
setcode do
svc_status = YAML.load(Facter::Core::Execution.exec('puppet resource service alert_manager --to_yaml'))
Copy link
Member

Choose a reason for hiding this comment

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

awesome, I wasn't aware of --to_yaml takes notes

# This is here to stop the previous alertmanager that was installed in version 0.1.14
service { 'alert_manager':
ensure => 'stopped',
if $::prometheus_alert_manager_running == 'running' {
Copy link
Member

Choose a reason for hiding this comment

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

Please use the new facts hash here. $facts['prometheus_alert_manager_running']

@bastelfreak
Copy link
Member

Thanks for the PR!

@bastelfreak bastelfreak merged commit 34fdebb into voxpupuli:master Nov 21, 2017
@tuxmea tuxmea deleted the alert_manager_fresh_install branch November 21, 2017 12:55
@scottybrisbane
Copy link

Thanks for the fix @tuxmea!

cegeka-jenkins pushed a commit to cegeka/puppet-prometheus that referenced this pull request Aug 28, 2019
Rovanion pushed a commit to Rovanion/puppet-prometheus that referenced this pull request May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to use this module on fresh alert manager instances
3 participants