---
# Tasks specific for SUSE systems

- name: Check if warn parameter can be used for shell module
  ansible.builtin.set_fact:
    produce_warn: false
  when: ansible_version.full is version("2.14", "<")
  tags:
    - always

- name: "Suse | Installing zabbix-agent"
  ansible.builtin.package:
    pkg:
      - "{{ zabbix_agent_package }}"
    state: "{{ zabbix_agent_package_state }}"
  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: "Suse | Installing zabbix-{sender,get}"
  ansible.builtin.package:
    pkg:
      - "{{ zabbix_agent_sender_package }}"
      - "{{ zabbox_agent_get_package }}"
    state: "{{ zabbix_agent_package_state }}"
  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
  when:
    - not zabbix_agent_install_agent_only
  become: true
  tags:
    - install

- name: "Suse | Enable the service"
  ansible.builtin.service:
    name: "{{ zabbix_agent_service }}"
    enabled: true
    use: service
  become: true
  tags:
    - service
