Debian Codegraph @

ansible_collections/community/zabbix/roles/zabbix_web/README.md

raw
1 # community.zabbix.zabbix_web role
2
3 ![Zabbix Web](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_web/badge.svg)
4
5 **Table of Contents**
6
7 - [Overview](#overview)
8 - [Requirements](#requirements)
9 - [Operating Systems](#operating-systems)
10 - [Zabbix Versions](#zabbix-versions)
11 - [Installation](#installation)
12 - [Role Variables](#role-variables)
13 - [Main variables](#main-variables)
14 - [Overall Zabbix](#overall-zabbix)
15 - [Zabbix Web specific](#zabbix-web-specific)
16 - [Apache configuration](#apache-configuration)
17 - [Nginx configuration](#nginx-configuration)
18 - [PHP-FPM](#php-fpm)
19 - [SElinux](#selinux)
20 - [Zabbix Server](#zabbix-server)
21 - [Zabbix Frontend Encrypt](#zabbix-frontend-encrypt)
22 * [proxy](#proxy)
23 - [Example Playbook](#example-playbook)
24 - [Single instance](#single-instance)
25 - [Multi host setup](#multi-host-setup)
26 - [Adding Environment Variables for zabbix_web](#adding-environment-variables-for-zabbixweb)
27 - [Using Elasticsearch for history storage](#using-elasticsearch-for-history-storage)
28 - [Molecule](#molecule)
29 - [License](#license)
30 - [Author Information](#author-information)
31
32 # Overview
33
34 # Requirements
35 ## Operating Systems
36
37 This role will work on the following operating systems:
38
39 * RedHat
40 * Debian
41 * Ubuntu
42
43 So, you'll need one of those operating systems.. :-)
44 Please send Pull Requests or suggestions when you want to use this role for other Operating systems.
45
46 ## Ansible 2.10 and higher
47
48 With the release of Ansible 2.10, modules have been moved into collections. With the exception of ansible.builtin modules, this means additonal collections must be installed in order to use modules such as seboolean (now ansible.posix.seboolean). The following collections are now required: `ansible.posix`. Installing the collections:
49
50 ```sh
51 ansible-galaxy collection install ansible.posix
52 ansible-galaxy collection install community.general
53 ```
54
55 ## Zabbix Versions
56
57 See the following list of supported Operating Systems with the Zabbix releases.
58
59 | Zabbix | 7.4 | 7.2 | 7.0 | 6.0 |
60 |---------------------|-----|-----|-----|-----|
61 | Red Hat Fam 9 | V | V | V | V |
62 | Red Hat Fam 8 | V | V | V | V |
63 | Ubuntu 24.04 noble | V | V | V | V |
64 | Ubuntu 22.04 jammy | V | V | V | V |
65 | Debian 12 bookworm | V | V | V | V |
66 | Debian 11 bullseye | | | | V |
67 | Suse Fam 15 | V | V | V | V |
68
69 You can bypass this matrix by setting `enable_version_check: false`
70
71 # Installation
72
73 Installing this role is very simple: `ansible-galaxy install community.zabbix.zabbix_web`
74
75 When the Zabbix Web needs to be running on the same host as the Zabbix Server, please also install the Zabbix Server by executing the following command: `ansible-galaxy install community.zabbix.zabbix_server`
76
77 Default username/password for the Zabbix Web interface is the default.
78
79 Username: Admin
80 Password: zabbix
81
82 # Role Variables
83
84 ## Main variables
85
86 The following is an overview of all available configuration defaults for this role.
87
88 ### Overall Zabbix
89
90 * `zabbix_web_version`: Optional. The latest available major.minor version of Zabbix will be installed on the host(s). If you want to use an older version, please specify this in the major.minor format. Example: `zabbix_web_version: 6.0`.
91 * `zabbix_web_version_minor`: When you want to specify a minor version to be installed. RedHat only. Default set to: `*` (latest available)
92 * `zabbix_web_disable_repo`: A list of repos to disable during install. Default `epel`.
93 * `zabbix_web_package_state`: Default: `present`. Can be overridden to `latest` to update packages when needed.
94 * `zabbix_web_doubleprecision`: Default: `False`. For upgraded installations, please read database [upgrade notes](https://www.zabbix.com/documentation/current/manual/installation/upgrade_notes_500) (Paragraph "Enabling extended range of numeric (float) values") before enabling this option.
95 * `zabbix_web_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file.
96 * `zabbix_manage_repo`: Have the collection install and configure the Zabbix repo Default `true`.
97
98
99 ### Zabbix Web specific
100
101 * `zabbix_api_server_url`: This is the url on which the zabbix web interface is available. Default is zabbix.example.com, you should override it. For example, see "Example Playbook"
102 * `zabbix_web_http_server`: Which web server is in use. Valid values are 'apache' and 'nginx'. Default is `apache`
103 * `zabbix_url_aliases`: A list with Aliases for the Apache Virtual Host configuration.
104 * `zabbix_timezone`: Default: `Europe/Amsterdam`. This is the timezone. The Apache Virtual Host needs this parameter.
105 * `zabbix_web_create_vhost`: Default: `true`. When you don't want to create an Apache Virtual Host configuration, you can set it to False.
106 * `zabbix_web_create_php_fpm`: Configure php-fpm (Debian hosts only). Default is to use the same value as `zabbix_web_create_vhost`.
107 * `zabbix_web_env`: (Optional) A Dictionary of PHP Environments settings.
108 * `zabbix_web_user`: When provided, the user (which should already exist on the host) will be used for ownership for web/php related processes. (Default set to either `apache` (`www-data` for Debian) or `nginx`).
109 * `zabbix_web_group`: When provided, the group (which should already exist on the host) will be used for ownership for web/php related processes. (Default set to either `apache` (`www-data` for Debian) or `nginx`).
110 * `zabbix_web_connect_ha_backend`: (Optional) Default: `false`. When set to `true` values for Zabbix server will not be written and frontend gets values from database to connect to active cluster node. Set `true` when operating Zabbix servers in a cluste (only >=6.0).
111 * `zabbix_saml_idp_crt`: (Optional) The path to the certificate of the Identity Provider used for SAML authentication
112 * `zabbix_saml_sp_crt`: (Optional) The path to the public certificate of Zabbix as Service Provider
113 * `zabbix_saml_sp_key`: (Optional) The path to the private certificate of Zabbix as Service Provider
114
115 #### Apache/Nginx Configuration
116
117 * `zabbix_web_vhost_port`: The port on which Zabbix HTTP vhost is running.
118 * `zabbix_web_vhost_tls_port`: The port on which Zabbix HTTPS vhost is running.
119 * `zabbix_web_vhost_listen_ip`: On which interface the Apache Virtual Host is available.
120 * `zabbix_web_max_execution_time`: PHP max execution time
121 * `zabbix_web_memory_limit`: PHP memory limit
122 * `zabbix_web_post_max_size`: PHP maximum post size
123 * `zabbix_web_upload_max_filesize`: PHP maximum file size
124 * `zabbix_web_max_input_time`:
125 * `zabbix_web_tls`: If the Apache vhost should be configured with TLS encryption or not.
126 * `zabbix_web_redirect`: If a redirect should take place from HTTP to HTTPS
127 * `zabbix_web_tls_crt`: The path to the TLS certificate file.
128 * `zabbix_web_tls_key`: The path to the TLS key file.
129 * `zabbix_web_tls_chain`: The path to the TLS certificate chain file.
130 * `zabbix_web_SSLPassPhraseDialog`: Type of pass phrase dialog for encrypted private keys.
131 * `zabbix_web_ssl_session_cache`: Type of the global/inter-process SSL Session Cache
132 * `zabbix_web_ssl_session_cache_timeout`: Number of seconds before an SSL session expires in the Session Cache
133 * `zabbix_web_SSLCryptoDevice`: Enable use of a cryptographic hardware accelerator
134 * `zabbix_apache_custom_includes`: Configure custom includes. Default: `[]`
135 * `zabbix_web_ssl_http2`: Bool (default: False) if using http2
136 * `zabbix_web_ssl_session_protocols`: Space seperated list of ssl protocols to explicitly allow (Nginx only)
137 * `zabbix_web_ssl_session_prefer_server_ciphers`: (`on`/`off`) Should server ciphers be prefered over client ciphers (Nginx only)
138 * `zabbix_web_ssl_session_stapling`: (`on`/`off`) Should enable/disable stapling of OCSP responses by server (Nginx only)
139
140
141 When `zabbix_web_tls_crt`, `zabbix_web_tls_key` and/or `zabbix_web_tls_chain` are used, make sure that these files exists before executing this role. The Zabbix-Web role will not install the mentioned files.
142
143 See https://httpd.apache.org/docs/current/mod/mod_ssl.html for SSL* configuration options for Apache HTTPD.
144
145 #### Nginx configuration
146
147
148 #### PHP-FPM
149
150 The following properties are for the PHP(-FPM) configuration:
151
152 * `zabbix_php_fpm_session`: The directory where sessions will be stored. If none are provided, defaults are used.
153 * `zabbix_php_fpm_listen`: The path to a socket file or ipaddress:port combination on which PHP-FPM needs to listen. If none are provided, defaults are used.
154 * `zabbix_php_fpm_conf_listen`: Default: `true`. If we want to configure the `zabbix_php_fpm_listen` in the PHP-FPM configuration file.
155 * `zabbix_php_fpm_conf_user`: The owner of the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file).
156 * `zabbix_php_fpm_conf_group`: The group of the owner of the socket file (When `zabbix_php_fpm_listen` contains a patch to a socket file).
157
158
159 The following values can be used to tune php-fpm for better performance on the frontend:
160
161 * `zabbix_web_php_fpm_mode`: Set the mode the php process management will work in. Available dynamic, static, ondemand - default: dynamic
162 * `zabbix_web_php_fpm_max_childs`: Set maximum number of process children php-fpm can spawn - default: 50
163 * `zabbix_web_php_fpm_start_servers`: The number of child process to be spawned on start. default: 5
164 * `zabbix_web_php_fpm_min_spare_servers`: The minimum number of idle child processes PHP-FPM will create. More are created if fewer than this number are available. - default: 5
165 * `zabbix_web_php_fpm_max_spare_servers`: The maximum number of idle child processes PHP-FPM will create. If there are more child processes available than this value, then some will be killed off. - default: 35
166 * `zabbix_web_custom_php`: Any customer php settings
167
168 ##### Tunning recommendations
169 | Setting | Value |
170 |--------------------------------------|--------------------------------------------------------------|
171 | zabbix_web_php_fpm_max_childs | (Total RAM – Memory used for Linux, DB, etc.) / process size |
172 | zabbix_web_php_fpm_start_servers | Number of CPU cores x 4 |
173 | zabbix_web_php_fpm_min_spare_servers | Number of CPU cores x 2 |
174 | zabbix_web_php_fpm_max_spare_servers | Same as start_servers |
175
176 ### SElinux
177
178 Selinux changes will be installed based on the status of selinux running on the target system.
179
180 * `selinux_allow_httpd_can_connect_ldap`: Default: `False`. Set SELinux boolean to allow httpd to connect to LDAP.
181 * `selinux_allow_httpd_can_connect_zabbix`: Default: `True`. Set SELinux boolean to allow httpd to connect to zabbix.
182 * `selinux_allow_httpd_can_network_connect_db`: Default: `True` Set SELinux boolean to allow httpd to connect databases over the network.
183
184 ### Zabbix Server
185
186 * `zabbix_server_name`: The name of the Zabbix Server.
187 * `zabbix_server_database`: The type of database used. Can be: mysql or pgsql
188 * `zabbix_server_hostname`: The hostname on which the zabbix-server is running. Default set to: {{ inventory_hostname }}
189 * `zabbix_server_listenport`: On which port the Zabbix Server is available. Default: 10051
190 * `zabbix_server_dbhost`: The hostname on which the database is running.
191 * `zabbix_server_dbname`: The database name which is used by the Zabbix Server.
192 * `zabbix_server_dbuser`: The database username which is used by the Zabbix Server.
193 * `zabbix_server_dbpassword`: The database user password which is used by the Zabbix Server.
194 * `zabbix_server_dbport`: The database port which is used by the Zabbix Server.
195 * `zabbix_server_dbencryption`: Use encryption with the database connection
196
197 The following properties are related when using Elasticsearch for history storage:
198
199 * `zabbix_server_history_url`: String with url to the Elasticsearch server or a list if the types are stored on different Elasticsearch URLs.
200 * `zabbix_server_history_types`: List of history types to store in Elasticsearch.
201
202 See the following links for more information regarding Zabbix and Elasticsearch
203 https://www.zabbix.com/documentation/3.4/manual/appendix/install/elastic_search_setup
204 https://www.zabbix.com/documentation/4.0/manual/appendix/install/elastic_search_setup
205
206 ### Zabbix Frontend Encrypt
207 Supported as of Zabbix 7.4.
208
209 * `zabbix_server_tls_active`: 0 = unencrypted, 1 = active.
210 * `zabbix_server_tls_ca_file`: Path to the CA certificate file.
211 * `zabbix_server_tls_key_file`: Path to the key file.
212 * `zabbix_server_tls_cert_file`: Path to the certificate file.
213 * `zabbix_server_tls_certificate_issuer`: Allowed frontend certificate issuer. Optional.
214 * `zabbix_server_tls_certificate_subject`: Allowed frontend certificate subject. Optional.
215
216 https://www.zabbix.com/documentation/7.4/en/manual/introduction/whatsnew#tls-encryption-between-frontend-and-server
217 https://www.zabbix.com/documentation/7.4/en/manual/appendix/install/frontend_encrypt
218
219 ## proxy
220
221 When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy:
222
223 * `zabbix_http_proxy`
224 * `zabbix_https_proxy`
225
226 ## Tags
227
228 The majority of tasks within this role are tagged as follows:
229
230 * `install`: Tasks associated with the installation of software.
231 * `dependencies`: Installation tasks related to dependencies that aren't part of the core zabbix installation.
232 * `database`: Tasks associated with the installation or configuration of the database.
233 * `api`: Tasks associated with using the Zabbix API to connect and modify the Zabbix server.
234 * `config`: Tasks associated with the configuration of Zabbix or a supporting service.
235 * `service`: Tasks associated with managing a service.
236
237 # Example Playbook
238
239 There are two ways of using the zabbix-web:
240
241 * Single instance
242 * Multi host setup
243
244 ## Single instance
245
246 When there is one host running both Zabbix Server and the Zabbix Web (Running MySQL as database):
247
248 ```yaml
249 - hosts: zabbix-server
250 become: yes
251 roles:
252 - role: geerlingguy.apache
253 - role: geerlingguy.php
254 - role: community.zabbix.zabbix_server
255 zabbix_server_database: mysql
256 zabbix_db_type_long: mysql
257 zabbix_server_dbport: 3306
258 - role: community.zabbix.zabbix_web
259 zabbix_api_server_url: zabbix.mydomain.com
260 zabbix_server_database: mysql
261 zabbix_db_type_long: mysql
262 zabbix_server_dbport: 3306
263 ```
264
265 ## Multi host setup
266
267 This is a two host setup. On one host (Named: "zabbix-server") the Zabbix Server is running, and the other host (Named: zabbix-web) runs Zabbix Web (with MySQL as database):
268
269 ```yaml
270 - hosts: zabbix-server
271 become: yes
272 roles:
273 - role: community.zabbix.zabbix_server
274 zabbix_server_database: mysql
275 zabbix_db_type_long: mysql
276 zabbix_server_dbport: 3306
277
278 - hosts: zabbix-web
279 become: yes
280 roles:
281 - role: geerlingguy.apache
282 - role: geerlingguy.php
283 - role: community.zabbix.zabbix_web
284 zabbix_api_server_url: zabbix.mydomain.com
285 zabbix_server_hostname: zabbix-server
286 zabbix_server_database: mysql
287 zabbix_db_type_long: mysql
288 zabbix_server_dbport: 3306
289 ```
290
291 ## Adding Environment Variables for zabbix_web
292
293 Sometimes you need to add environment variables to your
294 zabbix.conf.php, for example to add LDAP CA certificates. To do this add a `zabbix_web_env` dictionary:
295
296 ```yaml
297 - hosts: zabbix-web
298 become: yes
299 roles:
300 - role: geerlingguy.apache
301 - role: geerlingguy.php
302 php_memory_limit: "128M"
303 php_max_execution_time: "300"
304 php_upload_max_filesize: "256M"
305 php_packages:
306 - php
307 - php-fpm
308 - php-apcu
309 - role: geerlingguy.apache-php-fpm
310 - role: community.zabbix.zabbix_web
311 zabbix_api_server_url: zabbix.mydomain.com
312 zabbix_server_hostname: zabbix-server
313 zabbix_server_database: mysql
314 zabbix_db_type_long: mysql
315 zabbix_server_dbport: 3306
316 zabbix_web_env:
317 LDAPTLS_CACERT: /etc/ssl/certs/ourcert.pem
318 ```
319
320 ## Using Elasticsearch for history storage
321
322 To use Elasticsearch for history storage you need to configure the `zabbix_server_history_url` and `zabbix_server_history_types`. You will also need to configure Elasticsearch
323 in the zabbix_server role.
324
325 Zabbix can store the following history types
326 in Elasticsearch:
327 * Numeric (unsigned) - `uint`
328 * Numeric (float) - `dbl`
329 * Character - `str`
330 * Log - `log`
331 * Text - `text`
332
333 To store all history types in the same history URL the following variables should be set (make sure history url points to your Elasticsearch cluster):
334
335 ```
336 zabbix_server_history_url: "http://localhost:9200"
337 zabbix_server_history_types:
338 - 'str'
339 - 'text'
340 - 'log'
341 - 'uint'
342 - 'dbl'
343 ```
344
345 # Molecule
346
347 This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule:
348
349 * http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/
350 * http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/
351 * http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/
352
353 With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully.
354
355 # License
356
357 GNU General Public License v3.0 or later
358
359 See LICENCE to see the full text.
360
361 # Author Information
362
363 Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role.
364
365 Github: https://github.com/ansible-collections/community.zabbix