Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate icingaweb2 setup #4

Open
wants to merge 54 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
82541f8
Add missing dict2items filter
arjanoosting Nov 13, 2019
540086a
Also install php-curl for API access and php-imagick for reports
arjanoosting Nov 14, 2019
a99cea3
Make sure apache is restarted when new PHP modules are installed/enabled
arjanoosting Nov 18, 2019
7f09da3
Generate configuration files for IcingaWeb2 based on variables
arjanoosting Nov 18, 2019
ff7e9b5
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Nov 18, 2019
a820dd7
Quote zone names
arjanoosting Nov 28, 2019
584a421
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Nov 28, 2019
5728fd4
Use the i2_api_host and i2_api_port to connect to parent
arjanoosting Nov 28, 2019
1a7bcf7
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Nov 28, 2019
22aea82
Adjust the way we handle the configuration files so we can reuse it for
arjanoosting Dec 4, 2019
7ae7149
Adjust the installation of modules to include an version and repo
arjanoosting Dec 4, 2019
2fe356a
Fixes in the node hierachy detection
arjanoosting Feb 4, 2020
9e96124
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Feb 4, 2020
1643840
Fix name of default config and order options in generated files
arjanoosting Feb 4, 2020
4aa1b34
Use template instead of blockinfile for the api-users.conf file
arjanoosting Feb 4, 2020
9624d2a
Cleanup unused code
arjanoosting Feb 4, 2020
99737e5
use openssl_certificate_info
arjanoosting Feb 4, 2020
9619b91
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Feb 4, 2020
421436c
Install icinga-director service, create Director database and create …
arjanoosting Feb 13, 2020
047f4e5
Simple label for loop and set managed_object_files without loop
arjanoosting Feb 25, 2020
2ab7d8d
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Feb 25, 2020
f2bcaab
Setup the icinga nodes in layers, first masters, then satellites, then
arjanoosting Feb 27, 2020
56fd64a
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Feb 27, 2020
bd623e1
Fix the layout of the feature configuration, which fixes IDO cleanup
arjanoosting Mar 23, 2020
a0d39b3
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Mar 23, 2020
7dbe5cb
Fix layout of generated configuration
arjanoosting Mar 24, 2020
fda1b5d
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Mar 24, 2020
3308e02
Configure the satellites via "Top Down Config Sync"
arjanoosting May 14, 2020
8cb329a
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting May 14, 2020
0da7e09
Mark commands tags which don't change the system
arjanoosting Jul 22, 2020
f1b010e
Make the state of the icinga packages a variable so we can use this role
arjanoosting Jul 22, 2020
46fbc2f
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Jul 22, 2020
2933b28
Use the i2_package_state for Red Hat as well and use the restart icinga2
arjanoosting Aug 26, 2020
c4ea74f
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Aug 26, 2020
93c25ee
Specify default more clearly
arjanoosting Aug 27, 2020
60c59ba
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Aug 27, 2020
75a4474
Support install icingaweb on additional hosts
arjanoosting Aug 27, 2020
16c1acf
handle lists
arjanoosting Sep 10, 2020
e270eda
Use complete path to binary
arjanoosting Feb 18, 2021
8b3c258
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Feb 18, 2021
70aa2fa
Only do set_fact if the hostvar is not set yet or incorrect and add an
arjanoosting Feb 26, 2021
f69f47a
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Feb 26, 2021
fddb44a
Remove space after comma in lists
arjanoosting Feb 26, 2021
3b99aa2
Fix removal of unmanaged files which sometimes removed to much
arjanoosting Mar 11, 2021
22fcf38
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Mar 11, 2021
8857934
Remove when clause which causes configuration to be lost
arjanoosting Mar 11, 2021
d56074a
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Mar 11, 2021
86e9f93
Handle hosts in the all group
arjanoosting Apr 7, 2021
09f531b
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Apr 7, 2021
5c7b72c
Another fix to handle hosts in the all group
arjanoosting Apr 7, 2021
84512b7
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Apr 7, 2021
31dd9be
icinga_ido should use latin1.
arjanoosting Feb 14, 2022
b70be1f
Only install apt-transport-https when we are on an apt version which …
arjanoosting Aug 29, 2022
e598786
Merge branch 'development' into automate-icingaweb2-setup
arjanoosting Aug 29, 2022
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
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ script:
- molecule test
matrix:
include:
- env: ANSIBLE_VERSION="2.5.9"
- env: ANSIBLE_VERSION="2.6.5"
- env: ANSIBLE_VERSION="2.7.0"
- env: ANSIBLE_VERSION="2.7.5"
- env: ANSIBLE_VERSION="2.9.2"
- env: ANSIBLE_VERSION="2.8.7"
branches:
only:
- master
Expand Down
128 changes: 122 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ i2_remove_unmanaged_features: no
i2_remove_unmanaged_objects: no
i2_remove_unmanaged_objects_in_zone: no

