Skip to content

Add check status tasks #79

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

Merged
merged 1 commit into from
Mar 30, 2020
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
13 changes: 13 additions & 0 deletions tasks/check_status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"description": "Get the status of a Puppet Service in JSON format",
"parameters": {
"service": {
"type": "Enum[all, ca, code-manager-service, file-sync-client-service,file-sync-storage-service, jruby-metrics, master,pe-jruby-metrics, pe-master, pe-puppet-profiler,puppet-profiler, status-service]",
"description": "What service to check. For example: 'all, status-service, pe-master, master, pe-jruby-metrics code-manager-service'"
}
},
"input_method": "environment",
"implementations": [
{"name": "check_status.sh"}
]
}
18 changes: 18 additions & 0 deletions tasks/check_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# For more information about what this task can return see the API
# https://puppet.com/docs/puppetserver/latest/status-api/v1/services.html
# Note: if you pass in a service name you will get only the status of that
# service.
# This task is meant to be run on the puppetserver which is why localhost
# is used as the hostname.
service=$PT_service
if [[ $service == 'all' ]]; then
out=$(curl https://localhost:8140/status/v1/services -k -s)
else
out=$(curl -k -s https://localhost:8140/status/v1/services/${service})
fi

code=$?
echo $out
exit $code