diff --git a/docker-compose.yml b/docker-compose.yml index 1042ff1..2e6f6e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,9 @@ services: context: ./image-files dockerfile: Dockerfile environment: - - HOST= - - MASTERHOST= - - MASTERPORT=5665 + - CN= + - ZONE= + - PARENTHOST= + - PARENTCN= - PARENTZONE= - TICKET= diff --git a/image-files/create-satellite.sh b/image-files/create-satellite.sh index 353a7fd..8911fa8 100755 --- a/image-files/create-satellite.sh +++ b/image-files/create-satellite.sh @@ -1,19 +1,37 @@ #!/bin/bash -icinga2 pki new-cert --cn $HOST \ ---key /var/lib/icinga2/certs/${HOST}.key \ ---cert /var/lib/icinga2/certs/${HOST}.crt -icinga2 pki save-cert --key /var/lib/icinga2/certs/${HOST}.key \ ---cert /var/lib/icinga2/certs/${HOST}.crt \ ---trustedcert /var/lib/icinga2/certs/${MASTERHOST}.crt \ ---host ${MASTERHOST} +# If parent cn is not specified, default it to the parent host. +# If the zone if not specified, default it to the cn of the satellite/agent. +# Use the default port if none is specified. -icinga2 node setup --ticket $TICKET \ ---cn $HOST \ ---endpoint ${MASTERHOST},${MASTERHOST},${MASTERPORT} \ ---zone $HOST \ ---parent_zone $PARENTZONE \ ---parent_host $MASTERHOST \ ---trustedcert /var/lib/icinga2/certs/${MASTERHOST}.crt \ +if [ -z "$PARENTCN" ]; then + PARENTCN="$PARENTHOST" +fi + +if [ -z "$ZONE" ]; then + ZONE="$CN" +fi + +if [ -z "$PARENTPORT" ]; then + PARENTPORT=5665 +fi + + +icinga2 pki new-cert --cn "$CN" \ +--key /var/lib/icinga2/certs/"${CN}".key \ +--cert /var/lib/icinga2/certs/"${CN}".crt + +icinga2 pki save-cert --key /var/lib/icinga2/certs/"${CN}".key \ +--cert /var/lib/icinga2/certs/"${CN}".crt \ +--trustedcert /var/lib/icinga2/certs/"${PARENTCN}".crt \ +--host "${PARENTHOST}" + +icinga2 node setup --ticket "$TICKET" \ +--cn "$CN" \ +--endpoint "${PARENTCN}","${PARENTHOST}","${PARENTPORT}" \ +--zone "$ZONE" \ +--parent_zone "$PARENTZONE" \ +--parent_host "$PARENTHOST" \ +--trustedcert /var/lib/icinga2/certs/"${PARENTCN}".crt \ --accept-commands --accept-config \ --disable-confd