aboutsummaryrefslogtreecommitdiff
path: root/roles/icinga2/tasks/icingaweb.yml
blob: ee4cd6ab94943e6029eb083e5ac80bcf2fce3267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
- name: icingaweb Database
  mysql_db:
    name: icingaweb
    state: present
    login_unix_socket: /var/run/mysqld/mysqld.sock
  become: yes
  register: icingaweb_db

- name: icingaweb Database schema
  mysql_db:
    name: icingaweb
    state: import
    target: '/usr/share/icingaweb2/etc/schema/mysql.schema.sql'
    login_unix_socket: /var/run/mysqld/mysqld.sock
  become: yes
  when: icingaweb_db.changed

# password is 'admin'
# create with php -r 'echo password_hash("admin", PASSWORD_DEFAULT);'
- name: Create default admin user
  community.mysql.mysql_query:
    query: "INSERT INTO icingaweb.icingaweb_user (name, active, password_hash) VALUES ('admin', 1, '$2y$10$MN74jDR1LtgzEzxxxyqOgug1WWuuirfMWjOtHZdvi5yjsd4el75Y2')"
    login_unix_socket: /var/run/mysqld/mysqld.sock
  become: yes
  when: icingaweb_db.changed

- name: icingaweb Database user
  mysql_user:
    name: icingaweb
    host: localhost
    state: present
    priv: 'icingaweb.*:ALL'
    password: '{{ icinga_web_db_pw }}'
    login_unix_socket: /var/run/mysqld/mysqld.sock
  become: yes

- name: Config dirs
  file:
    state: directory
    path: '/etc/icingaweb2/{{ item }}'
    owner: root
    group: icingaweb2
    mode: '2770'
  become: yes
  loop:
    - ''
    - modules
    - modules/monitoring
    - enabledModules

- name: Install configuration files
  template:
    src: 'web/{{ item }}.j2'
    dest: '/etc/icingaweb2/{{ item }}'
    owner: www-data
    group: icingaweb2
    mode: '0660'
  become: yes
  loop:
    - config.ini
    - authentication.ini
    - groups.ini
    - resources.ini
    - roles.ini
    - modules/monitoring/config.ini
    - modules/monitoring/commandtransports.ini
    - modules/monitoring/backends.ini

- name: Install modules
  git:
    dest: '/usr/share/icingaweb2/modules/{{ item.key }}'
    repo: '{{ item.value.url }}'
    version: '{{ item.value.version }}'
  become: yes
  with_dict: '{{ icingaweb.install_modules }}'

- name: Enable modules
  file:
    path: '/etc/icingaweb2/enabledModules/{{ item }}'
    src: '/usr/share/icingaweb2/modules/{{ item }}'
    state: link
    owner: www-data
    group: icingaweb2
  become: yes
  with_items: '{{ icingaweb.enabled_modules }}'

- name: icingaweb2 user
  user:
    name: icingaweb2
    group: icingaweb2
    groups: www-data
    append: yes
  become: yes