forked from aussieade/pe-api-hacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pe-add-class
executable file
·25 lines (20 loc) · 774 Bytes
/
pe-add-class
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
#!/bin/bash
#
# Filename: pe-add-class
# Created: Wed Jul 8 19:07:26 2015 (+1000)
# Version: 0.1.0
# Author: Ade
# Description:
# adds a class to a group
# 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"
if [ $# -ne 2 ]; then
echo "usage: $(basename $0) <groupid> <class>"
exit 0
fi
sudo curl -s -X POST -H 'Content-Type: application/json' ${CURLCERT} -d \
'{ "classes": {"'$2'": {}}}' ${ENDPOINT}/groups/${1} | jq .