Skip to content

Commit

Permalink
Add role Icinga Web 2 (#161)
Browse files Browse the repository at this point in the history
* adds local/vagrant/vbox test scenario

* adds role icingaweb2

* Adds IcingaDB-Web support (#159)

* provides generic module configuration

* adds docu and remove examples

* removes python2 unittests

* adds documentation for modules

---------

Co-authored-by: Daniel Bodky <dbodky@gmail.com>
  • Loading branch information
mkayontour and mocdaniel authored Jul 5, 2023
1 parent 51024ab commit 4077df4
Show file tree
Hide file tree
Showing 34 changed files with 939 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- '!doc/**'

jobs:
build-ansible210:
build:
runs-on: ubuntu-latest

env:
Expand All @@ -28,8 +28,8 @@ jobs:
max-parallel: 1
matrix:
distro: [ubuntu2204]
python: ['3.8', '3.9', '3.10']
ansible: ['2.10.7', '2.11.8']
python: ['3.9', '3.10']
ansible: ['2.13.10', '2.14.7']
scenario: [default]

steps:
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,3 @@ jobs:
python -m unittest -v tests.unittestpy3.test_data
env:
MOLECULE_DISTRO: ${{ matrix.distro }}#
unittest-py2:
runs-on: ubuntu-latest

strategy:
# max-parallel: 4
matrix:
distro: [centos8, debian10]
python: ['2.7']

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Test with unittest
run: |
python -m unittest -v tests.unittestpy2.test_data
env:
MOLECULE_DISTRO: ${{ matrix.distro }}
37 changes: 37 additions & 0 deletions doc/role-icingaweb2/module-director.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Module Director

The module Icinga Director provides a management GUI for Icinga 2 DSL.

## Configuration

The general module parameter like `enabled` and `source` can be applied here.

For every config file, create a dictionary with sections as keys and the parameters as values. For all parameters please check the [module documentation](https://icinga.com/docs/icinga-director/latest/doc/03-Automation/)

The database resource won't be created
as Icinga Web 2 resource, please use the `icingaweb2_resources` variable to define
the resource.

`import_schema`: Checks for pending migrations on the database and applies them if needed.

`run_kickstart`: Runs kickstart when needed, please make sure the api user is available before.



```
icingaweb2_modules:
director:
enabled: true
source: package
import_schema: true
run_kickstart: true
kickstart:
config:
endpoint: "{{ ansible_fqdn }}"
host: 127.0.0.1
username: root
password: root
config:
db:
resource: director_db
```
32 changes: 32 additions & 0 deletions doc/role-icingaweb2/module-icingadb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Module IcingaDB

This module IcingaDB is the replacement for the monitoring module with IcingaDB as database backend.

## Configuration

The general module parameter like `enabled` and `source` can be applied here.

For every config file, create a dictionary with sections as keys and the parameters as values. For all parameters please check the [module documentation](https://icinga.com/docs/icinga-db-web/latest/doc/01-About/)

```
icingaweb2_modules:
icingadb:
enabled: true
source: package
commandtransports:
instance01:
transport: api
host: 127.0.0.1
username: root
password: root
config:
icingadb:
resource: icingadb
redis:
tls: '0'
redis:
redis1:
host: "192.168.56.200"
redis2:
host: "192.168.56.201"
```
28 changes: 28 additions & 0 deletions doc/role-icingaweb2/module-monitoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Module Monitoring

The module Monitoring is the main module for the deprecated IDO backend.

## Configuration

The general module parameter `enabled` be applied here.

For every config file, create a dictionary with sections as keys and the parameters as values. For all parameters please check the [module documentation](https://icinga.com/docs/icinga-web/latest/doc/03-Configuration/#configuration)

```
icingaweb2_modules:
monitoring:
enabled: true
commandtransports:
icinga2_api:
transport: api
host: localhost
username: root
password: changeme
backends:
icinga2_ido_mysql:
type: ido
resource: icinga_ido
config:
security:
protected_customvars: "*pw*,*pass*,community"
```
49 changes: 49 additions & 0 deletions doc/role-icingaweb2/role-icingaweb2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Role icinga.icinga.icingaweb2

The role icingaweb2 installs and configures Icinga Web 2 and its modules.

### Modules
* [Director](./module-director.md)
* [IcingaDB](./module-icingadb.md)
* [Monitoring](./module-monitoring.md)

## Variables

### Icinga Web 2 DB Configuration

If you use this configuration it will be your main Icinga Web DB, this means if the variable `icingaweb2_db_import_schema` is used the schema will be imported to this database.

```
icingaweb2_db:
type: mysql
name: icingaweb
host: 127.0.0.1
user: icingaweb
password: icingaweb
```

* `icingaweb2_db_import_schema: boolean`
* Decides whether the schema should be imported in the database defined at `icingaweb2_db`. **Default: False**

* `icingaweb2_admin_<username|password>: string`
* Set the username and password for the first admin user for Icinga Web 2.

#### Resources

Besides the standard Icinga Web 2 database you may configure additional resources for IcingaDB or automated imports.

```
icingaweb2_resources:
icinga_ido:
type: db
db: mysql
host: localhost
dbname: icinga
username: icinga
password: icinga
use_ssl: 0
charset: utf8
my_ldap:
type: ldap
[...]
```
6 changes: 6 additions & 0 deletions molecule/local-default/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
collections:
- name: community.docker
version: ">=1.9.0,<2.0.0"
- name: community.general
version: ">=2,<3"
- name: community.mysql
167 changes: 167 additions & 0 deletions molecule/local-default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
- name: Converge
hosts: all
become: true
vars:
icingaweb2_resources:
director_db:
type: db
db: mysql
host: localhost
dbname: directordb
username: directordb
password: directordb
charset: utf8
icinga_ido:
type: db
db: mysql
host: localhost
dbname: icinga
username: icinga
password: icinga
use_ssl: 0
charset: utf8
icingaweb2_modules:
director:
enabled: true
source: package
import_schema: true
run_kickstart: true
kickstart:
config:
endpoint: "{{ ansible_fqdn }}"
host: 127.0.0.1
username: root
password: root
config:
db:
resource: director_db
icingadb:
enabled: true
source: package
commandtransports:
instance01:
transport: api
host: 127.0.0.1
username: root
password: root
config:
icingadb:
resource: icingadb
redis:
tls: '0'
redis:
redis1:
host: "192.168.56.200"
redis2:
host: "192.168.56.201"
monitoring:
enabled: false
backends:
icinga2_ido_mysql:
type: ido
resource: icinga_ido
icingaweb2_roles:
my_admins:
users:
- blubber
- robby
permissions:
- "config/*"
- "module/monitoring"
- "monitoring/commands/schedule-check"
'monitoring/filter/objects': "host_name=*win*"
icingaweb2_db:
type: mysql
name: icingaweb
host: 127.0.0.1
user: icingaweb
password: icingaweb
icingaweb2_admin_username: admin
icingaweb2_admin_password: admin
icingaweb2_db_import_schema: true
icingadb_database_import_schema: true
mysql_innodb_file_format: barracuda
mysql_innodb_large_prefix: 1
mysql_innodb_file_per_table: 1
mysql_packages:
- mariadb-client
- mariadb-server
- python3-mysqldb
mysql_users:
- name: directordb
host: "%"
password: directordb
priv: "directordb.*:ALL"
- name: icingadb
host: "%"
password: icingadb
priv: "icingadb.*:ALL"
- name: icingaweb
host: "%"
password: icingaweb
priv: "icingaweb.*:ALL"
- name: icinga
host: "%"
password: icinga
priv: "icinga.*:ALL"
mysql_databases:
- name: icingaweb
- name: icinga
- name: directordb
- name: icingadb
collation: utf8mb4_general_ci
encoding: utf8mb4
icinga2_confd: true
icinga2_features:
- name: perfdata
host_perfdata_path: "/var/spool/icinga2/perfdata/host-perfdata"
service_perfdata_path: "/var/spool/icinga2/perfdata/service-perfdata"
- name: gelf
host: localhost
port: 12201
- name: elasticsearch
host: localhost
port: 9200
index: "icinga2"
enable_send_perfdata: true
flush_interval: 10
flush_threshold: 1024
- name: opentsdb
host: localhost
port: 4242
- name: icingadb
host: 127.0.0.1
- name: idomysql
host: localhost
database: icinga
user: icinga
password: icinga
import_schema: true
- name: notification
- name: checker
- name: influxdb2
host: 127.0.0.1
port: 8086
organization: monitoring
bucket: icinga2
auth_token: testtoken123
- name: mainlog
- name: api
ca_host: none
endpoints:
- name: "{{ ansible_fqdn }}"
zones:
- name: "main"
endpoints:
- "{{ ansible_fqdn }}"
icinga2_config_directories:
- zones.d/main/commands
- zones.d/main/hosts
- zones.d/main/services
collections:
- icinga.icinga
roles:
- repos
- geerlingguy.mysql
- icinga2
- icingaweb2
Loading

0 comments on commit 4077df4

Please sign in to comment.