95 lines
3.3 KiB
YAML
95 lines
3.3 KiB
YAML
---
|
|
# tasks file for zabbix_agent
|
|
- name: "Include OS-specific variables"
|
|
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
|
|
tags:
|
|
- always
|
|
|
|
- name: Determine Latest Supported Zabbix Version
|
|
ansible.builtin.set_fact:
|
|
zabbix_agent_version: "{{ zabbix_valid_agent_versions[ansible_distribution_major_version][0] | default(6.4) }}"
|
|
when: zabbix_agent_version is not defined or zabbix_agent_version is none
|
|
tags:
|
|
- always
|
|
|
|
- name: Set More Variables
|
|
ansible.builtin.set_fact:
|
|
zabbix_valid_version: "{{ zabbix_agent_version|float in zabbix_valid_agent_versions[ansible_distribution_major_version] }}"
|
|
tags:
|
|
- always
|
|
|
|
- name: Stopping Install of Invalid Version
|
|
ansible.builtin.fail:
|
|
msg: Zabbix version {{ zabbix_agent_version }} is not supported on {{ ansible_distribution }} {{ ansible_distribution_major_version }}
|
|
when: not zabbix_valid_version
|
|
tags:
|
|
- always
|
|
|
|
- name: Setting Zabbix API Server Port
|
|
ansible.builtin.set_fact:
|
|
zabbix_api_server_port: "{{ '443' if zabbix_api_use_ssl|bool else '80' }}"
|
|
when: zabbix_api_server_port is undefined
|
|
|
|
- name: "Set variables specific for Zabbix Agent 2"
|
|
ansible.builtin.set_fact:
|
|
zabbix_agent_service: zabbix-agent2
|
|
zabbix_agent_package: zabbix-agent2
|
|
when:
|
|
- zabbix_agent2 is defined
|
|
- zabbix_agent2
|
|
tags:
|
|
- always
|
|
|
|
- name: "Install the correct repository"
|
|
ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml"
|
|
when:
|
|
- not (zabbix_agent_docker | bool)
|
|
|
|
- name: "Encrypt with TLS PSK auto management"
|
|
ansible.builtin.include_tasks: tlspsk_auto.yml
|
|
when:
|
|
- not zabbix_agent2
|
|
- zabbix_agent_tlspsk_auto | bool
|
|
- (zabbix_agent_tlspskfile is undefined) or (zabbix_agent_tlspskfile | length == '0')
|
|
- (zabbix_agent_tlspsk_secret is undefined) or (zabbix_agent_tlspsk_secret | length == '0')
|
|
|
|
- name: "Encrypt with TLS PSK auto management"
|
|
ansible.builtin.include_tasks: tlspsk_auto_agent2.yml
|
|
when:
|
|
- zabbix_agent2 | bool
|
|
- zabbix_agent2_tlspsk_auto | bool
|
|
- (zabbix_agent2_tlspskfile is undefined) or (zabbix_agent2_tlspskfile | length == '0')
|
|
- (zabbix_agent2_tlspsk_secret is undefined) or (zabbix_agent2_tlspsk_secret | length == '0')
|
|
|
|
- name: "Configure Agent"
|
|
ansible.builtin.include_tasks: Windows_conf.yml
|
|
when:
|
|
- ansible_os_family == "Windows"
|
|
|
|
- name: "Configure Agent"
|
|
ansible.builtin.include_tasks: Linux.yml
|
|
when:
|
|
- (ansible_os_family != "Windows" and ansible_os_family != "Darwin") or (zabbix_agent_docker | bool)
|
|
|
|
- name: "Run the API calls to Zabbix Server"
|
|
vars:
|
|
gather_facts: false
|
|
ansible_user: "{{ zabbix_api_login_user }}"
|
|
ansible_httpapi_use_ssl: "{{ zabbix_api_use_ssl }}"
|
|
ansible_network_os: community.zabbix.zabbix
|
|
ansible_connection: httpapi
|
|
# Can't think of a way to make http_login_* vars be undefined -(
|
|
http_login_user: "{{ zabbix_api_http_user | default(-42) }}"
|
|
http_login_password: "{{ zabbix_api_http_password | default(-42) }}"
|
|
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|length > 0
|
|
tags:
|
|
- config
|