summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/templates/icinga2_agent/setup_agent.sh.epp
blob: 20e2132deba524a62d74da76f19ded47d9a41d27 (plain)
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
<%-| String $pki_api_user,
     String $pki_api_password,
     String $master_host,
|-%>
#!/bin/sh

set -e

TICKET=$(/usr/bin/curl -f -s --cacert /etc/icinga2/pki/ca.crt \
  -u "<%= $pki_api_user %>:<%= $pki_api_password %>" \
  -H "Accept: application/json" \
  "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"] %>" \
--endpoint "<%= $master_host %>" \
--zone "<%= $::facts["fqdn"] %>" \
--parent_zone "<%= $master_host %>" \
--parent_host "<%= $master_host %>" \
--trustedcert "/etc/icinga2/pki/ca.crt" \
--accept-commands \
--disable-confd