| 1 |
--- |
| 2 |
- name: "Include OS-specific variables" |
| 3 |
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml" |
| 4 |
tags: |
| 5 |
- always |
| 6 |
|
| 7 |
- name: Determine Latest Supported Zabbix Version |
| 8 |
ansible.builtin.set_fact: |
| 9 |
zabbix_web_version: "{{ zabbix_valid_web_versions[ansible_facts['distribution_major_version']][0] | default(7.2) }}" |
| 10 |
when: zabbix_web_version is not defined |
| 11 |
tags: |
| 12 |
- always |
| 13 |
|
| 14 |
- name: Set More Variables |
| 15 |
ansible.builtin.set_fact: |
| 16 |
zabbix_db_type_long: "{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }}" |
| 17 |
tags: |
| 18 |
- always |
| 19 |
|
| 20 |
- name: Check that version is supported |
| 21 |
when: zabbix_web_version_check | bool |
| 22 |
ansible.builtin.assert: |
| 23 |
that: |
| 24 |
- "{{ zabbix_web_version|float in zabbix_valid_web_versions[ ansible_facts['distribution_major_version'] ] }}" |
| 25 |
fail_msg: Zabbix version {{ zabbix_web_version }} is not supported on {{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_major_version'] }} |
| 26 |
tags: |
| 27 |
- always |
| 28 |
|
| 29 |
- name: Determine PHP Version |
| 30 |
ansible.builtin.shell: php --version | head -1 | awk '{ print $2 }' | awk -F '.' '{print $1"."$2}' |
| 31 |
register: _zabbix_web_php_installed_version |
| 32 |
changed_when: false |
| 33 |
tags: |
| 34 |
- config |
| 35 |
- install |
| 36 |
|
| 37 |
- name: Set PHP Version |
| 38 |
ansible.builtin.set_fact: |
| 39 |
zabbix_web_php_installed_version: "{{ _zabbix_web_php_installed_version.stdout }}" |
| 40 |
tags: |
| 41 |
- config |
| 42 |
- install |
| 43 |
|
| 44 |
- name: Set PHP Variables |
| 45 |
ansible.builtin.set_fact: |
| 46 |
zabbix_php_fpm_listen: "{{ zabbix_php_fpm_listen if zabbix_php_fpm_listen is defined else _zabbix_php_fpm_listen }}" |
| 47 |
zabbix_php_fpm_dir: "{{ zabbix_php_fpm_dir if zabbix_php_fpm_dir is defined else _php_fpm_dir }}" |
| 48 |
zabbix_php_fpm_session: "{{ zabbix_php_fpm_session if zabbix_php_fpm_session is defined else _php_fpm_session }}" |
| 49 |
tags: |
| 50 |
- config |
| 51 |
- install |
| 52 |
|
| 53 |
- name: Install Repository |
| 54 |
ansible.builtin.include_role: |
| 55 |
name: community.zabbix.zabbix_repo |
| 56 |
vars: |
| 57 |
zabbix_repo_version: "{{ zabbix_web_version }}" |
| 58 |
zabbix_repo_package: "zabbix-web-service" |
| 59 |
when: zabbix_manage_repo | default(true) |
| 60 |
|
| 61 |
- name: Include OS Specific Tasks |
| 62 |
ansible.builtin.include_tasks: "{{ ansible_facts['os_family'] }}.yml" |
| 63 |
|
| 64 |
- name: "Install zabbix-web package" |
| 65 |
ansible.builtin.package: |
| 66 |
name: "{{ _zabbix_web_package }}" |
| 67 |
state: "{{ zabbix_web_package_state }}" |
| 68 |
update_cache: true |
| 69 |
disablerepo: "{{ zabbix_web_disable_repo | default(_zabbix_web_disable_repo | default(omit)) }}" |
| 70 |
environment: |
| 71 |
http_proxy: "{{ zabbix_http_proxy | default('') }}" |
| 72 |
https_proxy: "{{ zabbix_https_proxy | default('') }}" |
| 73 |
register: _zabbix_web_package_installed |
| 74 |
until: _zabbix_web_package_installed is succeeded |
| 75 |
become: true |
| 76 |
tags: |
| 77 |
- install |
| 78 |
|
| 79 |
- name: "Debian | Link graphfont.ttf (workaround ZBX-10467)" |
| 80 |
when: |
| 81 |
- ansible_facts['os_family'] == 'Debian' |
| 82 |
- zabbix_web_version is version ('7.2', '<') |
| 83 |
ansible.builtin.file: |
| 84 |
src: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" |
| 85 |
path: "/usr/share/zabbix/fonts/graphfont.ttf" |
| 86 |
state: link |
| 87 |
become: true |
| 88 |
tags: |
| 89 |
- install |
| 90 |
|
| 91 |
- name: "Install the web server specific tasks" |
| 92 |
ansible.builtin.include_tasks: "{{ zabbix_web_http_server }}.yml" |
| 93 |
|
| 94 |
- name: "Create zabbix-web directory" |
| 95 |
ansible.builtin.file: |
| 96 |
path: /etc/zabbix/web |
| 97 |
owner: "{{ zabbix_php_fpm_conf_user }}" |
| 98 |
group: root |
| 99 |
state: directory |
| 100 |
mode: 0755 |
| 101 |
become: true |
| 102 |
tags: |
| 103 |
- install |
| 104 |
- config |
| 105 |
|
| 106 |
- name: "Configure zabbix-web" |
| 107 |
ansible.builtin.template: |
| 108 |
src: zabbix.conf.php.j2 |
| 109 |
dest: /etc/zabbix/web/zabbix.conf.php |
| 110 |
owner: "{{ zabbix_php_fpm_conf_user }}" |
| 111 |
group: "{{ zabbix_php_fpm_conf_group }}" |
| 112 |
mode: "{{ zabbix_web_conf_mode }}" |
| 113 |
become: true |
| 114 |
tags: |
| 115 |
- config |
| 116 |
|
| 117 |
- name: "Install PHP" |
| 118 |
ansible.builtin.template: |
| 119 |
src: php-fpm.conf.j2 |
| 120 |
dest: "{{ zabbix_php_fpm_dir }}/zabbix.conf" |
| 121 |
owner: "{{ zabbix_php_fpm_conf_user }}" |
| 122 |
group: "{{ zabbix_php_fpm_conf_group }}" |
| 123 |
mode: 0644 |
| 124 |
become: true |
| 125 |
when: |
| 126 |
- zabbix_web_create_php_fpm |
| 127 |
notify: |
| 128 |
- restart php-fpm-version |
| 129 |
- restart php-fpm |
| 130 |
tags: |
| 131 |
- config |