Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Exclude all hidden files
.*

icinga2.conf.d/*
!icinga2.conf.d/README.md

# Except those related to Git (and GitHub)
!.git*
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,47 @@ Icinga Web is provided on port **8080** and you can access the Icinga 2 API on p
The default user of Icinga Web is `icingaadmin` with password `icinga` and
the default user of the Icinga 2 API for Web is `icingaweb` with password `icingaweb`.

### Use with podman

Environment:
* ``podman version 4.0.2``
* ``docker-compose version 1.29.2, build 5becea4c``

Ensure you have started the podman socket and set the environment variable
````bash
systemctl enable podman.socket --now
export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock
echo "export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock" >> ~/.bashrc
````

Furthermore you need an older docker-compose version (because of compability to [podman](https://github.com/containers/podman/issues/11822)):
````bash
wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/sbin/docker-compose1.29.2
````

#### Podman Rootless

To use the container rootless, you have to create the user environent first
````bash
useradd -m -c "User for icinga containers" pod_icinga
sudo -iu pod_icinga
echo 'export XDG_RUNTIME_DIR="/run/user/$UID"' >> ~/.bashrc
echo 'export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"' >> ~/.bashrc
echo "export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock" >> ~/.bashrc
````

Enable lingering for user (**as root**). If you forget this step, the containers will be stopped if the user logs out.
````bash
loginctl enable-linger pod_icinga_cluster
````

To start the container use now the following command:
````bash
# Change directory to the git_clone
/usr/local/sbin/docker-compose1.29.2 up -d
````


## Upgrading from v1.1.0 to v1.2.0

**v1.2.0** deploys Icinga Web ≥ 2.11.0, Icinga 2 ≥ 2.13.4, Icinga DB ≥ 1.0.0 and Icinga DB Web ≥ 1.0.0.
Expand All @@ -29,3 +70,4 @@ The easiest way to upgrade is to start over, removing all the volumes and
therefore wiping out any configurations you have changed:

`docker-compose down --volumes && docker-compose build --pull && docker-compose -p icinga-playground up -d`

36 changes: 24 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
version: '3.7'

x-icingadb-redis-host: &icingadb-redis-host icingadb-redis
x-icingadb-host: &icingadb-host icingadb
x-icinga2-host: &icinga2-host icinga2
x-mysql-host: &mysql-host mysql

x-icinga-db-web-config:
&icinga-db-web-config
icingaweb.modules.icingadb.config.icingadb.resource: icingadb
icingaweb.modules.icingadb.redis.redis1.host: icingadb-redis
icingaweb.modules.icingadb.redis.redis1.host: *icingadb-redis-host
icingaweb.modules.icingadb.redis.redis1.port: 6379
icingaweb.modules.icingadb.commandtransports.icinga2.host: icinga2
icingaweb.modules.icingadb.commandtransports.icinga2.host: *icinga2-host
icingaweb.modules.icingadb.commandtransports.icinga2.port: 5665
icingaweb.modules.icingadb.commandtransports.icinga2.password: ${ICINGAWEB_ICINGA2_API_USER_PASSWORD:-icingaweb}
icingaweb.modules.icingadb.commandtransports.icinga2.transport: api
icingaweb.modules.icingadb.commandtransports.icinga2.username: icingaweb
icingaweb.resources.icingadb.charset: utf8mb4
icingaweb.resources.icingadb.db: mysql
icingaweb.resources.icingadb.dbname: icingadb
icingaweb.resources.icingadb.host: mysql
icingaweb.resources.icingadb.host: *mysql-host
icingaweb.resources.icingadb.password: ${ICINGADB_MYSQL_PASSWORD:-icingadb}
icingaweb.resources.icingadb.type: db
icingaweb.resources.icingadb.username: icingadb
Expand All @@ -22,14 +27,14 @@ x-icinga-director-config:
&icinga-director-config
icingaweb.modules.director.config.db.resource: director-mysql
icingaweb.modules.director.kickstart.config.endpoint: icinga2
icingaweb.modules.director.kickstart.config.host: icinga2
icingaweb.modules.director.kickstart.config.host: *icinga2-host
icingaweb.modules.director.kickstart.config.port: 5665
icingaweb.modules.director.kickstart.config.username: icingaweb
icingaweb.modules.director.kickstart.config.password: ${ICINGAWEB_ICINGA2_API_USER_PASSWORD:-icingaweb}
icingaweb.resources.director-mysql.charset: utf8mb4
icingaweb.resources.director-mysql.db: mysql
icingaweb.resources.director-mysql.dbname: director
icingaweb.resources.director-mysql.host: mysql
icingaweb.resources.director-mysql.host: *mysql-host
icingaweb.resources.director-mysql.password: ${ICINGA_DIRECTOR_MYSQL_PASSWORD:-director}
icingaweb.resources.director-mysql.type: db
icingaweb.resources.director-mysql.username: director
Expand All @@ -48,7 +53,7 @@ x-icinga-web-config:
icingaweb.resources.icingaweb-mysql.charset: utf8mb4
icingaweb.resources.icingaweb-mysql.db: mysql
icingaweb.resources.icingaweb-mysql.dbname: icingaweb
icingaweb.resources.icingaweb-mysql.host: mysql
icingaweb.resources.icingaweb-mysql.host: *mysql-host
icingaweb.resources.icingaweb-mysql.password: icingaweb
icingaweb.resources.icingaweb-mysql.type: db
icingaweb.resources.icingaweb-mysql.username: icingaweb
Expand All @@ -74,6 +79,7 @@ networks:

services:
director:
container_name: director
command:
- /bin/bash
- -ce
Expand Down Expand Up @@ -102,11 +108,13 @@ services:
logging: *default-logging
volumes:
- icinga2:/data
- ./icingadb.conf:/config/icingadb.conf
- ./icingaweb-api-user.conf:/config/icingaweb-api-user.conf
- ./init-icinga2.sh:/config/init-icinga2.sh
- ./icingadb.conf:/config/icingadb.conf:z
- ./icingaweb-api-user.conf:/config/icingaweb-api-user.conf:z
- ./init-icinga2.sh:/config/init-icinga2.sh:z

icinga2:
#container_name: icinga2
container_name: *icinga2-host
command: [ "sh", "-c", "sleep 5 ; icinga2 daemon" ]
depends_on:
- icingadb-redis
Expand All @@ -118,9 +126,10 @@ services:
- 5665:5665
volumes:
- icinga2:/data
- ./icinga2.conf.d:/custom_data/custom.conf.d
- ./icinga2.conf.d:/custom_data/custom.conf.d:z

icingadb:
container_name: *icingadb-host
environment:
ICINGADB_DATABASE_HOST: mysql
ICINGADB_DATABASE_PORT: 3306
Expand All @@ -136,10 +145,12 @@ services:
logging: *default-logging

icingadb-redis:
container_name: *icingadb-redis-host
image: redis
logging: *default-logging

icingaweb:
container_name: icingaweb
depends_on:
- mysql
environment:
Expand All @@ -158,6 +169,7 @@ services:
- icingaweb:/data

mysql:
container_name: *mysql-host
image: mariadb:10.7
command: --default-authentication-plugin=mysql_native_password
environment:
Expand All @@ -168,8 +180,8 @@ services:
logging: *default-logging
volumes:
- mysql:/var/lib/mysql
- ./env/mysql/:/docker-entrypoint-initdb.d/

- ./env/mysql/:/docker-entrypoint-initdb.d/:z
volumes:
icinga2:
icingaweb:
Expand Down
23 changes: 22 additions & 1 deletion init-icinga2.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

set -e
set -o pipefail

echo "Starting init-icinga2.sh script"

if [ ! -f /data/etc/icinga2/conf.d/icingaweb-api-user.conf ]; then
sed "s/\$ICINGAWEB_ICINGA2_API_USER_PASSWORD/${ICINGAWEB_ICINGA2_API_USER_PASSWORD:-icingaweb}/" /config/icingaweb-api-user.conf >/data/etc/icinga2/conf.d/icingaweb-api-user.conf
fi
Expand All @@ -11,3 +12,23 @@ if [ ! -f /data/etc/icinga2/features-enabled/icingadb.conf ]; then
mkdir -p /data/etc/icinga2/features-enabled
cat /config/icingadb.conf >/data/etc/icinga2/features-enabled/icingadb.conf
fi

optional_confd=`grep 'include_recursive "/custom_data/custom.conf.d"' /etc/icinga2/icinga2.conf`
echo $optional_confd
if [ -z "$optional_confd" ]; then
echo "Create include_recursive for custom.conf.d in icinga2.conf"
echo 'include_recursive "/custom_data/custom.conf.d"' >> /etc/icinga2/icinga2.conf
fi

rm -f /etc/icinga2/conf.d/hosts.conf

cat <<EOL > /etc/icinga2/conf.d/hosts.conf
object Host NodeName {
/* Import the default host template defined in `templates.conf`. */
import "generic-host"

/* Specify the address attributes for checks e.g. `ssh` or `http`. */
address = "127.0.0.1"
address6 = "::1"
}
EOL