More and better variables, and general clean-up
This commit is contained in:
parent
6b24c3daac
commit
ae8244fde7
@ -8,6 +8,7 @@ RUN printf "deb http://packages.icinga.com/ubuntu icinga-bionic main\ndeb-src ht
|
|||||||
chown -R nagios:nagios /var/lib/icinga2/certs
|
chown -R nagios:nagios /var/lib/icinga2/certs
|
||||||
|
|
||||||
COPY create-satellite.sh /create-satellite.sh
|
COPY create-satellite.sh /create-satellite.sh
|
||||||
RUN chmod +x /create-satellite.sh
|
COPY run-icinga.sh /run-icinga.sh
|
||||||
|
RUN chmod +x /create-satellite.sh ; chmod +x /run-icinga.sh
|
||||||
|
|
||||||
CMD /create-satellite.sh ; /usr/sbin/icinga2 daemon
|
ENTRYPOINT ["/run-icinga.sh"]
|
55
README.md
Normal file
55
README.md
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# icinga-satellite
|
||||||
|
An easy-to-use Dockerized Icinga2 satellite setup. It could be used as an
|
||||||
|
Icinga2 agent aswell, but I don't think that would make much sense. The goal
|
||||||
|
is instead to create an easy-to-deploy satellite Docker.
|
||||||
|
|
||||||
|
## Environment variables
|
||||||
|
Everything is controlled using the follwing environment variables.
|
||||||
|
|
||||||
|
* **CN** is the Common Name of the satellite
|
||||||
|
* **ZONE** is the Zone name in which the satellite is. If no zone is specified
|
||||||
|
it defaults to using the **CN** as the zone.
|
||||||
|
* **PARENTCN** is the Common Name of the parent host, for example the master. If
|
||||||
|
no **PARENTCN** is specified it defaults to using the **PARENTHOST** as a
|
||||||
|
**PARENTCN**
|
||||||
|
* **PARENTHOST** is the FQDN or IP of the parent host, for example the master.
|
||||||
|
* **PARENTPORT** is the Icinga2 port on the parent host. Defaults to 5665.
|
||||||
|
* **TICKET** is the ticket you get from the master (if you are using Director
|
||||||
|
you find it under the Agent tab of the host).
|
||||||
|
* **ACCEPT_CONFIG** takes a *y* or *n* value for yes or no. The default is
|
||||||
|
*n*(o).
|
||||||
|
* **ACCEPT_COMMANDS** takes a *y* or *n* value for yes or no. The default is
|
||||||
|
*n*(o).
|
||||||
|
* **DISABLE_CONFD** takes a *y* or *n* value for yes or no. The default is
|
||||||
|
*y*(es). This should be a sane default for most people.
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
```
|
||||||
|
#> docker run -d --name my-icinga-sat \
|
||||||
|
-e CN=icinga-sat02.local \
|
||||||
|
-e PARENTHOST=icinga-master.local \
|
||||||
|
-e PARENTCN=icinga-master.local \
|
||||||
|
-e PARENTZONE=master \
|
||||||
|
-e TICKET=124de0573705d1133db62a974aaf \
|
||||||
|
-e DISABLE_CONFD=y -e ACCEPT_CONFIG=y -e ACCEPT_COMMANDS=y \
|
||||||
|
jackbenny/icinga-satellite
|
||||||
|
```
|
||||||
|
|
||||||
|
## docker-compose.yml example
|
||||||
|
```
|
||||||
|
version: "3.8"
|
||||||
|
services:
|
||||||
|
my-icinga-sat:
|
||||||
|
image: jackbenny/icinga-satellite
|
||||||
|
environment:
|
||||||
|
- CN=icinga-sat02.local
|
||||||
|
- ZONE=icinga-sat02.local
|
||||||
|
- PARENTHOST=icinga-master.local
|
||||||
|
- PARENTCN=icinga-master.local
|
||||||
|
- PARENTZONE=master
|
||||||
|
- TICKET=124de0573705d1133db62a974aaf
|
||||||
|
- ACCEPT_CONFIG=y
|
||||||
|
- ACCEPT_COMMANDS=y
|
||||||
|
- DISABLE_CONFD=y
|
||||||
|
```
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# If parent cn is not specified, default it to the parent host.
|
# 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.
|
# If the zone if not specified, default it to the CN of the satellite/agent.
|
||||||
# Use the default port if none is specified.
|
# Use the default port if none is specified.
|
||||||
|
|
||||||
if [ -z "$PARENTCN" ]; then
|
if [ -z "$PARENTCN" ]; then
|
||||||
@ -16,6 +16,26 @@ if [ -z "$PARENTPORT" ]; then
|
|||||||
PARENTPORT=5665
|
PARENTPORT=5665
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set accept config and accept commands (defaults to no)
|
||||||
|
if [ "$ACCEPT_CONFIG" == "y" ]; then
|
||||||
|
ACCEPT_CONF="--accept-config"
|
||||||
|
else
|
||||||
|
ACCEPT_CONF=" "
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ACCEPT_COMMANDS" == "y" ]; then
|
||||||
|
ACCEPT_COMM="--accept-commands"
|
||||||
|
else
|
||||||
|
ACCEPT_COMM=" "
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Defaults to disable conf.d (so to "n" or anything else to enable inclusion of
|
||||||
|
# conf.d directory
|
||||||
|
if [ -z "$DISABLE_CONFD" ] || [ "$DISABLE_CONFD" == "y" ]; then
|
||||||
|
DISABLE_CONF="--disable-confd"
|
||||||
|
else
|
||||||
|
DISABLE_CONF=" "
|
||||||
|
fi
|
||||||
|
|
||||||
icinga2 pki new-cert --cn "$CN" \
|
icinga2 pki new-cert --cn "$CN" \
|
||||||
--key /var/lib/icinga2/certs/"${CN}".key \
|
--key /var/lib/icinga2/certs/"${CN}".key \
|
||||||
@ -33,5 +53,6 @@ icinga2 node setup --ticket "$TICKET" \
|
|||||||
--parent_zone "$PARENTZONE" \
|
--parent_zone "$PARENTZONE" \
|
||||||
--parent_host "$PARENTHOST" \
|
--parent_host "$PARENTHOST" \
|
||||||
--trustedcert /var/lib/icinga2/certs/"${PARENTCN}".crt \
|
--trustedcert /var/lib/icinga2/certs/"${PARENTCN}".crt \
|
||||||
--accept-commands --accept-config \
|
$ACCEPT_CONF \
|
||||||
--disable-confd
|
$ACCEPT_COMM \
|
||||||
|
$DISABLE_CONF
|
@ -1,14 +0,0 @@
|
|||||||
version: "3.8"
|
|
||||||
services:
|
|
||||||
|
|
||||||
icinga:
|
|
||||||
build:
|
|
||||||
context: ./image-files
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
environment:
|
|
||||||
- CN=
|
|
||||||
- ZONE=
|
|
||||||
- PARENTHOST=
|
|
||||||
- PARENTCN=
|
|
||||||
- PARENTZONE=
|
|
||||||
- TICKET=
|
|
3
run-icinga.sh
Executable file
3
run-icinga.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
/create-satellite.sh
|
||||||
|
/usr/sbin/icinga2 daemon
|
Loading…
x
Reference in New Issue
Block a user