summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/templates
diff options
context:
space:
mode:
authorJan Dittberner <jandd@cacert.org>2019-07-20 20:42:38 +0200
committerJan Dittberner <jandd@cacert.org>2019-07-20 20:42:38 +0200
commit573b6e8c5af6439bef4c793c6268cf109d931541 (patch)
treecf02a8db43668ce95a0e2591e3573cd082ae471c /sitemodules/profiles/templates
parent0af14ee4e9d236f50e6682ac1abfa6d6ac87c471 (diff)
downloadcacert-puppet-573b6e8c5af6439bef4c793c6268cf109d931541.tar.gz
cacert-puppet-573b6e8c5af6439bef4c793c6268cf109d931541.tar.xz
cacert-puppet-573b6e8c5af6439bef4c793c6268cf109d931541.zip
Add missing json parsing in agent setup script
Diffstat (limited to 'sitemodules/profiles/templates')
-rw-r--r--sitemodules/profiles/templates/icinga2_agent/setup_agent.sh.epp9
1 files changed, 7 insertions, 2 deletions
diff --git a/sitemodules/profiles/templates/icinga2_agent/setup_agent.sh.epp b/sitemodules/profiles/templates/icinga2_agent/setup_agent.sh.epp
index a0fd034..c12eb62 100644
--- a/sitemodules/profiles/templates/icinga2_agent/setup_agent.sh.epp
+++ b/sitemodules/profiles/templates/icinga2_agent/setup_agent.sh.epp
@@ -5,12 +5,17 @@
|-%>
#!/bin/sh
+set -e
+
TICKET=$(/usr/bin/curl -s --cacert /etc/icinga2/pki/ca.crt \
-u "<%= $pki_api_user %>:<%= $pki_api_password %>" \
-H "Accept: application/json" \
--resolve "<%= $master_host %>:5665:<%= $master_ip %>" \
- "https://<%= $master_host %>:5665/v1/actions/generate_ticket" \
- --data '{ "cn": "<%= $::facts["fqdn"] %>" }')
+ "https://<%= $master_host %>:5665/v1/actions/generate-ticket" \
+ --data '{ "cn": "<%= $::facts["fqdn"] %>" }' | \
+ /usr/bin/python3 -c \
+ 'import json, sys;
+ print(json.load(sys.stdin)["results"][0]["ticket"])')
/usr/sbin/icinga2 node setup --ticket "${TICKET}" \
--cn "<%= $::facts["fqdn"] %>" \