---
- name: "Debian | Installing zabbix-java-gateway"
  ansible.builtin.apt:
    pkg: zabbix-java-gateway
    state: "{{ zabbix_javagateway_package_state }}"
    update_cache: true
    force: true
    cache_valid_time: 3600
  environment:
    http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
    https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
  register: zabbix_java_gateway_install
  until: zabbix_java_gateway_install is succeeded
  become: true
  tags:
    - install

- name: "Debian | Make sure Zabbix Java Gateway is not yet running"
  ansible.builtin.systemd:
    name: zabbix-java-gateway
    state: stopped
    enabled: true
    daemon_reload: true
  become: true
  when:
    - zabbix_java_gateway_install.changed
  tags:
    - service