i2_master: no
i2_satellite: no
i2_webui: "{{ inventory_hostname == i2_configuration_master }}"
i2_master: "{{ inventory_hostname in groups[i2_master_group] }}"
i2_satellite: "{{ inventory_hostname in groups[i2_satellite_group] }}"
i2_api_port: 5665
i2_connection_direction: 'top-down'

Expand Down Expand Up @@ -68,10 +69,17 @@ i2_webui_php_all: no
i2_webui_modules_dir: "/usr/share/icingaweb2/modules"
i2_timezone: "UTC"
i2_webui_modules:
- map
- cube
- toplevelview
- businessprocess
- name: cube
version: v1.1.0
- name: map
version: v1.1.0
repo: https://github.com/nbuchwitz/icingaweb2-module-map.git
- name: toplevelview
version: v0.3.1
- name: ipl
version: v0.4.0
- name: businessprocess
version: v2.2.0
i2_webui_params:
database: icingaweb
user: icingaweb
Expand All @@ -84,5 +92,113 @@ i2_webui_params:
# {{ ansible_facts.default_ipv4.address }}
i2_webui_connectfrom:
- localhost
i2_webui_user: "www-data" # fixme this is httpd on RedHat
i2_webui_group: icingaweb2
i2_webui_admins: []

i2_webui_default_config:
authentication:
file: authentication.ini
sections:
icingaweb2:
backend: db
resource: icingaweb_db
config:
file: config.ini
sections:
global:
show_stacktraces: "0"
show_application_state_messages: "1"
config_backend: db
config_resource: icingaweb_db
logging:
log: syslog
level: ERROR
application: icingaweb2
facility: user
groups:
file: groups.ini
sections:
icingaweb2:
backend: db
resource: icingaweb_db
resources:
file: resources.ini
sections:
icingaweb_db:
type: db
db: mysql
host: "{{ i2_webui_params.host|default('localhost') }}"
port: "{{ i2_webui_params.port|default(omit) }}"
dbname: "{{ i2_webui_params.database }}"
username: "{{ i2_webui_params.user }}"
password: "{{ i2_webui_params.password }}"
charset: utf8
use_ssl: "0"
icinga_ido:
type: db
db: mysql
host: "{{ i2_ido_params.host|default('localhost') }}"
port: "{{ i2_ido_params.port|default(omit) }}"
dbname: "{{ i2_ido_params.database }}"
username: "{{ i2_ido_params.user }}"
password: "{{ i2_ido_params.password }}"
charset: latin1
use_ssl: "0"
roles:
file: roles.ini
sections:
Administrators:
users: "{{ i2_webui_admins|join(',') }}"
permissions: "*"
groups: Administrators
modules_monitoring_backends:
file: modules/monitoring/backends.ini
sections:
icinga:
type: ido
resource: icinga_ido
modules_monitoring_commandtransports:
file: modules/monitoring/commandtransports.ini
sections:
icinga2:
transport: api
host: "{{ i2_api_host }}"
port: "{{ i2_api_port }}"
username: "{{ i2_api_webui_user }}"
password: "{{ i2_api_webui_password }}"
modules_monitoring_config:
file: modules/monitoring/config.ini
sections:
security:
protected_customvars: "*pw*,*pass*,community"
i2_webui_default_module_config:
director:
resources:
sections:
director_db:
type: db
db: mysql
host: "{{ i2_director_params.host|default('localhost') }}"
port: ""
dbname: "{{ i2_director_params.database }}"
username: "{{ i2_director_params.user }}"
password: "{{ i2_director_params.password }}"
charset: utf8
use_ssl: "0"
modules_director_config:
file: modules/director/config.ini
sections:
db:
resource: director_db
modules_director_kickstart:
file: modules/director/kickstart.ini
sections:
config:
endpoint: "{{ i2_hostname }}"
username: director
password: "{{ i2_api_director_password }}"
i2_webui_custom_config: {}
i2_webui_config: "{{ i2_webui_default_config|combine(i2_webui_custom_config, recursive=True) }}"

i2_bootstrap_cacheable: False
21 changes: 21 additions & 0 deletions files/icinga-director.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Icinga Director - Monitoring Configuration
Documentation=https://icinga.com/docs/director/latest/
Wants=network.target

