--- # tasks file for zabbix_agent - name: "Include OS-specific variables" ansible.builtin.include_vars: "{{ ansible_facts.os_family }}.yml" tags: - always - name: Determine Latest Supported Zabbix Version ansible.builtin.set_fact: zabbix_agent_version: "{{ zabbix_valid_agent_versions[ansible_facts.distribution_major_version][0] | default(7.2) }}" when: zabbix_agent_version is not defined or zabbix_agent_version is none tags: - always - name: Check that version is supported when: zabbix_agent_version_check | bool ansible.builtin.assert: that: - zabbix_agent_version | float in zabbix_valid_agent_versions[ansible_facts.distribution_major_version] fail_msg: Zabbix version {{ zabbix_agent_version }} is not supported on {{ ansible_facts.distribution }} {{ ansible_facts.distribution_major_version }} tags: - always - name: Load Appropriate Defaults ansible.builtin.include_vars: "{{ zabbix_agent2 | ternary('agent2', 'agent') }}_vars.yml" - when: zabbix_agent_tlspsk_auto | bool tags: - config block: - name: AutoPSK | Default tlsconnect to enforce PSK ansible.builtin.set_fact: zabbix_agent_tlsconnect: psk - name: AutoPSK | Default tlsaccept to enforce PSK when zabbix_agent_tlsaccept is not defined ansible.builtin.set_fact: zabbix_agent_tlsaccept: psk when: not zabbix_agent_tlsaccept is defined - name: AutoPSK | Default tlsaccept to enforce PSK when zabbix_agent_tlsaccept is defined ansible.builtin.set_fact: zabbix_agent_tlsaccept: "{{ 'psk,' + zabbix_agent_tlsaccept }}" when: - zabbix_agent_tlsaccept is defined - not 'psk' in zabbix_agent_tlsaccept - name: Install Repository ansible.builtin.include_role: name: community.zabbix.zabbix_repo vars: zabbix_repo_version: "{{ zabbix_agent_version }}" zabbix_repo_package: "{{ zabbix_agent_package }}" when: - zabbix_manage_repo | default(true) - not (zabbix_agent_docker | bool) - ansible_facts['os_family'] not in ['Alpine', 'Darwin', 'FreeBSD', 'Windows'] - name: "Install the agent" when: not (zabbix_agent_docker | bool) ansible.builtin.include_tasks: "{{ _install_tasks_file }}" with_first_found: - "install-{{ ansible_facts['os_family'] }}.yml" - "install.yml" loop_control: loop_var: _install_tasks_file - name: "Configure Agent" when: ansible_facts['os_family'] not in ['Darwin'] ansible.builtin.include_tasks: "{{ _configure_tasks_file }}" with_first_found: - "configure-{{ ansible_facts['os_family'] }}.yml" - "configure{% if zabbix_agent_docker %}-Docker{% endif %}.yml" loop_control: loop_var: _configure_tasks_file - name: "Run the API calls to Zabbix Server" vars: ansible_network_os: community.zabbix.zabbix ansible_connection: httpapi ansible_httpapi_use_ssl: "{{ zabbix_api_use_ssl }}" # --- Basic Auth (Begin) --- http_login_user: "{{ zabbix_api_http_user | default(-42) }}" http_login_password: "{{ zabbix_api_http_password | default(-42) }}" # --- Basic Auth (End) --- ansible_user: "{{ zabbix_api_login_user }}" ansible_httpapi_pass: "{{ zabbix_api_login_pass }}" ansible_httpapi_port: "{{ zabbix_api_server_port }}" ansible_httpapi_validate_certs: "{{ zabbix_api_validate_certs }}" ansible.builtin.include_tasks: api.yml when: - (zabbix_api_create_hostgroup | bool) or (zabbix_api_create_hosts | bool) tags: - api - name: "Including userparameters" ansible.builtin.include_tasks: "userparameter.yml" when: zabbix_agent_userparameters | default ([]) | length > 0 tags: - config