├── .gitignore ├── README.md ├── docker-compose.yml ├── env └── mysql │ └── init-mysql.sh ├── icinga2.conf.d └── README.md ├── icingadb.conf ├── icingaweb-api-user.conf └── init-icinga2.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Exclude all hidden files 2 | .* 3 | 4 | # Except those related to Git (and GitHub) 5 | !.git* 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-compose Icinga stack 2 | 3 | docker-compose configuration to start-up an Icinga stack containing 4 | Icinga 2, Icinga Web 2 and Icinga DB. 5 | 6 | Ensure you have the latest Docker and docker-compose versions and 7 | then just run `docker-compose -p icinga-playground up` in order to start the Icinga stack. 8 | 9 | Icinga Web is provided on port **8080** and you can access the Icinga 2 API on port **5665**. 10 | The default user of Icinga Web is `icingaadmin` with password `icinga` and 11 | the default user of the Icinga 2 API for Web is `icingaweb` with password `icingaweb`. 12 | 13 | ## Upgrading from v1.1.0 to v1.2.0 14 | 15 | **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. 16 | The Icinga Director is also set up and its daemon started, all in a separate container. 17 | 18 | The easiest way to upgrade is to start over, removing all the volumes and 19 | therefore wiping out any configurations you have changed: 20 | 21 | `docker-compose -p icinga-playground down --volumes && docker-compose pull && docker-compose -p icinga-playground up --build -d` 22 | 23 | 24 | ## Upgrading from v1.0.0 to v1.1.0 25 | 26 | **v1.1.0** deploys Icinga Web 2.9.0 and snapshots of Icinga 2, Icinga DB and Icinga DB Web. 27 | 28 | The easiest way to upgrade is to start over, removing all the volumes and 29 | therefore wiping out any configurations you have changed: 30 | 31 | `docker-compose down --volumes && docker-compose build --pull && docker-compose -p icinga-playground up -d` 32 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | x-icinga-db-web-config: 4 | &icinga-db-web-config 5 | icingaweb.modules.icingadb.config.icingadb.resource: icingadb 6 | icingaweb.modules.icingadb.redis.redis1.host: icingadb-redis 7 | icingaweb.modules.icingadb.redis.redis1.port: 6379 8 | icingaweb.modules.icingadb.commandtransports.icinga2.host: icinga2 9 | icingaweb.modules.icingadb.commandtransports.icinga2.port: 5665 10 | icingaweb.modules.icingadb.commandtransports.icinga2.password: ${ICINGAWEB_ICINGA2_API_USER_PASSWORD:-icingaweb} 11 | icingaweb.modules.icingadb.commandtransports.icinga2.transport: api 12 | icingaweb.modules.icingadb.commandtransports.icinga2.username: icingaweb 13 | icingaweb.resources.icingadb.charset: utf8mb4 14 | icingaweb.resources.icingadb.db: mysql 15 | icingaweb.resources.icingadb.dbname: icingadb 16 | icingaweb.resources.icingadb.host: mysql 17 | icingaweb.resources.icingadb.password: ${ICINGADB_MYSQL_PASSWORD:-icingadb} 18 | icingaweb.resources.icingadb.type: db 19 | icingaweb.resources.icingadb.username: icingadb 20 | 21 | x-icinga-director-config: 22 | &icinga-director-config 23 | icingaweb.modules.director.config.db.resource: director-mysql 24 | icingaweb.modules.director.kickstart.config.endpoint: icinga2 25 | icingaweb.modules.director.kickstart.config.host: icinga2 26 | icingaweb.modules.director.kickstart.config.port: 5665 27 | icingaweb.modules.director.kickstart.config.username: icingaweb 28 | icingaweb.modules.director.kickstart.config.password: ${ICINGAWEB_ICINGA2_API_USER_PASSWORD:-icingaweb} 29 | icingaweb.resources.director-mysql.charset: utf8mb4 30 | icingaweb.resources.director-mysql.db: mysql 31 | icingaweb.resources.director-mysql.dbname: director 32 | icingaweb.resources.director-mysql.host: mysql 33 | icingaweb.resources.director-mysql.password: ${ICINGA_DIRECTOR_MYSQL_PASSWORD:-director} 34 | icingaweb.resources.director-mysql.type: db 35 | icingaweb.resources.director-mysql.username: director 36 | 37 | x-icinga-web-config: 38 | &icinga-web-config 39 | icingaweb.authentication.icingaweb2.backend: db 40 | icingaweb.authentication.icingaweb2.resource: icingaweb-mysql 41 | icingaweb.config.global.config_backend: db 42 | icingaweb.config.global.config_resource: icingaweb-mysql 43 | icingaweb.config.global.module_path: /usr/share/icingaweb2/modules 44 | icingaweb.config.logging.log: php 45 | icingaweb.groups.icingaweb2.backend: db 46 | icingaweb.groups.icingaweb2.resource: icingaweb-mysql 47 | icingaweb.passwords.icingaweb2.icingaadmin: icinga 48 | icingaweb.resources.icingaweb-mysql.charset: utf8mb4 49 | icingaweb.resources.icingaweb-mysql.db: mysql 50 | icingaweb.resources.icingaweb-mysql.dbname: icingaweb 51 | icingaweb.resources.icingaweb-mysql.host: mysql 52 | icingaweb.resources.icingaweb-mysql.password: icingaweb 53 | icingaweb.resources.icingaweb-mysql.type: db 54 | icingaweb.resources.icingaweb-mysql.username: icingaweb 55 | icingaweb.roles.Administrators.groups: Administrators 56 | icingaweb.roles.Administrators.permissions: '*' 57 | icingaweb.roles.Administrators.users: icingaadmin 58 | 59 | x-icinga2-environment: 60 | &icinga2-environment 61 | ICINGA_CN: icinga2 62 | ICINGA_MASTER: 1 63 | 64 | x-logging: 65 | &default-logging 66 | driver: "json-file" 67 | options: 68 | max-file: "10" 69 | max-size: "1M" 70 | 71 | networks: 72 | default: 73 | name: icinga-playground 74 | 75 | services: 76 | director: 77 | command: 78 | - /bin/bash 79 | - -ce 80 | - | 81 | echo "Testing the database connection. Container could restart." 82 | (echo > /dev/tcp/mysql/3306) >/dev/null 2>&1 83 | echo "Testing the Icinga 2 API connection. Container could restart." 84 | (echo > /dev/tcp/icinga2/5665) >/dev/null 2>&1 85 | icingacli director migration run 86 | (icingacli director kickstart required && icingacli director kickstart run && icingacli director config deploy) || true 87 | echo "Starting Icinga Director daemon." 88 | icingacli director daemon run 89 | entrypoint: [] 90 | logging: *default-logging 91 | image: icinga/icingaweb2 92 | restart: on-failure 93 | volumes: 94 | - icingaweb:/data 95 | 96 | # The Icinga 2 docker image does not support configuration via env vars at the moment. 97 | # So, we have to ship some configs with this little init container. Referenced in depends_on of the icinga2 service. 98 | init-icinga2: 99 | command: [ "/config/init-icinga2.sh" ] 100 | environment: *icinga2-environment 101 | image: icinga/icinga2 102 | logging: *default-logging 103 | volumes: 104 | - icinga2:/data 105 | - ./icingadb.conf:/config/icingadb.conf 106 | - ./icingaweb-api-user.conf:/config/icingaweb-api-user.conf 107 | - ./init-icinga2.sh:/config/init-icinga2.sh 108 | 109 | icinga2: 110 | command: [ "sh", "-c", "sleep 5 ; icinga2 daemon" ] 111 | depends_on: 112 | - icingadb-redis 113 | - init-icinga2 114 | environment: *icinga2-environment 115 | image: icinga/icinga2 116 | logging: *default-logging 117 | ports: 118 | - 5665:5665 119 | volumes: 120 | - icinga2:/data 121 | - ./icinga2.conf.d:/custom_data/custom.conf.d 122 | 123 | icingadb: 124 | environment: 125 | ICINGADB_DATABASE_HOST: mysql 126 | ICINGADB_DATABASE_PORT: 3306 127 | ICINGADB_DATABASE_DATABASE: icingadb 128 | ICINGADB_DATABASE_USER: icingadb 129 | ICINGADB_DATABASE_PASSWORD: ${ICINGADB_MYSQL_PASSWORD:-icingadb} 130 | ICINGADB_REDIS_HOST: icingadb-redis 131 | ICINGADB_REDIS_PORT: 6379 132 | depends_on: 133 | - mysql 134 | - icingadb-redis 135 | image: icinga/icingadb 136 | logging: *default-logging 137 | 138 | icingadb-redis: 139 | image: redis 140 | logging: *default-logging 141 | 142 | icingaweb: 143 | depends_on: 144 | - mysql 145 | environment: 146 | icingaweb.enabledModules: director, icingadb, incubator 147 | <<: [*icinga-db-web-config, *icinga-director-config, *icinga-web-config] 148 | logging: *default-logging 149 | image: icinga/icingaweb2 150 | ports: 151 | - 8080:8080 152 | # Restart Icinga Web container automatically since we have to wait for the database to be ready. 153 | # Please note that this needs a more sophisticated solution. 154 | restart: on-failure 155 | volumes: 156 | - icingaweb:/data 157 | 158 | mysql: 159 | image: mariadb:10.7 160 | command: --default-authentication-plugin=mysql_native_password 161 | environment: 162 | MYSQL_RANDOM_ROOT_PASSWORD: 1 163 | ICINGADB_MYSQL_PASSWORD: ${ICINGADB_MYSQL_PASSWORD:-icingadb} 164 | ICINGAWEB_MYSQL_PASSWORD: ${ICINGAWEB_MYSQL_PASSWORD:-icingaweb} 165 | ICINGA_DIRECTOR_MYSQL_PASSWORD: ${ICINGA_DIRECTOR_MYSQL_PASSWORD:-director} 166 | logging: *default-logging 167 | volumes: 168 | - mysql:/var/lib/mysql 169 | - ./env/mysql/:/docker-entrypoint-initdb.d/ 170 | 171 | volumes: 172 | icinga2: 173 | icingaweb: 174 | mysql: 175 | -------------------------------------------------------------------------------- /env/mysql/init-mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | create_database_and_user() { 4 | DB=$1 5 | USER=$2 6 | PASSWORD=$3 7 | 8 | mysql --user root --password=$MYSQL_ROOT_PASSWORD </data/etc/icinga2/conf.d/icingaweb-api-user.conf 8 | fi 9 | 10 | if [ ! -f /data/etc/icinga2/features-enabled/icingadb.conf ]; then 11 | mkdir -p /data/etc/icinga2/features-enabled 12 | cat /config/icingadb.conf >/data/etc/icinga2/features-enabled/icingadb.conf 13 | fi 14 | --------------------------------------------------------------------------------