diff --git a/doc/role-icingaweb2/module-graphite.md b/doc/role-icingaweb2/module-graphite.md new file mode 100644 index 00000000..077717e7 --- /dev/null +++ b/doc/role-icingaweb2/module-graphite.md @@ -0,0 +1,77 @@ +## Module Graphite + +This module only configures the module in Icinga Web and not the graphite backend itself. + +## Variables + +### Module Configuration File + +The general module parameter like `enabled` and `source` can be applied here. + +For the **config** file, create a dictionary with sections as keys and the parameters as values. + +Example: + +``` +icingaweb2_modules: + graphite: + enabled: true + source: package + config: + graphite: # This is the section + url: 127.0.0.1:9000 + user: graphite + password: graphitepw + ui: + default_time_range: 6 + +``` + +#### Section graphite + +| Variable | Type | Example | +|----------|--------|------------------| +| url | string | "127.0.0.1:9000" | +| user | string | "graphite" | +| password | string | "password" | +| insecure | number | "1" | + +#### Section ui + +| Variable | Type | Example | +|-------------------------|--------|---------| +| default_time_range | number | "1" | +| defautl_time_range_unit | string | "hours" | +| disable_no_graphs_found | bool | "0"/"1" | + + +#### Section icinga + +| Variable | Type | Example | +|---------------------------------------|--------|----------------------| +| graphite_writer_host_name_template | string | "$host.template$" | +| graphite_writer_service_name_template | string | "$service.template$" | +| customvar_obscured_check_command | string | "customvar" | + + +### Custom Template Files + +Custom templates are good to enhance the graphite basic template library. To include own +graphs and modifications. + +To copy them into the templates folder please use the `custom_template_files` dictionary. + +The `src_path` will search within any `files/` directory in the Ansible environment. + + +``` +icingaweb2_modules: + graphite: + enabled: true + source: package + custom_template_files: + - name: mygraph.ini + src_path: graphite_templates/mygraph.ini + - name: myothergraph.ini + src_path: graphite_templates/myothergraph.ini +``` diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index d3b3194a..844881d1 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -3,6 +3,54 @@ - name: Converge hosts: all vars: + icingaweb2_modules: + graphite: + enabled: true + custom_template_files: + - name: test.ini + src_path: graphite_templates/test.ini + config: + graphite: + url: 127.0.0.1:9000 + ui: + default_time_range: 6 + director: + enabled: true + source: package + import_schema: false + run_kickstart: false + kickstart: + config: + endpoint: icinga-default + 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: "127.0.0.1" + monitoring: + enabled: false + backends: + icinga2_ido_mysql: + type: ido + resource: icinga_ido icingaweb2_db: type: mysql name: icingaweb diff --git a/molecule/default/files/graphite_templates/test.ini b/molecule/default/files/graphite_templates/test.ini new file mode 100644 index 00000000..a7755e80 --- /dev/null +++ b/molecule/default/files/graphite_templates/test.ini @@ -0,0 +1,30 @@ +[hostalive-rta.graph] +check_command = "hostalive" + +[hostalive-rta.metrics_filters] +rta.value = "$host_name_template$.perfdata.rta.value" + +[hostalive-rta.urlparams] +areaAlpha = "0.5" +areaMode = "all" +min = "0" +yUnitSystem = "none" + +[hostalive-rta.functions] +rta.value = "alias(color(scale($metric$, 1000), '#1a7dd7'), 'Round trip time (ms)')" + + +[hostalive-pl.graph] +check_command = "hostalive" + +[hostalive-pl.metrics_filters] +pl.value = "$host_name_template$.perfdata.pl.value" + +[hostalive-pl.urlparams] +areaAlpha = "0.5" +areaMode = "all" +min = "0" +yUnitSystem = "none" + +[hostalive-pl.functions] +pl.value = "alias(color($metric$, '#1a7dd7'), 'Packet loss (%)')" diff --git a/roles/icingaweb2/tasks/modules/graphite.yml b/roles/icingaweb2/tasks/modules/graphite.yml new file mode 100644 index 00000000..e842ced2 --- /dev/null +++ b/roles/icingaweb2/tasks/modules/graphite.yml @@ -0,0 +1,39 @@ +- name: Module Graphite | Ensure config directory + ansible.builtin.file: + state: directory + dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}" + owner: "{{ icingaweb2_httpd_user }}" + group: "{{ icingaweb2_group }}" + mode: "2770" + +- name: Module Graphite | Ensure templates directory + ansible.builtin.file: + state: directory + dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}/templates" + owner: "{{ icingaweb2_httpd_user }}" + group: "{{ icingaweb2_group }}" + mode: "2770" + +- name: Module Graphite | Manage config files + ansible.builtin.include_tasks: manage_module_config.yml + loop: "{{ _files }}" + loop_control: + loop_var: _file + when: vars['icingaweb2_modules'][_module][_file] is defined + vars: + _module: "{{ item.key }}" + _files: + - config + +- name: Module Graphite | Copy custom templates + ansible.builtin.copy: + owner: "{{ icingaweb2_httpd_user }}" + group: "{{ icingaweb2_group }}" + src: "files/{{ _file.src_path }}" + dest: "{{ icingaweb2_modules_config_dir }}/{{ item.key }}/templates/{{ _file.name }}" + when: vars['icingaweb2_modules'][_module]['custom_template_files'] is defined + loop: "{{ vars['icingaweb2_modules'][_module]['custom_template_files'] }}" + loop_control: + loop_var: _file + vars: + _module: "{{ item.key }}" diff --git a/roles/icingaweb2/vars/main.yml b/roles/icingaweb2/vars/main.yml index 588f0d6d..9d96b2e6 100644 --- a/roles/icingaweb2/vars/main.yml +++ b/roles/icingaweb2/vars/main.yml @@ -2,5 +2,6 @@ icingaweb2_module_packages: icingadb: icingadb-web director: icinga-director + graphite: icinga-graphite-web x509: icinga-x509 businessprocess: icinga-businessprocess