[Service]
EnvironmentFile=-/etc/default/icinga-director
EnvironmentFile=-/etc/sysconfig/icinga-director
ExecStart=/usr/bin/icingacli director daemon run
ExecReload=/bin/kill -HUP ${MAINPID}
User=icingadirector
SyslogIdentifier=icingadirector
Type=notify

NotifyAccess=main
WatchdogSec=10
RestartSec=30
Restart=always

[Install]
WantedBy=multi-user.target
11 changes: 11 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
- name: reload systemd
become: yes
systemd:
daemon_reload: yes

- name: start icinga2
become: yes
service:
Expand Down Expand Up @@ -44,6 +49,12 @@
state: restarted
when: i2_manage_service

- name: restart icinga-director
become: yes
service:
name: icinga-director
state: restarted

- name: restart php-fpm
become: yes
service:
Expand Down
15 changes: 10 additions & 5 deletions tasks/icinga2-Debian.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
- name: Debian - Determine apt version
package_facts:

- name: Debian - Install apt-transport-https
become: yes
apt:
name: apt-transport-https
state: present
when: i2_manage_repository
when:
- i2_manage_repository
- ansible_facts.packages['apt'] | map(attribute='version') | first is version('1.5', '<')

- name: Debian - Add Icinga 2 repository key
become: yes
Expand All @@ -24,16 +29,16 @@
become: yes
apt:
name: icinga2
state: present
notify: start icinga2
state: "{{ i2_package_state|default('present') }}"
notify: restart icinga2
when: i2_manage_package

- name: Debian - Ensure IDO is installed on the masters
become: yes
apt:
name: "icinga2-ido-{{ i2_ido_backend }}"
state: present
notify: start icinga2
state: "{{ i2_package_state|default('present') }}"
notify: retart icinga2
when:
- i2_manage_package
- i2_ido_backend is defined
Expand Down
6 changes: 3 additions & 3 deletions tasks/icinga2-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
become: yes
yum:
name: icinga2
state: present
state: "{{ i2_package_state|default('present') }}"
update_cache: yes
notify: start icinga2
notify: restart icinga2
when: i2_manage_package

- name: RedHat - Ensure IDO is installed on the masters
become: yes
yum:
name: "icinga2-ido-{{ i2_ido_backend }}"
state: present
notify: start icinga2
notify: restart icinga2
when:
- i2_manage_package
- i2_ido_backend is defined
Expand Down
24 changes: 5 additions & 19 deletions tasks/icinga2-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- name: Master - Create Certificate Authority
become: yes
command: icinga2 pki new-ca
command: /usr/sbin/icinga2 pki new-ca
args:
creates: "{{ i2_ca_file }}"
when: inventory_hostname == i2_configuration_master
Expand Down Expand Up @@ -97,7 +97,7 @@
- name: Master - Create Host Certificate
become: yes
command: >
icinga2 pki new-cert
/usr/sbin/icinga2 pki new-cert
--cn {{ i2_hostname }}
--key {{ i2_pki_path }}/{{ i2_hostname }}.key
--csr {{ i2_pki_path }}/{{ i2_hostname }}.csr
Expand All @@ -107,7 +107,7 @@
- name: Master - Sign Host Certificate
become: yes
command: >
icinga2 pki sign-csr
/usr/sbin/icinga2 pki sign-csr
--csr {{ i2_pki_path }}/{{ i2_hostname }}.csr
--cert {{ i2_pki_path }}/{{ i2_hostname }}.crt
args:
Expand Down Expand Up @@ -152,28 +152,14 @@
# Blerim made i2_confd an array of locations to be included.
- name: Master - Create Api-Users config file
become: yes
blockinfile:
create: yes
template:
src: api-users.conf.j2
dest: "{{ i2_zones_dir }}/{{ i2_zonename }}/api-users.conf"
marker: "// {mark} Ansible managed block for {{ item.key }}"
content: "{{ lookup('template', 'api_users_fragment.j2') }}"
owner: "{{ i2_user }}"
group: "{{ i2_group }}"
mode: 0644
directory_mode: 0755
with_dict: "{{ i2_api_users }}"
when:
- inventory_hostname == i2_configuration_master
- i2_api_users is defined
notify:
- reload icinga2

- name: Master – Restart Icinga2 Service on Config Master
service:
name: icinga2
state: started
enabled: yes
when:
- inventory_hostname == i2_configuration_master
- i2_manage_service

Loading