-
Notifications
You must be signed in to change notification settings - Fork 1
/
pe-show-group
executable file
·35 lines (31 loc) · 1.03 KB
/
pe-show-group
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#
# Filename: pe-show-group
# Created: Wed Jul 8 19:11:05 2015 (+1000)
# Version: 0.1.0
# Author: Ade
# Description:
# show group list/detail
# Change Log:
#
HOST=$(grep server /etc/puppetlabs/puppet/classifier.yaml|awk '{print $2}')
PORT=$(grep port /etc/puppetlabs/puppet/classifier.yaml|awk '{print $2}')
CURLCERT="--cert /etc/puppetlabs/puppet/ssl/certs/${HOST}.pem --key /etc/puppetlabs/puppet/ssl/private_keys/${HOST}.pem --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem"
ENDPOINT="https://${HOST}:${PORT}/classifier-api/v1"
case "$1" in
"-f")
sudo curl -s ${ENDPOINT}/groups -H 'Content-Type: application/json' \
${CURLCERT} | jq .
;;
"-s")
sudo curl -s ${ENDPOINT}/groups -H 'Content-Type: application/json' \
${CURLCERT} | jq '.[] | {name: .name, id: .id}'
;;
""|"-?"|"-h"|"--help")
echo "usage: $(basename $0) [-s|-f|uuid] (summary, full or specific uuid)"
;;
*)
sudo curl -s ${ENDPOINT}/groups/${1} -H 'Content-Type: application/json' \
${CURLCERT} | jq .
;;
esac