--- # Tasks specific for Debian/Ubuntu Systems - name: "Debian | Set some variables" ansible.builtin.set_fact: zabbix_short_version: "{{ zabbix_agent_version | regex_replace('\\.', '') }}" zabbix_underscore_version: "{{ zabbix_agent_version | regex_replace('\\.', '_') }}" tags: - always - name: "Debian | Repo URL" ansible.builtin.set_fact: zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}{{ '-arm64' if ansible_machine == 'aarch64' else ''}}" when: - zabbix_repo_deb_url is undefined tags: - always - name: "Debian | Installing gnupg" ansible.builtin.apt: pkg: gnupg update_cache: true cache_valid_time: 3600 force: true state: present environment: http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" register: gnupg_installed until: gnupg_installed is succeeded become: true tags: - install # In releases older than Debian 12 and Ubuntu 22.04, /etc/apt/keyrings does not exist by default. # It SHOULD be created with permissions 0755 if it is needed and does not already exist. # See: https://wiki.debian.org/DebianRepository/UseThirdParty - name: "Debian | Create /etc/apt/keyrings/ on older versions" ansible.builtin.file: path: /etc/apt/keyrings/ state: directory mode: "0755" become: true when: - (ansible_distribution == "Ubuntu" and ansible_distribution_major_version < "22") or (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" mode: "0644" force: true environment: http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" become: true tags: - install - name: "Debian | Installing repository {{ ansible_distribution }}" ansible.builtin.copy: dest: /etc/apt/sources.list.d/zabbix.sources owner: root group: root mode: 0644 content: | Types: deb deb-src Enabled: yes URIs: {{ zabbix_repo_deb_url }} Suites: {{ ansible_distribution_release }} Components: {{ zabbix_repo_deb_component }} Architectures: {{ 'amd64' if ansible_machine != 'aarch64' else 'arm64'}} Signed-By: {{ zabbix_gpg_key }} become: true tags: - install - name: "Debian | Create /etc/apt/preferences.d/" ansible.builtin.file: path: /etc/apt/preferences.d/ state: directory mode: "0755" when: - zabbix_agent_apt_priority | int become: true tags: - install - name: "Debian | Configuring the weight for APT" ansible.builtin.copy: dest: "/etc/apt/preferences.d/zabbix-agent-{{ zabbix_underscore_version }}" content: | Package: {{ zabbix_agent_package }} Pin: origin repo.zabbix.com Pin-Priority: {{ zabbix_agent_apt_priority | int }} owner: root mode: "0644" when: - zabbix_agent_apt_priority | int become: true tags: - install - name: "Debian | Installing zabbix-agent" ansible.builtin.apt: pkg: "{{ zabbix_agent_package }}" state: "{{ zabbix_agent_package_state }}" update_cache: true cache_valid_time: 0 force_apt_get: "{{ zabbix_apt_force_apt_get }}" install_recommends: "{{ zabbix_apt_install_recommends }}" environment: http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" register: zabbix_agent_package_installed until: zabbix_agent_package_installed is succeeded become: true tags: - install - name: "Debian | Installing zabbix-{sender,get}" ansible.builtin.apt: pkg: - "{{ zabbix_sender_package }}" - "{{ zabbix_get_package }}" state: "{{ zabbix_agent_package_state }}" update_cache: true cache_valid_time: 0 force_apt_get: "{{ zabbix_apt_force_apt_get }}" install_recommends: "{{ zabbix_apt_install_recommends }}" environment: http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" when: - not zabbix_agent_install_agent_only register: zabbix_agent_package_installed until: zabbix_agent_package_installed is succeeded become: true check_mode: false tags: - install - name: "Debian | Enable the service" ansible.builtin.service: name: "{{ zabbix_agent_service }}" enabled: true use: service become: true tags: - service