Skip to content

Commit 8916d5f

Browse files
authored
Merge pull request #79 from nwops/check_status
Add check status tasks
2 parents ebcec2d + 2c2fd0f commit 8916d5f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tasks/check_status.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"description": "Get the status of a Puppet Service in JSON format",
3+
"parameters": {
4+
"service": {
5+
"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]",
6+
"description": "What service to check. For example: 'all, status-service, pe-master, master, pe-jruby-metrics code-manager-service'"
7+
}
8+
},
9+
"input_method": "environment",
10+
"implementations": [
11+
{"name": "check_status.sh"}
12+
]
13+
}

tasks/check_status.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# For more information about what this task can return see the API
4+
# https://puppet.com/docs/puppetserver/latest/status-api/v1/services.html
5+
# Note: if you pass in a service name you will get only the status of that
6+
# service.
7+
# This task is meant to be run on the puppetserver which is why localhost
8+
# is used as the hostname.
9+
service=$PT_service
10+
if [[ $service == 'all' ]]; then
11+
out=$(curl https://localhost:8140/status/v1/services -k -s)
12+
else
13+
out=$(curl -k -s https://localhost:8140/status/v1/services/${service})
14+
fi
15+
16+
code=$?
17+
echo $out
18+
exit $code

0 commit comments

Comments
 (0)