inventory add

This commit is contained in:
root
2023-11-28 14:51:57 +09:00
parent de41743f2f
commit 2dcaeada28
44 changed files with 3024 additions and 2950 deletions

View File

@@ -1,2 +1,2 @@
[defaults] [defaults]
stdout_callback = debug stdout_callback = debug

View File

@@ -1,3 +1,3 @@
collections: collections:
- name: ansible.utils - name: ansible.utils
- name: community.zabbix - name: community.zabbix

View File

@@ -1,5 +1,79 @@
[server] [server]
10.10.34.40 ansible_port=22001 ansible_user=ai 10.10.43.100 ansible_port=2222 ansible_user=dev2-iac
10.10.43.101 ansible_port=2222 ansible_user=dev2-iac
[all:children] 10.10.43.105 ansible_port=2222 ansible_user=dev2-iac
server 10.10.43.106 ansible_port=2222 ansible_user=dev2-iac
10.10.43.111 ansible_port=2222 ansible_user=dev2-iac
10.10.43.112 ansible_port=2222 ansible_user=dev2-iac
10.10.43.113 ansible_port=2222 ansible_user=dev2-iac
10.10.43.114 ansible_port=2222 ansible_user=dev2-iac
10.10.43.115 ansible_port=2222 ansible_user=dev2-iac
10.10.43.116 ansible_port=2222 ansible_user=dev2-iac
10.10.43.117 ansible_port=2222 ansible_user=dev2-iac
10.10.43.118 ansible_port=2222 ansible_user=dev2-iac
10.10.43.119 ansible_port=2222 ansible_user=dev2-iac
10.10.43.120 ansible_port=2222 ansible_user=dev2-iac
10.10.43.121 ansible_port=2222 ansible_user=dev2-iac
10.10.43.122 ansible_port=2222 ansible_user=dev2-iac
10.10.43.123 ansible_port=2222 ansible_user=dev2-iac
10.10.43.124 ansible_port=2222 ansible_user=dev2-iac
10.10.43.125 ansible_port=2222 ansible_user=dev2-iac
10.10.43.126 ansible_port=2222 ansible_user=dev2-iac
10.10.43.127 ansible_port=2222 ansible_user=dev2-iac
10.10.43.128 ansible_port=2222 ansible_user=dev2-iac
10.10.43.129 ansible_port=2222 ansible_user=dev2-iac
10.10.43.130 ansible_port=2222 ansible_user=dev2-iac
10.10.43.131 ansible_port=2222 ansible_user=dev2-iac
10.10.43.132 ansible_port=2222 ansible_user=dev2-iac
10.10.43.133 ansible_port=2222 ansible_user=dev2-iac
10.10.43.134 ansible_port=2222 ansible_user=dev2-iac
10.10.43.135 ansible_port=2222 ansible_user=dev2-iac
10.10.43.136 ansible_port=2222 ansible_user=dev2-iac
10.10.43.137 ansible_port=2222 ansible_user=dev2-iac
10.10.43.138 ansible_port=2222 ansible_user=dev2-iac
10.10.43.139 ansible_port=2222 ansible_user=dev2-iac
10.10.43.140 ansible_port=2222 ansible_user=dev2-iac
10.10.43.141 ansible_port=2222 ansible_user=dev2-iac
10.10.43.142 ansible_port=2222 ansible_user=dev2-iac
10.10.43.143 ansible_port=2222 ansible_user=dev2-iac
10.10.43.144 ansible_port=2222 ansible_user=dev2-iac
10.10.43.145 ansible_port=2222 ansible_user=dev2-iac
10.10.43.146 ansible_port=2222 ansible_user=dev2-iac
10.10.43.147 ansible_port=2222 ansible_user=dev2-iac
10.10.43.148 ansible_port=2222 ansible_user=dev2-iac
10.10.43.151 ansible_port=2222 ansible_user=dev2-iac
10.10.43.152 ansible_port=2222 ansible_user=dev2-iac
10.10.43.153 ansible_port=2222 ansible_user=dev2-iac
10.10.43.164 ansible_port=2222 ansible_user=dev2-iac
10.10.43.165 ansible_port=2222 ansible_user=dev2-iac
10.10.43.166 ansible_port=2222 ansible_user=dev2-iac
10.10.43.167 ansible_port=2222 ansible_user=dev2-iac
10.10.43.168 ansible_port=2222 ansible_user=dev2-iac
10.10.43.169 ansible_port=2222 ansible_user=dev2-iac
10.10.43.171 ansible_port=2222 ansible_user=dev2-iac
10.10.43.172 ansible_port=2222 ansible_user=dev2-iac
10.10.43.173 ansible_port=2222 ansible_user=dev2-iac
10.10.43.174 ansible_port=2222 ansible_user=dev2-iac
10.10.43.175 ansible_port=2222 ansible_user=dev2-iac
10.10.43.176 ansible_port=2222 ansible_user=dev2-iac
10.10.43.177 ansible_port=2222 ansible_user=dev2-iac
10.10.43.178 ansible_port=2222 ansible_user=dev2-iac
10.10.43.179 ansible_port=2222 ansible_user=dev2-iac
10.10.43.180 ansible_port=2222 ansible_user=dev2-iac
10.10.43.181 ansible_port=2222 ansible_user=dev2-iac
10.10.43.182 ansible_port=2222 ansible_user=dev2-iac
10.10.43.185 ansible_port=2222 ansible_user=dev2-iac
10.10.43.186 ansible_port=2222 ansible_user=dev2-iac
10.10.43.187 ansible_port=2222 ansible_user=dev2-iac
10.10.43.188 ansible_port=2222 ansible_user=dev2-iac
10.10.43.189 ansible_port=2222 ansible_user=dev2-iac
10.10.43.190 ansible_port=2222 ansible_user=dev2-iac
10.10.43.191 ansible_port=2222 ansible_user=dev2-iac
10.10.43.192 ansible_port=2222 ansible_user=dev2-iac
10.10.43.193 ansible_port=2222 ansible_user=dev2-iac
10.10.43.194 ansible_port=2222 ansible_user=dev2-iac
10.10.43.199 ansible_port=2222 ansible_user=dev2-iac
[all:children]
server

View File

@@ -1,292 +1,292 @@
--- ---
# defaults file for zabbix_agent # defaults file for zabbix_agent
zabbix_agent2: false zabbix_agent2: false
# zabbix_agent_version: 6.4 # zabbix_agent_version: 6.4
zabbix_agent_version_minor: "*" zabbix_agent_version_minor: "*"
zabbix_version_patch: 0 zabbix_version_patch: 0
zabbix_agent_package_remove: false zabbix_agent_package_remove: false
zabbix_agent_package: zabbix-agent zabbix_agent_package: zabbix-agent
zabbix_sender_package: zabbix-sender zabbix_sender_package: zabbix-sender
zabbix_get_package: zabbix-get zabbix_get_package: zabbix-get
zabbix_agent_package_state: present zabbix_agent_package_state: present
zabbix_agent_server: zabbix_agent_server:
zabbix_agent_serveractive: zabbix_agent_serveractive:
zabbix_agent2_server: "{{ zabbix_agent_server }}" zabbix_agent2_server: "{{ zabbix_agent_server }}"
zabbix_agent2_serveractive: "{{ zabbix_agent_serveractive }}" zabbix_agent2_serveractive: "{{ zabbix_agent_serveractive }}"
zabbix_selinux: false zabbix_selinux: false
zabbix_agent_apt_priority: zabbix_agent_apt_priority:
zabbix_agent_conf_mode: "0644" zabbix_agent_conf_mode: "0644"
zabbix_agent_dont_detect_ip: false zabbix_agent_dont_detect_ip: false
zabbix_agent_allow_key: [] zabbix_agent_allow_key: []
zabbix_agent_deny_key: [] zabbix_agent_deny_key: []
zabbix_agent2_allow_key: "{{ zabbix_agent_allow_key }}" zabbix_agent2_allow_key: "{{ zabbix_agent_allow_key }}"
zabbix_agent2_deny_key: "{{ zabbix_agent_deny_key }}" zabbix_agent2_deny_key: "{{ zabbix_agent_deny_key }}"
# Selinux related vars # Selinux related vars
selinux_allow_zabbix_run_sudo: false selinux_allow_zabbix_run_sudo: false
zabbix_agent_install_agent_only: false zabbix_agent_install_agent_only: false
zabbix_agent_packages: zabbix_agent_packages:
- "{{ zabbix_agent_package }}" - "{{ zabbix_agent_package }}"
- "{{ zabbix_sender_package }}" - "{{ zabbix_sender_package }}"
- "{{ zabbix_get_package }}" - "{{ zabbix_get_package }}"
# Zabbix role related vars # Zabbix role related vars
zabbix_apt_force_apt_get: true zabbix_apt_force_apt_get: true
zabbix_apt_install_recommends: false zabbix_apt_install_recommends: false
# Override Ansible specific facts # Override Ansible specific facts
zabbix_agent_distribution_major_version: "{{ ansible_distribution_major_version }}" zabbix_agent_distribution_major_version: "{{ ansible_distribution_major_version }}"
zabbix_agent_distribution_release: "{{ ansible_distribution_release }}" zabbix_agent_distribution_release: "{{ ansible_distribution_release }}"
zabbix_repo_yum_gpgcheck: 0 zabbix_repo_yum_gpgcheck: 0
zabbix_repo_yum_schema: https zabbix_repo_yum_schema: https
zabbix_agent_disable_repo: zabbix_agent_disable_repo:
- epel - epel
zabbix_repo_yum: zabbix_repo_yum:
- name: zabbix - name: zabbix
description: Zabbix Official Repository - $basearch description: Zabbix Official Repository - $basearch
baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/" baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/"
mode: "0644" mode: "0644"
gpgcheck: "{{ zabbix_repo_yum_gpgcheck }}" gpgcheck: "{{ zabbix_repo_yum_gpgcheck }}"
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
state: present state: present
- name: zabbix-non-supported - name: zabbix-non-supported
description: Zabbix Official Repository non-supported - $basearch description: Zabbix Official Repository non-supported - $basearch
baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/" baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/"
mode: "0644" mode: "0644"
gpgcheck: "{{ zabbix_repo_yum_gpgcheck }}" gpgcheck: "{{ zabbix_repo_yum_gpgcheck }}"
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
state: present state: present
- name: zabbix-agent2-plugins - name: zabbix-agent2-plugins
description: Zabbix Official Repository (Agent2 Plugins) - $basearch description: Zabbix Official Repository (Agent2 Plugins) - $basearch
baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix-agent2-plugins/1/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/" baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix-agent2-plugins/1/rhel/{{ zabbix_agent_distribution_major_version }}/$basearch/"
mode: "0644" mode: "0644"
gpgcheck: "{{ zabbix_repo_yum_gpgcheck }}" gpgcheck: "{{ zabbix_repo_yum_gpgcheck }}"
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
state: present state: present
zabbix_repo_deb_component: main zabbix_repo_deb_component: main
# Zabbix API stuff # Zabbix API stuff
zabbix_api_server_host: localhost zabbix_api_server_host: localhost
# zabbix_api_server_port: 80 # zabbix_api_server_port: 80
zabbix_api_login_user: Admin zabbix_api_login_user: Admin
zabbix_api_use_ssl: false zabbix_api_use_ssl: false
zabbix_api_login_pass: !unsafe zabbix zabbix_api_login_pass: !unsafe zabbix
zabbix_api_validate_certs: false zabbix_api_validate_certs: false
ansible_httpapi_pass: "{{ zabbix_api_login_pass }}" ansible_httpapi_pass: "{{ zabbix_api_login_pass }}"
ansible_httpapi_port: "{{ zabbix_api_server_port }}" ansible_httpapi_port: "{{ zabbix_api_server_port }}"
ansible_httpapi_validate_certs: "{{ zabbix_api_validate_certs }}" ansible_httpapi_validate_certs: "{{ zabbix_api_validate_certs }}"
zabbix_api_timeout: 30 zabbix_api_timeout: 30
zabbix_api_create_hostgroup: false zabbix_api_create_hostgroup: false
zabbix_api_create_hosts: false zabbix_api_create_hosts: false
zabbix_agent_hostgroups_state: present # or absent zabbix_agent_hostgroups_state: present # or absent
zabbix_agent_host_state: present # or absent zabbix_agent_host_state: present # or absent
zabbix_agent_host_update: true zabbix_agent_host_update: true
zabbix_host_status: enabled # or disabled zabbix_host_status: enabled # or disabled
zabbix_agent_proxy: null zabbix_agent_proxy: null
zabbix_agent_inventory_mode: disabled zabbix_agent_inventory_mode: disabled
zabbix_useuip: 1 zabbix_useuip: 1
zabbix_host_groups: zabbix_host_groups:
- Linux servers - Linux servers
zabbix_agent_link_templates: zabbix_agent_link_templates:
- Template Linux by Zabbix agent - Template Linux by Zabbix agent
zabbix_agent_interfaces: zabbix_agent_interfaces:
- type: 1 - type: 1
main: 1 main: 1
useip: "{{ zabbix_useuip }}" useip: "{{ zabbix_useuip }}"
ip: "{{ zabbix_agent_ip }}" ip: "{{ zabbix_agent_ip }}"
dns: "{{ ansible_fqdn }}" dns: "{{ ansible_fqdn }}"
port: "{{ (zabbix_agent2 == True) | ternary(zabbix_agent2_listenport, zabbix_agent_listenport) }}" port: "{{ (zabbix_agent2 == True) | ternary(zabbix_agent2_listenport, zabbix_agent_listenport) }}"
# Zabbix configuration variables # Zabbix configuration variables
zabbix_agent_pidfile: /var/run/zabbix/zabbix_agentd.pid zabbix_agent_pidfile: /var/run/zabbix/zabbix_agentd.pid
zabbix_agent_logtype: file zabbix_agent_logtype: file
zabbix_agent_logfile: /var/log/zabbix/zabbix_agentd.log zabbix_agent_logfile: /var/log/zabbix/zabbix_agentd.log
zabbix_agent_logfilesize: 100 zabbix_agent_logfilesize: 100
zabbix_agent_debuglevel: 3 zabbix_agent_debuglevel: 3
zabbix_agent_sourceip: zabbix_agent_sourceip:
zabbix_agent_enableremotecommands: 0 zabbix_agent_enableremotecommands: 0
zabbix_agent_allowkeys: zabbix_agent_allowkeys:
zabbix_agent_denykeys: zabbix_agent_denykeys:
zabbix_agent_logremotecommands: 0 zabbix_agent_logremotecommands: 0
zabbix_agent_listenport: 10050 zabbix_agent_listenport: 10050
zabbix_agent_jmx_listenport: zabbix_agent_jmx_listenport:
zabbix_agent_listeninterface: zabbix_agent_listeninterface:
zabbix_agent_listenip: zabbix_agent_listenip:
zabbix_agent_startagents: 3 zabbix_agent_startagents: 3
zabbix_agent_hostname: "{{ inventory_hostname }}" zabbix_agent_hostname: "{{ inventory_hostname }}"
zabbix_agent_hostnameitem: zabbix_agent_hostnameitem:
zabbix_agent_hostmetadata: zabbix_agent_hostmetadata:
zabbix_agent_hostmetadataitem: zabbix_agent_hostmetadataitem:
zabbix_agent_refreshactivechecks: 120 zabbix_agent_refreshactivechecks: 120
zabbix_agent_buffersend: 5 zabbix_agent_buffersend: 5
zabbix_agent_buffersize: 100 zabbix_agent_buffersize: 100
zabbix_agent_maxlinespersecond: 100 zabbix_agent_maxlinespersecond: 100
zabbix_agent_allowroot: 0 zabbix_agent_allowroot: 0
zabbix_agent_zabbix_alias: zabbix_agent_zabbix_alias:
zabbix_agent_timeout: 3 zabbix_agent_timeout: 3
zabbix_agent_include: /etc/zabbix/zabbix_agentd.d zabbix_agent_include: /etc/zabbix/zabbix_agentd.d
zabbix_agent_include_pattern: zabbix_agent_include_pattern:
zabbix_agent_include_mode: "0750" zabbix_agent_include_mode: "0750"
zabbix_agent_unsafeuserparameters: 0 zabbix_agent_unsafeuserparameters: 0
zabbix_agent_userparameters: [] zabbix_agent_userparameters: []
zabbix_agent_userparameters_templates_src: "userparameters" zabbix_agent_userparameters_templates_src: "userparameters"
zabbix_agent_userparameters_scripts_src: "scripts" zabbix_agent_userparameters_scripts_src: "scripts"
zabbix_agent_custom_scripts: false zabbix_agent_custom_scripts: false
zabbix_agent_loadmodulepath: ${libdir}/modules zabbix_agent_loadmodulepath: ${libdir}/modules
zabbix_agent_loadmodule: zabbix_agent_loadmodule:
zabbix_agent_become_on_localhost: true zabbix_agent_become_on_localhost: true
zabbix_agent_description: zabbix_agent_description:
zabbix_agent_inventory_zabbix: {} zabbix_agent_inventory_zabbix: {}
zabbix_agent_heartbeatfrequency: 60 zabbix_agent_heartbeatfrequency: 60
zabbix_agent_macros: [] zabbix_agent_macros: []
zabbix_agent_tags: [] zabbix_agent_tags: []
zabbix_agent_chassis: false zabbix_agent_chassis: false
# TLS settings # TLS settings
zabbix_agent_tlsconnect: zabbix_agent_tlsconnect:
zabbix_agent_tlsaccept: zabbix_agent_tlsaccept:
zabbix_agent_tlscafile: zabbix_agent_tlscafile:
zabbix_agent_tlscrlfile: zabbix_agent_tlscrlfile:
zabbix_agent_tlsservercertissuer: zabbix_agent_tlsservercertissuer:
zabbix_agent_tlsservercertsubject: zabbix_agent_tlsservercertsubject:
zabbix_agent_tls_subject: "{{ zabbix_agent_tlsservercertsubject }}" # FIXME this is not correct and should be removed with 2.0.0, here only to prevent regression zabbix_agent_tls_subject: "{{ zabbix_agent_tlsservercertsubject }}" # FIXME this is not correct and should be removed with 2.0.0, here only to prevent regression
zabbix_agent_tlscertfile: zabbix_agent_tlscertfile:
zabbix_agent_tlskeyfile: zabbix_agent_tlskeyfile:
zabbix_agent_tlspskidentity: zabbix_agent_tlspskidentity:
zabbix_agent_tlspsk_auto: false zabbix_agent_tlspsk_auto: false
zabbix_agent_tls_config: zabbix_agent_tls_config:
unencrypted: "1" unencrypted: "1"
psk: "2" psk: "2"
cert: "4" cert: "4"
# IPMI settings # IPMI settings
zabbix_agent_ipmi_authtype: 2 zabbix_agent_ipmi_authtype: 2
zabbix_agent_ipmi_password: zabbix_agent_ipmi_password:
zabbix_agent_ipmi_privilege: 2 zabbix_agent_ipmi_privilege: 2
zabbix_agent_ipmi_username: zabbix_agent_ipmi_username:
# Zabbix Agent2 # Zabbix Agent2
zabbix_agent2_pidfile: /var/run/zabbix/zabbix_agent2.pid zabbix_agent2_pidfile: /var/run/zabbix/zabbix_agent2.pid
zabbix_agent2_logfile: /var/log/zabbix/zabbix_agent2.log zabbix_agent2_logfile: /var/log/zabbix/zabbix_agent2.log
zabbix_agent2_logtype: file zabbix_agent2_logtype: file
zabbix_agent2_statusport: 9999 zabbix_agent2_statusport: 9999
zabbix_agent2_include: /etc/zabbix/zabbix_agent2.d zabbix_agent2_include: /etc/zabbix/zabbix_agent2.d
zabbix_agent2_include_pattern: zabbix_agent2_include_pattern:
zabbix_agent2_logfilesize: 100 zabbix_agent2_logfilesize: 100
zabbix_agent2_debuglevel: 3 zabbix_agent2_debuglevel: 3
zabbix_agent2_sourceip: zabbix_agent2_sourceip:
zabbix_agent2_listenport: 10050 zabbix_agent2_listenport: 10050
zabbix_agent2_listenip: zabbix_agent2_listenip:
zabbix_agent2_hostname: "{{ inventory_hostname }}" zabbix_agent2_hostname: "{{ inventory_hostname }}"
zabbix_agent2_hostnameitem: zabbix_agent2_hostnameitem:
zabbix_agent2_hostmetadata: zabbix_agent2_hostmetadata:
zabbix_agent2_hostmetadataitem: zabbix_agent2_hostmetadataitem:
zabbix_agent2_hostinterface: zabbix_agent2_hostinterface:
zabbix_agent2_hostinterfaceitem: zabbix_agent2_hostinterfaceitem:
zabbix_agent2_enablepersistentbuffer: 0 zabbix_agent2_enablepersistentbuffer: 0
zabbix_agent2_persistentbufferperiod: 1h zabbix_agent2_persistentbufferperiod: 1h
zabbix_agent2_persistentbufferfile: zabbix_agent2_persistentbufferfile:
zabbix_agent2_refreshactivechecks: 120 zabbix_agent2_refreshactivechecks: 120
zabbix_agent2_buffersend: 5 zabbix_agent2_buffersend: 5
zabbix_agent2_buffersize: 100 zabbix_agent2_buffersize: 100
zabbix_agent2_zabbix_alias: zabbix_agent2_zabbix_alias:
zabbix_agent2_timeout: 3 zabbix_agent2_timeout: 3
zabbix_agent2_include_mode: "0750" zabbix_agent2_include_mode: "0750"
zabbix_agent2_unsafeuserparameters: 0 zabbix_agent2_unsafeuserparameters: 0
zabbix_agent2_controlsocket: /tmp/agent.sock zabbix_agent2_controlsocket: /tmp/agent.sock
zabbix_agent2_plugins: [] zabbix_agent2_plugins: []
# Zabbix Agent2 TLS settings # Zabbix Agent2 TLS settings
zabbix_agent2_tlsconnect: zabbix_agent2_tlsconnect:
zabbix_agent2_tlsaccept: zabbix_agent2_tlsaccept:
zabbix_agent2_tlscafile: zabbix_agent2_tlscafile:
zabbix_agent2_tlscrlfile: zabbix_agent2_tlscrlfile:
zabbix_agent2_tlsservercertissuer: zabbix_agent2_tlsservercertissuer:
zabbix_agent2_tlsservercertsubject: zabbix_agent2_tlsservercertsubject:
zabbix_agent2_tls_subject: "{{ zabbix_agent2_tlsservercertsubject }}" # FIXME this is not correct and should be removed with 2.0.0, here only to prevent regression zabbix_agent2_tls_subject: "{{ zabbix_agent2_tlsservercertsubject }}" # FIXME this is not correct and should be removed with 2.0.0, here only to prevent regression
zabbix_agent2_tlscertfile: zabbix_agent2_tlscertfile:
zabbix_agent2_tlskeyfile: zabbix_agent2_tlskeyfile:
zabbix_agent2_tlspskidentity: zabbix_agent2_tlspskidentity:
zabbix_agent2_tlspsk_auto: false zabbix_agent2_tlspsk_auto: false
# Windows/macOS Related # Windows/macOS Related
zabbix_version_long: 5.2.4 zabbix_version_long: 5.2.4
# Windows Related # Windows Related
zabbix_win_package: zabbix_agent-{{ zabbix_version_long }}-windows-amd64-openssl.zip zabbix_win_package: zabbix_agent-{{ zabbix_version_long }}-windows-amd64-openssl.zip
zabbix2_win_package: zabbix_agent2-{{ zabbix_version_long }}-windows-amd64-openssl-static.zip zabbix2_win_package: zabbix_agent2-{{ zabbix_version_long }}-windows-amd64-openssl-static.zip
zabbix_win_download_url: https://cdn.zabbix.com/zabbix/binaries/stable zabbix_win_download_url: https://cdn.zabbix.com/zabbix/binaries/stable
zabbix_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix_win_package }}" zabbix_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix_win_package }}"
zabbix2_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix2_win_package }}" zabbix2_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix2_win_package }}"
zabbix_win_install_dir: 'C:\Zabbix' zabbix_win_install_dir: 'C:\Zabbix'
zabbix_win_install_dir_conf: '{{ zabbix_win_install_dir }}\\conf' zabbix_win_install_dir_conf: '{{ zabbix_win_install_dir }}\\conf'
zabbix_win_install_dir_bin: '{{ zabbix_win_install_dir }}\\bin' zabbix_win_install_dir_bin: '{{ zabbix_win_install_dir }}\\bin'
zabbix_agent_win_logfile: "{{ zabbix_win_install_dir }}\\zabbix_agentd.log" zabbix_agent_win_logfile: "{{ zabbix_win_install_dir }}\\zabbix_agentd.log"
zabbix_agent_win_include: "{{ zabbix_win_install_dir }}\\zabbix_agent.d\\" zabbix_agent_win_include: "{{ zabbix_win_install_dir }}\\zabbix_agent.d\\"
zabbix_agent2_win_logfile: "{{ zabbix_win_install_dir }}\\zabbix_agent2.log" zabbix_agent2_win_logfile: "{{ zabbix_win_install_dir }}\\zabbix_agent2.log"
zabbix_agent_win_svc_recovery: true zabbix_agent_win_svc_recovery: true
zabbix_win_firewall_management: true zabbix_win_firewall_management: true
# macOS Related # macOS Related
zabbix_mac_package: zabbix_agent-{{ zabbix_version_long }}-macos-amd64-openssl.pkg zabbix_mac_package: zabbix_agent-{{ zabbix_version_long }}-macos-amd64-openssl.pkg
zabbix_mac_download_url: https://cdn.zabbix.com/zabbix/binaries/stable zabbix_mac_download_url: https://cdn.zabbix.com/zabbix/binaries/stable
zabbix_mac_download_link: "{{ zabbix_mac_download_url }}/{{ zabbix_agent_version }}/{{ zabbix_version_long }}/{{ zabbix_mac_package }}" zabbix_mac_download_link: "{{ zabbix_mac_download_url }}/{{ zabbix_agent_version }}/{{ zabbix_version_long }}/{{ zabbix_mac_package }}"
# Zabbix Agent Docker facts # Zabbix Agent Docker facts
zabbix_agent_docker: false zabbix_agent_docker: false
zabbix_agent_docker_state: started zabbix_agent_docker_state: started
zabbix_agent_docker_name: zabbix-agent zabbix_agent_docker_name: zabbix-agent
zabbix_agent_docker_image: "zabbix/zabbix-agent" zabbix_agent_docker_image: "zabbix/zabbix-agent"
zabbix_agent_docker_image_tag: "ubuntu-{{ zabbix_agent_version }}.{{ zabbix_version_patch }}" zabbix_agent_docker_image_tag: "ubuntu-{{ zabbix_agent_version }}.{{ zabbix_version_patch }}"
zabbix_agent_docker_user_gid: 101 zabbix_agent_docker_user_gid: 101
zabbix_agent_docker_user_uid: 101 zabbix_agent_docker_user_uid: 101
zabbix_agent_docker_network_mode: host zabbix_agent_docker_network_mode: host
zabbix_agent_docker_restart_policy: unless-stopped zabbix_agent_docker_restart_policy: unless-stopped
zabbix_agent_docker_privileged: false zabbix_agent_docker_privileged: false
zabbix_agent_docker_ports: zabbix_agent_docker_ports:
- 10050:10050 - 10050:10050
zabbix_agent_docker_security_opts: zabbix_agent_docker_security_opts:
- apparmor:unconfined - apparmor:unconfined
zabbix_agent_docker_volumes: zabbix_agent_docker_volumes:
- /etc/zabbix/zabbix_agentd.d:{{ zabbix_agent_include }} - /etc/zabbix/zabbix_agentd.d:{{ zabbix_agent_include }}
- /:/hostfs:ro - /:/hostfs:ro
- /etc:/hostfs/etc:ro - /etc:/hostfs/etc:ro
- /proc:/hostfs/proc:ro - /proc:/hostfs/proc:ro
- /sys:/hostfs/sys:ro - /sys:/hostfs/sys:ro
- /var/run:/var/run - /var/run:/var/run
zabbix_agent_docker_env: zabbix_agent_docker_env:
ZBX_HOSTNAME: "{{ zabbix_agent_hostname }}" ZBX_HOSTNAME: "{{ zabbix_agent_hostname }}"
ZBX_SERVER_HOST: "{{ zabbix_agent_server }}" ZBX_SERVER_HOST: "{{ zabbix_agent_server }}"
ZBX_PASSIVE_ALLOW: "{{ zabbix_agent_serverpassive_allow | default(omit) }}" ZBX_PASSIVE_ALLOW: "{{ zabbix_agent_serverpassive_allow | default(omit) }}"
ZBX_PASSIVESERVERS: "{{ zabbix_agent_serverpassive | default(omit) }}" ZBX_PASSIVESERVERS: "{{ zabbix_agent_serverpassive | default(omit) }}"
ZBX_ACTIVE_ALLOW: "{{ zabbix_agent_serveractive_allow | default(omit) }}" ZBX_ACTIVE_ALLOW: "{{ zabbix_agent_serveractive_allow | default(omit) }}"
ZBX_LOADMODULE: "{{ zabbix_agent_loadmodule | default(omit) }}" ZBX_LOADMODULE: "{{ zabbix_agent_loadmodule | default(omit) }}"
ZBX_DEBUGLEVEL: "{{ zabbix_agent_debuglevel }}" ZBX_DEBUGLEVEL: "{{ zabbix_agent_debuglevel }}"
ZBX_TIMEOUT: "{{ zabbix_agent_timeout }}" ZBX_TIMEOUT: "{{ zabbix_agent_timeout }}"
ZBX_SOURCEIP: "{{ zabbix_agent_sourceip | default(omit) }}" ZBX_SOURCEIP: "{{ zabbix_agent_sourceip | default(omit) }}"
ZBX_ENABLEREMOTECOMMANDS: "{{ zabbix_agent_enableremotecommands | default(omit) }}" ZBX_ENABLEREMOTECOMMANDS: "{{ zabbix_agent_enableremotecommands | default(omit) }}"
ZBX_LOGREMOTECOMMANDS: "{{ zabbix_agent_logremotecommands | default(omit) }}" ZBX_LOGREMOTECOMMANDS: "{{ zabbix_agent_logremotecommands | default(omit) }}"
ZBX_STARTAGENTS: "{{ zabbix_agent_startagents | default(omit) }}" ZBX_STARTAGENTS: "{{ zabbix_agent_startagents | default(omit) }}"
ZBX_HOSTNAMEITEM: "{{ zabbix_agent_hostnameitem | default(omit) }}" ZBX_HOSTNAMEITEM: "{{ zabbix_agent_hostnameitem | default(omit) }}"
ZBX_METADATA: "{{ zabbix_agent_hostmetadata | default(omit) }}" ZBX_METADATA: "{{ zabbix_agent_hostmetadata | default(omit) }}"
ZBX_METADATAITEM: "{{ zabbix_agent_hostmetadataitem | default(omit) }}" ZBX_METADATAITEM: "{{ zabbix_agent_hostmetadataitem | default(omit) }}"
ZBX_REFRESHACTIVECHECKS: "{{ zabbix_agent_refreshactivechecks | default(omit) }}" ZBX_REFRESHACTIVECHECKS: "{{ zabbix_agent_refreshactivechecks | default(omit) }}"
ZBX_BUFFERSEND: "{{ zabbix_agent_buffersend | default(omit) }}" ZBX_BUFFERSEND: "{{ zabbix_agent_buffersend | default(omit) }}"
ZBX_BUFFERSIZE: "{{ zabbix_agent_buffersize | default(omit) }}" ZBX_BUFFERSIZE: "{{ zabbix_agent_buffersize | default(omit) }}"
ZBX_MAXLINESPERSECOND: "{{ zabbix_agent_maxlinespersecond | default(omit) }}" ZBX_MAXLINESPERSECOND: "{{ zabbix_agent_maxlinespersecond | default(omit) }}"
ZBX_LISTENIP: "{{ zabbix_agent_listenip }}" ZBX_LISTENIP: "{{ zabbix_agent_listenip }}"
ZBX_UNSAFEUSERPARAMETERS: "{{ zabbix_agent_unsafeuserparameters | default(omit) }}" ZBX_UNSAFEUSERPARAMETERS: "{{ zabbix_agent_unsafeuserparameters | default(omit) }}"
ZBX_TLSCONNECT: "{{ zabbix_agent_tlsconnect | default(omit) }}" ZBX_TLSCONNECT: "{{ zabbix_agent_tlsconnect | default(omit) }}"
ZBX_TLSACCEPT: "{{ zabbix_agent_tlsaccept | default(omit) }}" ZBX_TLSACCEPT: "{{ zabbix_agent_tlsaccept | default(omit) }}"
ZBX_TLSCAFILE: "{{ zabbix_agent_tlscafile | default(omit) }}" ZBX_TLSCAFILE: "{{ zabbix_agent_tlscafile | default(omit) }}"
ZBX_TLSCRLFILE: "{{ zabbix_agent_tlscrlfile | default(omit) }}" ZBX_TLSCRLFILE: "{{ zabbix_agent_tlscrlfile | default(omit) }}"
ZBX_TLSSERVERCERTISSUER: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}" ZBX_TLSSERVERCERTISSUER: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}"
ZBX_TLSSERVERCERTSUBJECT: "{{ zabbix_agent_tlsservercertsubject | default(omit) }}" ZBX_TLSSERVERCERTSUBJECT: "{{ zabbix_agent_tlsservercertsubject | default(omit) }}"
ZBX_TLSCERTFILE: "{{ zabbix_agent_tlscertfile | default(omit) }}" ZBX_TLSCERTFILE: "{{ zabbix_agent_tlscertfile | default(omit) }}"
ZBX_TLSKEYFILE: "{{ zabbix_agent_tlskeyfile | default(omit) }}" ZBX_TLSKEYFILE: "{{ zabbix_agent_tlskeyfile | default(omit) }}"
ZBX_TLSPSKIDENTITY: "{{ zabbix_agent_tlspskidentity | default(omit) }}" ZBX_TLSPSKIDENTITY: "{{ zabbix_agent_tlspskidentity | default(omit) }}"

View File

@@ -1,3 +1,3 @@
# This is an sample userparameters file. # This is an sample userparameters file.
UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive

View File

@@ -1,40 +1,40 @@
--- ---
# handlers file for zabbix-agent # handlers file for zabbix-agent
- name: restart zabbix-agent - name: restart zabbix-agent
ansible.builtin.service: ansible.builtin.service:
name: "{{ zabbix_agent_service }}" name: "{{ zabbix_agent_service }}"
state: restarted state: restarted
enabled: true enabled: true
become: true become: true
when: when:
- not zabbix_agent_docker - not zabbix_agent_docker
- ansible_os_family != "Windows" and ansible_os_family != "Darwin" - ansible_os_family != "Windows" and ansible_os_family != "Darwin"
- name: firewalld-reload - name: firewalld-reload
ansible.builtin.command: "firewall-cmd --reload" ansible.builtin.command: "firewall-cmd --reload"
become: true become: true
when: when:
- ansible_facts.services["firewalld"] is defined - ansible_facts.services["firewalld"] is defined
- ansible_facts.services["firewalld"].state == "running" - ansible_facts.services["firewalld"].state == "running"
- name: restart win zabbix agent - name: restart win zabbix agent
win_service: win_service:
name: "{{ zabbix_win_svc_name }}" name: "{{ zabbix_win_svc_name }}"
state: restarted state: restarted
when: when:
- ansible_os_family == "Windows" - ansible_os_family == "Windows"
- name: restart mac zabbix agent - name: restart mac zabbix agent
ansible.builtin.command: "launchctl kickstart -k system/{{ zabbix_agent_service }}" ansible.builtin.command: "launchctl kickstart -k system/{{ zabbix_agent_service }}"
become: true become: true
when: when:
- not zabbix_agent_docker - not zabbix_agent_docker
- ansible_os_family == "Darwin" - ansible_os_family == "Darwin"
- name: "clean repo files from proxy creds" - name: "clean repo files from proxy creds"
ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true ansible.builtin.shell: ls /etc/yum.repos.d/zabbix* && sed -i 's/^proxy =.*//' /etc/yum.repos.d/zabbix* || true
become: true become: true
when: when:
- ansible_os_family == 'RedHat' - ansible_os_family == 'RedHat'
- zabbix_http_proxy is defined or zabbix_https_proxy is defined - zabbix_http_proxy is defined or zabbix_https_proxy is defined

View File

@@ -1,42 +1,42 @@
--- ---
galaxy_info: galaxy_info:
author: Werner Dijkerman author: Werner Dijkerman
description: Installing and maintaining zabbix-agent for RedHat/Debian/Ubuntu/Windows/Suse. description: Installing and maintaining zabbix-agent for RedHat/Debian/Ubuntu/Windows/Suse.
company: myCompany.Dotcom company: myCompany.Dotcom
license: MIT license: MIT
min_ansible_version: 2.7 min_ansible_version: 2.7
platforms: platforms:
- name: EL - name: EL
versions: versions:
- 5 - 5
- 6 - 6
- 7 - 7
- name: Ubuntu - name: Ubuntu
versions: versions:
- lucid - lucid
- precise - precise
- trusty - trusty
- xenial - xenial
- bionic - bionic
- name: Debian - name: Debian
versions: versions:
- squeeze - squeeze
- wheezy - wheezy
- jessie - jessie
- stretch - stretch
- buster - buster
- name: opensuse - name: opensuse
versions: versions:
- 12.1 - 12.1
- 12.2 - 12.2
- 12.3 - 12.3
- 13.1 - 13.1
- 13.2 - 13.2
- name: Windows - name: Windows
versions: versions:
- all - all
galaxy_tags: galaxy_tags:
- zabbix - zabbix
- monitoring - monitoring
dependencies: [] dependencies: []

View File

@@ -1,14 +1,14 @@
# Molecule managed # Molecule managed
{% if item.registry is defined %} {% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }} FROM {{ item.registry.url }}/{{ item.image }}
{% else %} {% else %}
FROM {{ item.image }} FROM {{ item.image }}
{% endif %} {% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

View File

@@ -1,26 +1,26 @@
******************************** ********************************
Docker driver installation guide Docker driver installation guide
******************************** ********************************
Requirements Requirements
============ ============
* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html) * General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine * Docker Engine
* docker-py * docker-py
* docker * docker
Install Install
======= =======
Ansible < 2.6 Ansible < 2.6
.. code-block:: bash .. code-block:: bash
$ sudo pip install docker-py $ sudo pip install docker-py
Ansible >= 2.6 Ansible >= 2.6
.. code-block:: bash .. code-block:: bash
$ sudo pip install docker $ sudo pip install docker

View File

@@ -1,73 +1,73 @@
--- ---
dependency: dependency:
name: galaxy name: galaxy
driver: driver:
name: docker name: docker
platforms: platforms:
- name: zabbix-server-centos - name: zabbix-server-centos
image: milcom/centos7-systemd:latest image: milcom/centos7-systemd:latest
groups: groups:
- zabbix_server - zabbix_server
- mysql - mysql
privileged: true privileged: true
networks: networks:
- name: zabbix - name: zabbix
published_ports: published_ports:
- "80:80" - "80:80"
- name: zabbix-agent-centos - name: zabbix-agent-centos
image: milcom/centos7-systemd:latest image: milcom/centos7-systemd:latest
groups: groups:
- zabbix_agent - zabbix_agent
privileged: true privileged: true
networks: networks:
- name: zabbix - name: zabbix
- name: zabbix-agent-debian - name: zabbix-agent-debian
image: minimum2scp/systemd-stretch:latest image: minimum2scp/systemd-stretch:latest
command: /sbin/init command: /sbin/init
groups: groups:
- zabbix_agent - zabbix_agent
privileged: true privileged: true
networks: networks:
- name: zabbix - name: zabbix
- name: zabbix-agent-ubuntu - name: zabbix-agent-ubuntu
image: solita/ubuntu-systemd:bionic image: solita/ubuntu-systemd:bionic
groups: groups:
- zabbix_agent - zabbix_agent
privileged: true privileged: true
networks: networks:
- name: zabbix - name: zabbix
provisioner: provisioner:
name: ansible name: ansible
playbooks: playbooks:
docker: docker:
create: ../default/create.yml create: ../default/create.yml
destroy: ../default/destroy.yml destroy: ../default/destroy.yml
inventory: inventory:
group_vars: group_vars:
all: all:
zabbix_api_create_hosts: true zabbix_api_create_hosts: true
zabbix_api_create_hostgroup: true zabbix_api_create_hostgroup: true
zabbix_api_server_url: http://zabbix-server-centos zabbix_api_server_url: http://zabbix-server-centos
zabbix_apache_servername: zabbix-server-centos zabbix_apache_servername: zabbix-server-centos
mysql: mysql:
zabbix_server_database: mysql zabbix_server_database: mysql
zabbix_server_database_long: mysql zabbix_server_database_long: mysql
zabbix_server_dbport: 3306 zabbix_server_dbport: 3306
database_type: mysql database_type: mysql
database_type_long: mysql database_type_long: mysql
host_vars: host_vars:
zabbix-agent-fedora: zabbix-agent-fedora:
ansible_python_interpreter: /usr/bin/python3 ansible_python_interpreter: /usr/bin/python3
zabbix-agent-ubuntu: zabbix-agent-ubuntu:
zabbix_agent_tlsaccept: psk zabbix_agent_tlsaccept: psk
zabbix_agent_tlsconnect: psk zabbix_agent_tlsconnect: psk
zabbix_agent_tlspskidentity: "myhost PSK" zabbix_agent_tlspskidentity: "myhost PSK"
zabbix_agent_tlspsk_secret: b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d zabbix_agent_tlspsk_secret: b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d
zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent_pskfile.psk zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent_pskfile.psk
scenario: scenario:
name: with-server name: with-server
verifier: verifier:
name: testinfra name: testinfra

View File

@@ -1,24 +1,24 @@
--- ---
- name: Converge - name: Converge
hosts: all:!zabbix_server hosts: all:!zabbix_server
pre_tasks: pre_tasks:
- name: "Get IP Server" - name: "Get IP Server"
ansible.builtin.shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 ansible.builtin.shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1
register: ip_address register: ip_address
delegate_to: zabbix-server-centos delegate_to: zabbix-server-centos
changed_when: false changed_when: false
tags: tags:
- skip_ansible_lint - skip_ansible_lint
- name: "Get IP hosts" - name: "Get IP hosts"
ansible.builtin.shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1 ansible.builtin.shell: grep $(hostname) /etc/hosts | awk '{ print $1 }' | tail -n 1
register: ip_address_host register: ip_address_host
changed_when: false changed_when: false
tags: tags:
- skip_ansible_lint - skip_ansible_lint
roles: roles:
- role: zabbix_agent - role: zabbix_agent
zabbix_agent_ip: "{{ ip_address_host.stdout }}" zabbix_agent_ip: "{{ ip_address_host.stdout }}"
zabbix_agent_server: "{{ ip_address.stdout }}" zabbix_agent_server: "{{ ip_address.stdout }}"
zabbix_agent_serveractive: "{{ ip_address.stdout }}" zabbix_agent_serveractive: "{{ ip_address.stdout }}"

View File

@@ -1,114 +1,114 @@
--- ---
- name: Prepare - name: Prepare
hosts: zabbix_server hosts: zabbix_server
pre_tasks: pre_tasks:
- name: "Installing EPEL" - name: "Installing EPEL"
ansible.builtin.yum: ansible.builtin.yum:
name: name:
- epel-release - epel-release
state: present state: present
when: ansible_distribution == 'CentOS' when: ansible_distribution == 'CentOS'
- name: "Installing packages" - name: "Installing packages"
ansible.builtin.yum: ansible.builtin.yum:
name: name:
- net-tools - net-tools
- which - which
- libselinux-python - libselinux-python
- python-pip - python-pip
state: present state: present
register: installation_dependencies register: installation_dependencies
when: ansible_distribution == 'CentOS' when: ansible_distribution == 'CentOS'
- name: "Installing which on NON-CentOS" - name: "Installing which on NON-CentOS"
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- net-tools - net-tools
- python-pip - python-pip
- curl - curl
state: present state: present
when: ansible_distribution != 'CentOS' when: ansible_distribution != 'CentOS'
- name: "Configure SUDO." - name: "Configure SUDO."
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
dest: /etc/sudoers dest: /etc/sudoers
line: "Defaults !requiretty" line: "Defaults !requiretty"
state: present state: present
- name: "Make sure the docs are installed." - name: "Make sure the docs are installed."
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
dest: /etc/yum.conf dest: /etc/yum.conf
line: "tsflags=nodocs" line: "tsflags=nodocs"
state: absent state: absent
- name: "Installing some python dependencies" - name: "Installing some python dependencies"
ansible.builtin.pip: ansible.builtin.pip:
name: py-zabbix name: py-zabbix
state: present state: present
roles: roles:
- role: geerlingguy.mysql - role: geerlingguy.mysql
- role: zabbix_server - role: zabbix_server
- role: zabbix_web - role: zabbix_web
- name: Prepare - name: Prepare
hosts: all:!zabbix_server:!docker hosts: all:!zabbix_server:!docker
tasks: tasks:
- name: "Installing packages on CentOS family" - name: "Installing packages on CentOS family"
ansible.builtin.yum: ansible.builtin.yum:
name: name:
- net-tools - net-tools
- which - which
state: present state: present
when: when:
- ansible_os_family == 'RedHat' - ansible_os_family == 'RedHat'
- name: "Installing packages on Debian family" - name: "Installing packages on Debian family"
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- net-tools - net-tools
state: present state: present
when: when:
- ansible_os_family == 'Debian' - ansible_os_family == 'Debian'
- name: Converge - name: Converge
hosts: docker hosts: docker
tasks: tasks:
- name: "Download Docker CE repo file" - name: "Download Docker CE repo file"
ansible.builtin.get_url: ansible.builtin.get_url:
url: https://download.docker.com/linux/centos/docker-ce.repo url: https://download.docker.com/linux/centos/docker-ce.repo
dest: /etc/yum.repos.d/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo
mode: 0644 mode: 0644
register: zabbix_agent_prepare_docker_repo register: zabbix_agent_prepare_docker_repo
until: zabbix_agent_prepare_docker_repo is succeeded until: zabbix_agent_prepare_docker_repo is succeeded
- name: "Installing Epel" - name: "Installing Epel"
ansible.builtin.package: ansible.builtin.package:
pkg: pkg:
- epel-release - epel-release
state: present state: present
register: zabbix_agent_prepare_docker_install register: zabbix_agent_prepare_docker_install
until: zabbix_agent_prepare_docker_install is succeeded until: zabbix_agent_prepare_docker_install is succeeded
- name: "Installing Docker" - name: "Installing Docker"
ansible.builtin.package: ansible.builtin.package:
pkg: pkg:
- docker-ce - docker-ce
- python-pip - python-pip
- python-setuptools - python-setuptools
state: present state: present
register: zabbix_agent_prepare_docker_install register: zabbix_agent_prepare_docker_install
until: zabbix_agent_prepare_docker_install is succeeded until: zabbix_agent_prepare_docker_install is succeeded
- name: "Installing Docker Python" - name: "Installing Docker Python"
ansible.builtin.pip: ansible.builtin.pip:
name: name:
- docker - docker
state: present state: present
register: zabbix_agent_prepare_docker_install register: zabbix_agent_prepare_docker_install
until: zabbix_agent_prepare_docker_install is succeeded until: zabbix_agent_prepare_docker_install is succeeded
- name: "Starting Docker service" - name: "Starting Docker service"
ansible.builtin.service: ansible.builtin.service:
name: docker name: docker
state: started state: started

View File

@@ -1,5 +1,5 @@
--- ---
- src: geerlingguy.apache - src: geerlingguy.apache
- src: geerlingguy.mysql - src: geerlingguy.mysql
- src: dj-wasabi.zabbix-server - src: dj-wasabi.zabbix-server
- src: dj-wasabi.zabbix-web - src: dj-wasabi.zabbix-web

View File

@@ -1,44 +1,44 @@
import os import os
from zabbix_api import ZabbixAPI from zabbix_api import ZabbixAPI
import testinfra.utils.ansible_runner import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('zabbix_agent') os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('zabbix_agent')
def authenticate(): def authenticate():
zapi = ZabbixAPI(server='http://zabbix-server-centos/api_jsonrpc.php') zapi = ZabbixAPI(server='http://zabbix-server-centos/api_jsonrpc.php')
zapi.login("Admin", "zabbix") zapi.login("Admin", "zabbix")
return zapi return zapi
def test_psk_host(host): def test_psk_host(host):
zapi = authenticate() zapi = authenticate()
hostname = host.check_output('hostname -s') hostname = host.check_output('hostname -s')
host_name = "zabbix-agent-ubuntu" host_name = "zabbix-agent-ubuntu"
server_data = zapi.host.get({'output': 'extend', 'selectInventory': 'extend', 'filter': {'host': [hostname]}}) server_data = zapi.host.get({'output': 'extend', 'selectInventory': 'extend', 'filter': {'host': [hostname]}})
if hostname == host_name: if hostname == host_name:
assert server_data[0]['tls_psk'] == "b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d" assert server_data[0]['tls_psk'] == "b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d"
assert server_data[0]['tls_psk_identity'] == "myhost PSK" assert server_data[0]['tls_psk_identity'] == "myhost PSK"
assert server_data[0]['tls_accept'] == "2" assert server_data[0]['tls_accept'] == "2"
else: else:
assert server_data[0]['tls_psk'] == "" assert server_data[0]['tls_psk'] == ""
assert server_data[0]['tls_psk_identity'] == "" assert server_data[0]['tls_psk_identity'] == ""
assert server_data[0]['tls_accept'] == "1" assert server_data[0]['tls_accept'] == "1"
def test_zabbix_agent_psk(host): def test_zabbix_agent_psk(host):
hostname = host.check_output('hostname -s') hostname = host.check_output('hostname -s')
host_name = "zabbix-agent-ubuntu" host_name = "zabbix-agent-ubuntu"
psk_file = host.file("/etc/zabbix/zabbix_agent_pskfile.psk") psk_file = host.file("/etc/zabbix/zabbix_agent_pskfile.psk")
if hostname == host_name: if hostname == host_name:
assert psk_file.user == "zabbix" assert psk_file.user == "zabbix"
assert psk_file.group == "zabbix" assert psk_file.group == "zabbix"
assert psk_file.mode == 0o400 assert psk_file.mode == 0o400
assert psk_file.contains("b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d") assert psk_file.contains("b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d")
else: else:
assert not psk_file.exists assert not psk_file.exists

View File

@@ -1,41 +1,41 @@
import os import os
from zabbix_api import ZabbixAPI from zabbix_api import ZabbixAPI
import testinfra.utils.ansible_runner import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('zabbix_server') os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('zabbix_server')
def authenticate(): def authenticate():
zapi = ZabbixAPI(server='http://zabbix-server-centos/api_jsonrpc.php') zapi = ZabbixAPI(server='http://zabbix-server-centos/api_jsonrpc.php')
zapi.login("Admin", "zabbix") zapi.login("Admin", "zabbix")
return zapi return zapi
def get_hosts(): def get_hosts():
return [ return [
"zabbix-agent-debian", "zabbix-agent-debian",
"zabbix-agent-ubuntu", "zabbix-agent-ubuntu",
"zabbix-agent-centos", "zabbix-agent-centos",
"zabbix-agent-docker-centos" "zabbix-agent-docker-centos"
] ]
def test_hosts(): def test_hosts():
zapi = authenticate() zapi = authenticate()
hosts = get_hosts() hosts = get_hosts()
servers = zapi.host.get({'output': ["hostid", "name"]}) servers = zapi.host.get({'output': ["hostid", "name"]})
for server in servers: for server in servers:
if server['name'] != 'Zabbix server': if server['name'] != 'Zabbix server':
assert server['name'] in hosts assert server['name'] in hosts
def test_hosts_status(): def test_hosts_status():
zapi = authenticate() zapi = authenticate()
servers = zapi.host.get({'output': ["status", "name"]}) servers = zapi.host.get({'output': ["status", "name"]})
for server in servers: for server in servers:
if server['name'] != 'Zabbix server': if server['name'] != 'Zabbix server':
assert int(server['status']) == 0 assert int(server['status']) == 0

View File

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

View File

@@ -1,32 +1,32 @@
--- ---
- name: "Create volume mount string" - name: "Create volume mount string"
ansible.builtin.set_fact: ansible.builtin.set_fact:
volume_mount: "{{ zabbix_agent_tlspskfile }}:/var/lib/zabbix/enc/tlspskfile" volume_mount: "{{ zabbix_agent_tlspskfile }}:/var/lib/zabbix/enc/tlspskfile"
tls_key: tls_key:
ZBX_TLSPSKFILE: tlspskfile ZBX_TLSPSKFILE: tlspskfile
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- name: "Add zabbix_agent_tlspskfile to volume mount" - name: "Add zabbix_agent_tlspskfile to volume mount"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_docker_volumes: "{{ zabbix_agent_docker_volumes + [ volume_mount ] }}" zabbix_agent_docker_volumes: "{{ zabbix_agent_docker_volumes + [ volume_mount ] }}"
zabbix_agent_docker_env: "{{ zabbix_agent_docker_env | combine(tls_key) }}" zabbix_agent_docker_env: "{{ zabbix_agent_docker_env | combine(tls_key) }}"
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- name: "Ensure Zabbix Docker container is running" - name: "Ensure Zabbix Docker container is running"
community.docker.docker_container: community.docker.docker_container:
name: "{{ zabbix_agent_docker_name }}" name: "{{ zabbix_agent_docker_name }}"
image: "{{ zabbix_agent_docker_image }}:{{ zabbix_agent_docker_image_tag }}" image: "{{ zabbix_agent_docker_image }}:{{ zabbix_agent_docker_image_tag }}"
state: "{{ zabbix_agent_docker_state }}" state: "{{ zabbix_agent_docker_state }}"
restart_policy: "{{ zabbix_agent_docker_restart_policy }}" restart_policy: "{{ zabbix_agent_docker_restart_policy }}"
network_mode: "{{ zabbix_agent_docker_network_mode }}" network_mode: "{{ zabbix_agent_docker_network_mode }}"
published_ports: "{{ zabbix_agent_docker_ports }}" published_ports: "{{ zabbix_agent_docker_ports }}"
privileged: "{{ zabbix_agent_docker_privileged }}" privileged: "{{ zabbix_agent_docker_privileged }}"
security_opts: "{{ zabbix_agent_docker_security_opts }}" security_opts: "{{ zabbix_agent_docker_security_opts }}"
volumes: "{{ zabbix_agent_docker_volumes }}" volumes: "{{ zabbix_agent_docker_volumes }}"
env: "{{ zabbix_agent_docker_env }}" env: "{{ zabbix_agent_docker_env }}"
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
become: true become: true

View File

@@ -1,239 +1,239 @@
--- ---
- name: "Set default ip address for zabbix_agent_ip" - name: "Set default ip address for zabbix_agent_ip"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}" zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}"
when: when:
- zabbix_agent_ip is not defined - zabbix_agent_ip is not defined
- "'ansible_default_ipv4' in hostvars[inventory_hostname]" - "'ansible_default_ipv4' in hostvars[inventory_hostname]"
tags: tags:
- config - config
- name: "Get Total Private IP Addresses" - name: "Get Total Private IP Addresses"
ansible.builtin.set_fact: ansible.builtin.set_fact:
total_private_ip_addresses: "{{ ansible_all_ipv4_addresses | ansible.utils.ipaddr('private') | length }}" total_private_ip_addresses: "{{ ansible_all_ipv4_addresses | ansible.utils.ipaddr('private') | length }}"
when: when:
- ansible_all_ipv4_addresses is defined - ansible_all_ipv4_addresses is defined
- not (zabbix_agent_dont_detect_ip) - not (zabbix_agent_dont_detect_ip)
tags: tags:
- config - config
- name: "Set first public ip address for zabbix_agent_ip" - name: "Set first public ip address for zabbix_agent_ip"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('public') | first }}" zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('public') | first }}"
zabbix_agent_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent_server) }}" zabbix_agent_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent_server) }}"
zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent_serveractive) }}" zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent_serveractive) }}"
zabbix_agent2_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent2_server) }}" zabbix_agent2_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent2_server) }}"
zabbix_agent2_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent2_serveractive) }}" zabbix_agent2_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent2_serveractive) }}"
when: when:
- zabbix_agent_ip is not defined - zabbix_agent_ip is not defined
- total_private_ip_addresses is defined - total_private_ip_addresses is defined
- total_private_ip_addresses == '0' - total_private_ip_addresses == '0'
tags: tags:
- config - config
- name: "Set first private ip address for zabbix_agent_ip" - name: "Set first private ip address for zabbix_agent_ip"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('private') | first }}" zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('private') | first }}"
when: when:
- zabbix_agent_ip is not defined - zabbix_agent_ip is not defined
- total_private_ip_addresses is defined - total_private_ip_addresses is defined
- total_private_ip_addresses != '0' - total_private_ip_addresses != '0'
tags: tags:
- config - config
- name: "Fail invalid specified agent_listeninterface" - name: "Fail invalid specified agent_listeninterface"
ansible.builtin.fail: ansible.builtin.fail:
msg: "The specified network interface does not exist" msg: "The specified network interface does not exist"
when: when:
- (zabbix_agent_listeninterface) - (zabbix_agent_listeninterface)
- (zabbix_agent_listeninterface not in ansible_interfaces) - (zabbix_agent_listeninterface not in ansible_interfaces)
tags: tags:
- config - config
- name: "Set network interface" - name: "Set network interface"
ansible.builtin.set_fact: ansible.builtin.set_fact:
network_interface: ansible_{{ zabbix_agent_listeninterface }} network_interface: ansible_{{ zabbix_agent_listeninterface }}
when: when:
- (zabbix_agent_listeninterface) - (zabbix_agent_listeninterface)
- not zabbix_agent_listenip - not zabbix_agent_listenip
tags: tags:
- config - config
- name: "Get IP of agent_listeninterface when no agent_listenip specified" - name: "Get IP of agent_listeninterface when no agent_listenip specified"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_listenip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}" zabbix_agent_listenip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}"
when: when:
- (zabbix_agent_listeninterface) - (zabbix_agent_listeninterface)
- not zabbix_agent_listenip - not zabbix_agent_listenip
tags: tags:
- config - config
- api - api
- name: "Default agent_listenip to all when not specified" - name: "Default agent_listenip to all when not specified"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_listenip: "0.0.0.0" zabbix_agent_listenip: "0.0.0.0"
when: when:
- not (zabbix_agent_listenip) - not (zabbix_agent_listenip)
tags: tags:
- config - config
- name: "Fail invalid specified agent_listenip" - name: "Fail invalid specified agent_listenip"
ansible.builtin.fail: ansible.builtin.fail:
msg: "The agent_listenip does not exist" msg: "The agent_listenip does not exist"
when: when:
- zabbix_agent_listenip != '0.0.0.0' - zabbix_agent_listenip != '0.0.0.0'
- zabbix_agent_listenip != '127.0.0.1' - zabbix_agent_listenip != '127.0.0.1'
- (zabbix_agent_listenip not in ansible_all_ipv4_addresses) - (zabbix_agent_listenip not in ansible_all_ipv4_addresses)
tags: tags:
- config - config
- name: "Configure SELinux when enabled" - name: "Configure SELinux when enabled"
ansible.builtin.include_tasks: selinux.yml ansible.builtin.include_tasks: selinux.yml
when: when:
- zabbix_selinux | bool - zabbix_selinux | bool
- name: "Adding zabbix group" - name: "Adding zabbix group"
ansible.builtin.group: ansible.builtin.group:
name: zabbix name: zabbix
state: present state: present
gid: "{{ zabbix_agent_docker_user_gid | default(omit) }}" gid: "{{ zabbix_agent_docker_user_gid | default(omit) }}"
become: true become: true
when: when:
- zabbix_agent_docker | bool - zabbix_agent_docker | bool
tags: tags:
- config - config
- name: "Adding zabbix user" - name: "Adding zabbix user"
ansible.builtin.user: ansible.builtin.user:
name: zabbix name: zabbix
group: zabbix group: zabbix
state: present state: present
create_home: false create_home: false
home: /etc/zabbix home: /etc/zabbix
uid: "{{ zabbix_agent_docker_user_uid | default(omit) }}" uid: "{{ zabbix_agent_docker_user_uid | default(omit) }}"
system: true system: true
become: true become: true
when: when:
- zabbix_agent_docker | bool - zabbix_agent_docker | bool
tags: tags:
- config - config
- name: "Configure zabbix-agent" - name: "Configure zabbix-agent"
ansible.builtin.template: ansible.builtin.template:
src: "{{ 'zabbix_agentd.conf.j2' if not zabbix_agent2 else 'zabbix_agent2.conf.j2' }}" src: "{{ 'zabbix_agentd.conf.j2' if not zabbix_agent2 else 'zabbix_agent2.conf.j2' }}"
dest: "/etc/zabbix/{{ zabbix_agent_conf if not zabbix_agent2 else zabbix_agent2_conf }}" dest: "/etc/zabbix/{{ zabbix_agent_conf if not zabbix_agent2 else zabbix_agent2_conf }}"
owner: root owner: root
group: root group: root
mode: "{{ zabbix_agent_conf_mode }}" mode: "{{ zabbix_agent_conf_mode }}"
notify: notify:
- restart zabbix-agent - restart zabbix-agent
become: true become: true
when: when:
- not (zabbix_agent_docker | bool) - not (zabbix_agent_docker | bool)
tags: tags:
- config - config
- name: "Create directory for PSK file if not exist." - name: "Create directory for PSK file if not exist."
ansible.builtin.file: ansible.builtin.file:
path: "{{ zabbix_agent_tlspskfile | dirname }}" path: "{{ zabbix_agent_tlspskfile | dirname }}"
mode: 0755 mode: 0755
state: directory state: directory
become: true become: true
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- zabbix_agent_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680 - zabbix_agent_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680
- not (zabbix_agent2 | bool) - not (zabbix_agent2 | bool)
tags: tags:
- config - config
- name: "Create directory for PSK file if not exist (zabbix-agent2)" - name: "Create directory for PSK file if not exist (zabbix-agent2)"
ansible.builtin.file: ansible.builtin.file:
path: "{{ zabbix_agent2_tlspskfile | dirname }}" path: "{{ zabbix_agent2_tlspskfile | dirname }}"
mode: 0755 mode: 0755
state: directory state: directory
become: true become: true
when: when:
- zabbix_agent2_tlspskfile is defined - zabbix_agent2_tlspskfile is defined
- zabbix_agent2_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680 - zabbix_agent2_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680
- zabbix_agent2 | bool - zabbix_agent2 | bool
tags: tags:
- config - config
- name: "Place TLS PSK File" - name: "Place TLS PSK File"
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ zabbix_agent_tlspskfile }}" dest: "{{ zabbix_agent_tlspskfile }}"
content: "{{ zabbix_agent_tlspsk_secret }}" content: "{{ zabbix_agent_tlspsk_secret }}"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0400 mode: 0400
become: true become: true
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- zabbix_agent_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680 - zabbix_agent_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680
- zabbix_agent_tlspsk_secret is defined - zabbix_agent_tlspsk_secret is defined
- not (zabbix_agent2 | bool) - not (zabbix_agent2 | bool)
notify: notify:
- restart zabbix-agent - restart zabbix-agent
tags: tags:
- config - config
- name: "Place TLS PSK File (zabbix-agent2)" - name: "Place TLS PSK File (zabbix-agent2)"
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ zabbix_agent2_tlspskfile }}" dest: "{{ zabbix_agent2_tlspskfile }}"
content: "{{ zabbix_agent2_tlspsk_secret }}" content: "{{ zabbix_agent2_tlspsk_secret }}"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0400 mode: 0400
become: true become: true
when: when:
- zabbix_agent2_tlspskfile is defined - zabbix_agent2_tlspskfile is defined
- zabbix_agent2_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680 - zabbix_agent2_tlspskfile # https://github.com/ansible-collections/community.zabbix/issues/680
- zabbix_agent2_tlspsk_secret is defined - zabbix_agent2_tlspsk_secret is defined
- zabbix_agent2 | bool - zabbix_agent2 | bool
notify: notify:
- restart zabbix-agent - restart zabbix-agent
tags: tags:
- config - config
- name: "Create include dir zabbix-agent" - name: "Create include dir zabbix-agent"
ansible.builtin.file: ansible.builtin.file:
path: "{{ zabbix_agent_include if not zabbix_agent2 else zabbix_agent2_include }}" path: "{{ zabbix_agent_include if not zabbix_agent2 else zabbix_agent2_include }}"
owner: root owner: root
group: zabbix group: zabbix
mode: "{{ zabbix_agent_include_mode if not zabbix_agent2 else zabbix_agent2_include_mode }}" mode: "{{ zabbix_agent_include_mode if not zabbix_agent2 else zabbix_agent2_include_mode }}"
state: directory state: directory
become: true become: true
tags: tags:
- config - config
- name: "Install the Docker container" - name: "Install the Docker container"
ansible.builtin.include_tasks: Docker.yml ansible.builtin.include_tasks: Docker.yml
when: when:
- zabbix_agent_docker | bool - zabbix_agent_docker | bool
- name: "Remove zabbix-agent installation when zabbix-agent2 is used." - name: "Remove zabbix-agent installation when zabbix-agent2 is used."
ansible.builtin.include_tasks: remove.yml ansible.builtin.include_tasks: remove.yml
when: when:
- zabbix_agent2 | bool - zabbix_agent2 | bool
- zabbix_agent_package_remove - zabbix_agent_package_remove
- name: "Make sure the zabbix-agent service is running" - name: "Make sure the zabbix-agent service is running"
ansible.builtin.service: ansible.builtin.service:
name: "{{ zabbix_agent_service }}" name: "{{ zabbix_agent_service }}"
state: started state: started
enabled: true enabled: true
become: true become: true
when: when:
- not (zabbix_agent_docker | bool) - not (zabbix_agent_docker | bool)
tags: tags:
- service - service
- name: "Give zabbix-agent access to system.hw.chassis info" - name: "Give zabbix-agent access to system.hw.chassis info"
ansible.builtin.file: ansible.builtin.file:
path: /sys/firmware/dmi/tables/DMI path: /sys/firmware/dmi/tables/DMI
owner: root owner: root
group: zabbix group: zabbix
become: true become: true
when: zabbix_agent_chassis | bool when: zabbix_agent_chassis | bool
tags: tags:
- config - config

View File

@@ -1,70 +1,70 @@
--- ---
# Tasks specific for RedHat systems # Tasks specific for RedHat systems
- name: "RedHat | Install basic repo file" - name: "RedHat | Install basic repo file"
ansible.builtin.yum_repository: ansible.builtin.yum_repository:
name: "{{ item.name }}" name: "{{ item.name }}"
description: "{{ item.description }}" description: "{{ item.description }}"
baseurl: "{{ item.baseurl }}" baseurl: "{{ item.baseurl }}"
gpgcheck: "{{ item.gpgcheck }}" gpgcheck: "{{ item.gpgcheck }}"
gpgkey: "{{ item.gpgkey }}" gpgkey: "{{ item.gpgkey }}"
mode: "{{ item.mode | default('0644') }}" mode: "{{ item.mode | default('0644') }}"
priority: "{{ item.priority | default('99') }}" priority: "{{ item.priority | default('99') }}"
state: "{{ item.state | default('present') }}" state: "{{ item.state | default('present') }}"
proxy: "{{ zabbix_http_proxy | default(omit) }}" proxy: "{{ zabbix_http_proxy | default(omit) }}"
with_items: "{{ zabbix_repo_yum }}" with_items: "{{ zabbix_repo_yum }}"
register: yum_repo_installed register: yum_repo_installed
become: true become: true
notify: notify:
- "clean repo files from proxy creds" - "clean repo files from proxy creds"
tags: tags:
- install - install
- name: Check if warn parameter can be used for shell module - name: Check if warn parameter can be used for shell module
ansible.builtin.set_fact: ansible.builtin.set_fact:
produce_warn: False produce_warn: False
when: ansible_version.full is version("2.14", "<") when: ansible_version.full is version("2.14", "<")
tags: tags:
- always - always
- name: "RedHat | Installing zabbix-agent" - name: "RedHat | Installing zabbix-agent"
ansible.builtin.package: ansible.builtin.package:
pkg: pkg:
- "{{ zabbix_agent_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_agent_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}"
disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}"
state: "{{ zabbix_agent_package_state }}" state: "{{ zabbix_agent_package_state }}"
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_package_installed register: zabbix_agent_package_installed
until: zabbix_agent_package_installed is succeeded until: zabbix_agent_package_installed is succeeded
become: true become: true
tags: tags:
- install - install
- name: "RedHat | Installing zabbix-{sender,get}" - name: "RedHat | Installing zabbix-{sender,get}"
ansible.builtin.package: ansible.builtin.package:
pkg: pkg:
- "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}"
- "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}"
disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}"
state: "{{ zabbix_agent_package_state }}" state: "{{ zabbix_agent_package_state }}"
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_package_installed register: zabbix_agent_package_installed
until: zabbix_agent_package_installed is succeeded until: zabbix_agent_package_installed is succeeded
when: when:
- not zabbix_agent_install_agent_only - not zabbix_agent_install_agent_only
become: true become: true
tags: tags:
- install - install
- name: "RedHat | Enable the service" - name: "RedHat | Enable the service"
ansible.builtin.service: ansible.builtin.service:
name: "{{ zabbix_agent_service }}" name: "{{ zabbix_agent_service }}"
enabled: true enabled: true
use: service use: service
become: true become: true
tags: tags:
- service - service

View File

@@ -1,352 +1,352 @@
--- ---
- name: "Windows | Set default architecture" - name: "Windows | Set default architecture"
ansible.builtin.set_fact: ansible.builtin.set_fact:
windows_arch: 32 windows_arch: 32
tags: tags:
- always - always
- name: "Windows | Override architecture if 64-bit" - name: "Windows | Override architecture if 64-bit"
ansible.builtin.set_fact: ansible.builtin.set_fact:
windows_arch: 64 windows_arch: 64
when: when:
- ansible_architecture == "64-bit" - ansible_architecture == "64-bit"
tags: tags:
- always - always
- name: "Windows | Set path to zabbix.exe" - name: "Windows | Set path to zabbix.exe"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\win{{ windows_arch }}\zabbix_agentd.exe' zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\win{{ windows_arch }}\zabbix_agentd.exe'
tags: tags:
- always - always
- name: "Windows | Set variables specific to Zabbix" - name: "Windows | Set variables specific to Zabbix"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_win_svc_name: Zabbix Agent zabbix_win_svc_name: Zabbix Agent
zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agentd.exe' zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agentd.exe'
zabbix_win_config_name: "zabbix_agentd.conf" zabbix_win_config_name: "zabbix_agentd.conf"
zabbix2_win_svc_name: Zabbix Agent 2 zabbix2_win_svc_name: Zabbix Agent 2
zabbix2_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agent2.exe' zabbix2_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agent2.exe'
zabbix2_win_config_name: "zabbix_agent2.conf" zabbix2_win_config_name: "zabbix_agent2.conf"
tags: tags:
- always - always
- name: "Windows | Check if Zabbix agent is present" - name: "Windows | Check if Zabbix agent is present"
ansible.windows.win_stat: ansible.windows.win_stat:
path: "{{ item }}" path: "{{ item }}"
with_items: with_items:
- "{{ zabbix_win_exe_path }}" - "{{ zabbix_win_exe_path }}"
- "{{ zabbix2_win_exe_path }}" - "{{ zabbix2_win_exe_path }}"
register: agent_file_info register: agent_file_info
tags: tags:
- always - always
- name: "Windows | Get Installed Zabbix Agent Version" - name: "Windows | Get Installed Zabbix Agent Version"
community.windows.win_file_version: community.windows.win_file_version:
path: "{{ item.item }}" path: "{{ item.item }}"
register: zabbix_win_exe_info register: zabbix_win_exe_info
when: when:
- item.stat.exists | bool - item.stat.exists | bool
with_items: "{{ agent_file_info.results }}" with_items: "{{ agent_file_info.results }}"
tags: tags:
- always - always
- name: "Windows | Set facts current zabbix agent installation" - name: "Windows | Set facts current zabbix agent installation"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_1_binary_exist: true zabbix_agent_1_binary_exist: true
zabbix_agent_1_version: zabbix_win_exe_info.results[0].win_file_version.product_version zabbix_agent_1_version: zabbix_win_exe_info.results[0].win_file_version.product_version
when: when:
- zabbix_win_exe_info.results[0] is defined - zabbix_win_exe_info.results[0] is defined
- zabbix_win_exe_info.results[0].item.stat.exists - zabbix_win_exe_info.results[0].item.stat.exists
- zabbix_win_exe_info.results[0].item.stat.path == zabbix_win_exe_path - zabbix_win_exe_info.results[0].item.stat.path == zabbix_win_exe_path
- zabbix_win_exe_info.results[0].win_file_version.product_version - zabbix_win_exe_info.results[0].win_file_version.product_version
tags: tags:
- always - always
- name: "Windows | Set facts current zabbix agent installation (agent 2)" - name: "Windows | Set facts current zabbix agent installation (agent 2)"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_2_binary_exist: true zabbix_agent_2_binary_exist: true
zabbix_agent_2_version: zabbix_win_exe_info.results[1].win_file_version.product_version zabbix_agent_2_version: zabbix_win_exe_info.results[1].win_file_version.product_version
when: when:
- zabbix_win_exe_info.results[1] is defined - zabbix_win_exe_info.results[1] is defined
- zabbix_win_exe_info.results[1].item.stat.exists - zabbix_win_exe_info.results[1].item.stat.exists
- zabbix_win_exe_info.results[1].item.stat.path == zabbix2_win_exe_path - zabbix_win_exe_info.results[1].item.stat.path == zabbix2_win_exe_path
- zabbix_win_exe_info.results[1].win_file_version.product_version - zabbix_win_exe_info.results[1].win_file_version.product_version
tags: tags:
- always - always
- name: "Windows | Check Zabbix service" - name: "Windows | Check Zabbix service"
ansible.windows.win_service: ansible.windows.win_service:
name: "{{ (item.item.stat.path == zabbix_win_exe_path ) | ternary(zabbix_win_svc_name,zabbix2_win_svc_name) }}" name: "{{ (item.item.stat.path == zabbix_win_exe_path ) | ternary(zabbix_win_svc_name,zabbix2_win_svc_name) }}"
register: zabbix_service_info register: zabbix_service_info
when: item.item.stat.exists when: item.item.stat.exists
with_items: "{{ zabbix_win_exe_info.results }}" with_items: "{{ zabbix_win_exe_info.results }}"
tags: tags:
- always - always
- name: "Windows | Set facts about current zabbix agent service state" - name: "Windows | Set facts about current zabbix agent service state"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_1_service_exist: true zabbix_agent_1_service_exist: true
when: when:
- zabbix_service_info.results[0].exists is defined - zabbix_service_info.results[0].exists is defined
- zabbix_service_info.results[0].exists - zabbix_service_info.results[0].exists
- zabbix_service_info.results[0].display_name == zabbix_win_svc_name - zabbix_service_info.results[0].display_name == zabbix_win_svc_name
tags: tags:
- always - always
- name: "Windows | Set facts about current zabbix agent service state (agent 2)" - name: "Windows | Set facts about current zabbix agent service state (agent 2)"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_2_service_exist: true zabbix_agent_2_service_exist: true
when: when:
- zabbix_service_info.results[1].exists is defined - zabbix_service_info.results[1].exists is defined
- zabbix_service_info.results[1].exists - zabbix_service_info.results[1].exists
- zabbix_service_info.results[1].display_name == zabbix2_win_svc_name - zabbix_service_info.results[1].display_name == zabbix2_win_svc_name
tags: tags:
- always - always
- name: "Windows | Set fact about version change requirement" - name: "Windows | Set fact about version change requirement"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_version_change: true zabbix_agent_version_change: true
when: > when: >
(zabbix_agent_1_binary_exist | default(false) and (zabbix_agent_1_binary_exist | default(false) and
zabbix_win_exe_info.results[0].win_file_version.product_version is version(zabbix_version_long, '<>')) zabbix_win_exe_info.results[0].win_file_version.product_version is version(zabbix_version_long, '<>'))
or or
(zabbix_agent_2_binary_exist | default(false) and (zabbix_agent_2_binary_exist | default(false) and
zabbix_win_exe_info.results[1].win_file_version.product_version is version(zabbix_version_long, '<>')) zabbix_win_exe_info.results[1].win_file_version.product_version is version(zabbix_version_long, '<>'))
or (zabbix_agent_1_binary_exist | default(false) and zabbix_agent2) or (zabbix_agent_1_binary_exist | default(false) and zabbix_agent2)
or (zabbix_agent_2_binary_exist | default(false) and not zabbix_agent2) or (zabbix_agent_2_binary_exist | default(false) and not zabbix_agent2)
tags: tags:
- always - always
################## ##################
# delete section # # delete section #
################## ##################
- name: "Windows | Stop Zabbix agent v1" - name: "Windows | Stop Zabbix agent v1"
ansible.windows.win_service: ansible.windows.win_service:
name: "{{ zabbix_win_svc_name }}" name: "{{ zabbix_win_svc_name }}"
start_mode: auto start_mode: auto
state: stopped state: stopped
when: when:
- zabbix_agent_version_change | default(false) or zabbix_agent2 - zabbix_agent_version_change | default(false) or zabbix_agent2
- zabbix_agent_1_service_exist | default(false) - zabbix_agent_1_service_exist | default(false)
- name: "Windows | Stop Zabbix agent v2" - name: "Windows | Stop Zabbix agent v2"
ansible.windows.win_service: ansible.windows.win_service:
name: "{{ zabbix2_win_svc_name }}" name: "{{ zabbix2_win_svc_name }}"
start_mode: auto start_mode: auto
state: stopped state: stopped
when: when:
- zabbix_agent_version_change | default(false) or not zabbix_agent2 - zabbix_agent_version_change | default(false) or not zabbix_agent2
- zabbix_agent_2_service_exist | default(false) - zabbix_agent_2_service_exist | default(false)
- name: "Windows | Uninstall Zabbix v1" - name: "Windows | Uninstall Zabbix v1"
ansible.windows.win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix_win_config_name }}" --uninstall' ansible.windows.win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix_win_config_name }}" --uninstall'
when: when:
- zabbix_agent_version_change | default(false) or zabbix_agent2 - zabbix_agent_version_change | default(false) or zabbix_agent2
- zabbix_agent_1_service_exist | default(false) - zabbix_agent_1_service_exist | default(false)
- name: "Windows | Uninstall Zabbix v2" - name: "Windows | Uninstall Zabbix v2"
ansible.windows.win_command: '"{{ zabbix2_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix2_win_config_name }}" --uninstall' ansible.windows.win_command: '"{{ zabbix2_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix2_win_config_name }}" --uninstall'
when: when:
- zabbix_agent_version_change | default(false) or not zabbix_agent2 - zabbix_agent_version_change | default(false) or not zabbix_agent2
- zabbix_agent_2_service_exist | default(false) - zabbix_agent_2_service_exist | default(false)
- name: "Windows | Removing Zabbix Directory" - name: "Windows | Removing Zabbix Directory"
ansible.windows.win_file: ansible.windows.win_file:
path: "{{ zabbix_win_install_dir }}" path: "{{ zabbix_win_install_dir }}"
state: absent state: absent
when: when:
((zabbix_agent_version_change | default(false) or zabbix_agent2) and zabbix_agent_1_binary_exist | default(false)) or ((zabbix_agent_version_change | default(false) or zabbix_agent2) and zabbix_agent_1_binary_exist | default(false)) or
((zabbix_agent_version_change | default(false) or not zabbix_agent2) and zabbix_agent_2_binary_exist | default(false)) ((zabbix_agent_version_change | default(false) or not zabbix_agent2) and zabbix_agent_2_binary_exist | default(false))
################### ###################
# install section # # install section #
################### ###################
- name: "Windows | Create directory structure" - name: "Windows | Create directory structure"
ansible.windows.win_file: ansible.windows.win_file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
with_items: with_items:
- "{{ zabbix_win_install_dir }}" - "{{ zabbix_win_install_dir }}"
tags: tags:
- install - install
- name: "Windows | Create directory structure, includes" - name: "Windows | Create directory structure, includes"
ansible.windows.win_file: ansible.windows.win_file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
with_items: with_items:
- "{{ zabbix_agent_win_include }}" - "{{ zabbix_agent_win_include }}"
when: when:
- ('.conf' not in zabbix_agent_win_include) - ('.conf' not in zabbix_agent_win_include)
tags: tags:
- install - install
- name: "Windows | Set installation settings (agent 2)" - name: "Windows | Set installation settings (agent 2)"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_win_package: "{{ zabbix2_win_package }}" zabbix_win_package: "{{ zabbix2_win_package }}"
zabbix_win_download_link: "{{ zabbix2_win_download_link }}" zabbix_win_download_link: "{{ zabbix2_win_download_link }}"
zabbix_win_exe_path: "{{ zabbix2_win_exe_path }}" zabbix_win_exe_path: "{{ zabbix2_win_exe_path }}"
zabbix_win_config_name: "{{ zabbix2_win_config_name }}" zabbix_win_config_name: "{{ zabbix2_win_config_name }}"
zabbix_win_svc_name: "{{ zabbix2_win_svc_name }}" zabbix_win_svc_name: "{{ zabbix2_win_svc_name }}"
when: zabbix_agent2 | bool when: zabbix_agent2 | bool
tags: tags:
- install - install
- name: "Windows | Check if agent file is already downloaded" - name: "Windows | Check if agent file is already downloaded"
ansible.windows.win_stat: ansible.windows.win_stat:
path: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' path: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}'
register: file_info register: file_info
tags: tags:
- install - install
- name: "Windows | Check if agent binaries in place" - name: "Windows | Check if agent binaries in place"
ansible.windows.win_stat: ansible.windows.win_stat:
path: "{{ zabbix_win_exe_path }}" path: "{{ zabbix_win_exe_path }}"
register: zabbix_windows_binaries register: zabbix_windows_binaries
tags: tags:
- install - install
- name: "Windows | Download Zabbix Agent Zip file" - name: "Windows | Download Zabbix Agent Zip file"
ansible.windows.win_get_url: ansible.windows.win_get_url:
url: "{{ zabbix_win_download_link }}" url: "{{ zabbix_win_download_link }}"
dest: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' dest: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}'
url_username: "{{ zabbix_download_user | default(omit) }}" url_username: "{{ zabbix_download_user | default(omit) }}"
url_password: "{{ zabbix_download_pass | default(omit) }}" url_password: "{{ zabbix_download_pass | default(omit) }}"
force: false force: false
follow_redirects: all follow_redirects: all
proxy_url: "{{ zabbix_https_proxy | default(None) | default(omit) }}" proxy_url: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
validate_certs: "{{ zabbix_download_validate_certs | default(False) | bool }}" validate_certs: "{{ zabbix_download_validate_certs | default(False) | bool }}"
timeout: "{{ zabbix_download_timeout | default(120) | int }}" timeout: "{{ zabbix_download_timeout | default(120) | int }}"
when: when:
- not file_info.stat.exists - not file_info.stat.exists
- not zabbix_windows_binaries.stat.exists - not zabbix_windows_binaries.stat.exists
register: zabbix_agent_win_download_zip register: zabbix_agent_win_download_zip
until: zabbix_agent_win_download_zip is succeeded until: zabbix_agent_win_download_zip is succeeded
throttle: "{{ zabbix_download_throttle | default(5) | int }}" throttle: "{{ zabbix_download_throttle | default(5) | int }}"
tags: tags:
- install - install
- name: "Windows | Unzip file" - name: "Windows | Unzip file"
community.windows.win_unzip: community.windows.win_unzip:
src: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' src: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}'
dest: "{{ zabbix_win_install_dir }}" dest: "{{ zabbix_win_install_dir }}"
creates: "{{ zabbix_win_exe_path }}" creates: "{{ zabbix_win_exe_path }}"
tags: tags:
- install - install
- name: "Windows | Cleanup downloaded Zabbix Agent Zip file" - name: "Windows | Cleanup downloaded Zabbix Agent Zip file"
ansible.windows.win_file: ansible.windows.win_file:
path: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}' path: '{{ zabbix_win_install_dir }}\{{ zabbix_win_package }}'
state: absent state: absent
when: when:
- zabbix_agent_win_download_zip.changed - zabbix_agent_win_download_zip.changed
tags: tags:
- install - install
- name: "Windows | Copy binary files to expected location" - name: "Windows | Copy binary files to expected location"
ansible.windows.win_copy: ansible.windows.win_copy:
src: "{{ zabbix_win_install_dir }}\\bin\\{{ item }}" src: "{{ zabbix_win_install_dir }}\\bin\\{{ item }}"
dest: "{{ zabbix_win_install_dir_bin }}\\{{ item }}" dest: "{{ zabbix_win_install_dir_bin }}\\{{ item }}"
remote_src: yes remote_src: yes
loop: loop:
- zabbix_agentd.exe - zabbix_agentd.exe
- zabbix_sender.exe - zabbix_sender.exe
when: when:
- zabbix_win_install_dir_bin is defined - zabbix_win_install_dir_bin is defined
- not (zabbix_agent2 | bool) - not (zabbix_agent2 | bool)
tags: tags:
- install - install
- name: "Windows | Copy binary files to expected location (zabbix-agent2)" - name: "Windows | Copy binary files to expected location (zabbix-agent2)"
ansible.windows.win_copy: ansible.windows.win_copy:
src: "{{ zabbix_win_install_dir }}\\bin\\{{ item }}" src: "{{ zabbix_win_install_dir }}\\bin\\{{ item }}"
dest: "{{ zabbix_win_install_dir_bin }}\\{{ item }}" dest: "{{ zabbix_win_install_dir_bin }}\\{{ item }}"
remote_src: yes remote_src: yes
loop: loop:
- zabbix_agent2.exe - zabbix_agent2.exe
when: when:
- zabbix_win_install_dir_bin is defined - zabbix_win_install_dir_bin is defined
- zabbix_agent2 | bool - zabbix_agent2 | bool
tags: tags:
- install - install
- set_fact: - set_fact:
zabbix_win_exe_path: "{{ zabbix_win_install_dir_bin }}\\zabbix_agentd.exe" zabbix_win_exe_path: "{{ zabbix_win_install_dir_bin }}\\zabbix_agentd.exe"
when: when:
- zabbix_win_install_dir_bin is defined - zabbix_win_install_dir_bin is defined
- not (zabbix_agent2 | bool) - not (zabbix_agent2 | bool)
tags: tags:
- install - install
- set_fact: - set_fact:
zabbix_win_exe_path: "{{ zabbix_win_install_dir_bin }}\\zabbix_agent2.exe" zabbix_win_exe_path: "{{ zabbix_win_install_dir_bin }}\\zabbix_agent2.exe"
when: when:
- zabbix_win_install_dir_bin is defined - zabbix_win_install_dir_bin is defined
- zabbix_agent2 | bool - zabbix_agent2 | bool
tags: tags:
- install - install
- name: "Create directory for PSK file if not exist." - name: "Create directory for PSK file if not exist."
ansible.windows.win_file: ansible.windows.win_file:
path: "{{ zabbix_agent_tlspskfile | win_dirname }}" path: "{{ zabbix_agent_tlspskfile | win_dirname }}"
state: directory state: directory
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- zabbix_agent_tlspskfile - zabbix_agent_tlspskfile
- not (zabbix_agent2 | bool) - not (zabbix_agent2 | bool)
tags: tags:
- config - config
- name: "Create directory for PSK file if not exist (zabbix-agent2)" - name: "Create directory for PSK file if not exist (zabbix-agent2)"
ansible.windows.win_file: ansible.windows.win_file:
path: "{{ zabbix_agent2_tlspskfile | win_dirname }}" path: "{{ zabbix_agent2_tlspskfile | win_dirname }}"
state: directory state: directory
when: when:
- zabbix_agent2_tlspskfile is defined - zabbix_agent2_tlspskfile is defined
- zabbix_agent2_tlspskfile - zabbix_agent2_tlspskfile
- zabbix_agent2 | bool - zabbix_agent2 | bool
tags: tags:
- config - config
- name: "Place TLS PSK File" - name: "Place TLS PSK File"
ansible.windows.win_copy: ansible.windows.win_copy:
dest: "{{ zabbix_agent_tlspskfile }}" dest: "{{ zabbix_agent_tlspskfile }}"
content: "{{ zabbix_agent_tlspsk_secret }}" content: "{{ zabbix_agent_tlspsk_secret }}"
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- zabbix_agent_tlspskfile - zabbix_agent_tlspskfile
- zabbix_agent_tlspsk_secret is defined - zabbix_agent_tlspsk_secret is defined
- not (zabbix_agent2 | bool) - not (zabbix_agent2 | bool)
notify: notify:
- restart win zabbix agent - restart win zabbix agent
tags: tags:
- config - config
- name: "Place TLS PSK File (zabbix-agent2)" - name: "Place TLS PSK File (zabbix-agent2)"
ansible.windows.win_copy: ansible.windows.win_copy:
dest: "{{ zabbix_agent2_tlspskfile }}" dest: "{{ zabbix_agent2_tlspskfile }}"
content: "{{ zabbix_agent2_tlspsk_secret }}" content: "{{ zabbix_agent2_tlspsk_secret }}"
when: when:
- zabbix_agent2_tlspskfile is defined - zabbix_agent2_tlspskfile is defined
- zabbix_agent2_tlspskfile - zabbix_agent2_tlspskfile
- zabbix_agent2_tlspsk_secret is defined - zabbix_agent2_tlspsk_secret is defined
- zabbix_agent2 | bool - zabbix_agent2 | bool
notify: notify:
- restart win zabbix agent - restart win zabbix agent
tags: tags:
- config - config
- name: "Windows | Check if windows service exist" - name: "Windows | Check if windows service exist"
ansible.windows.win_service: ansible.windows.win_service:
name: "{{ zabbix_win_svc_name }}" name: "{{ zabbix_win_svc_name }}"
register: zabbix_windows_service register: zabbix_windows_service
tags: tags:
- service - service
- name: "Windows | Register Service" - name: "Windows | Register Service"
ansible.windows.win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix_win_config_name }}" --install' ansible.windows.win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix_win_config_name }}" --install'
when: not zabbix_windows_service.exists when: not zabbix_windows_service.exists
tags: tags:
- service - service

View File

@@ -1,56 +1,56 @@
--- ---
- name: "Set default ip address for zabbix_agent_ip" - name: "Set default ip address for zabbix_agent_ip"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_ip_addresses'] | ansible.utils.ipv4 | first }}" zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_ip_addresses'] | ansible.utils.ipv4 | first }}"
when: when:
- zabbix_agent_ip is not defined - zabbix_agent_ip is not defined
- "'ansible_ip_addresses' in hostvars[inventory_hostname]" - "'ansible_ip_addresses' in hostvars[inventory_hostname]"
tags: tags:
- config - config
- name: "Windows | Configure zabbix-agent" - name: "Windows | Configure zabbix-agent"
ansible.windows.win_template: ansible.windows.win_template:
src: "{{ zabbix_win_config_name }}.j2" src: "{{ zabbix_win_config_name }}.j2"
dest: "{{ zabbix_win_install_dir_conf }}\\{{ zabbix_win_config_name }}" dest: "{{ zabbix_win_install_dir_conf }}\\{{ zabbix_win_config_name }}"
notify: restart win zabbix agent notify: restart win zabbix agent
tags: tags:
- config - config
- name: "Windows | Set service startup mode to auto, ensure it is started and set auto-recovery" - name: "Windows | Set service startup mode to auto, ensure it is started and set auto-recovery"
ansible.windows.win_service: ansible.windows.win_service:
name: "{{ zabbix_win_svc_name }}" name: "{{ zabbix_win_svc_name }}"
start_mode: auto start_mode: auto
state: started state: started
failure_actions: failure_actions:
- type: restart - type: restart
delay_ms: 5000 delay_ms: 5000
- type: restart - type: restart
delay_ms: 10000 delay_ms: 10000
- type: restart - type: restart
delay_ms: 20000 delay_ms: 20000
failure_reset_period_sec: 86400 failure_reset_period_sec: 86400
tags: tags:
- config - config
- name: "Windows | Check firewall service" - name: "Windows | Check firewall service"
ansible.windows.win_service_info: ansible.windows.win_service_info:
name: MpsSvc name: MpsSvc
register: firewall_info register: firewall_info
when: zabbix_win_firewall_management when: zabbix_win_firewall_management
tags: tags:
- config - config
- name: "Windows | Firewall rule" - name: "Windows | Firewall rule"
community.windows.win_firewall_rule: community.windows.win_firewall_rule:
name: "{{ zabbix_win_svc_name }}" name: "{{ zabbix_win_svc_name }}"
localport: "{{ zabbix_agent_listenport }}" localport: "{{ zabbix_agent_listenport }}"
action: allow action: allow
direction: in direction: in
protocol: tcp protocol: tcp
state: present state: present
enabled: true enabled: true
when: when:
- zabbix_win_firewall_management - zabbix_win_firewall_management
- firewall_info.services[0].state == 'started' or firewall_info.services[0].start_mode == 'auto' - firewall_info.services[0].state == 'started' or firewall_info.services[0].start_mode == 'auto'
tags: tags:
- config - config

View File

@@ -1,70 +1,70 @@
--- ---
# Tasks specific for RedHat systems # Tasks specific for RedHat systems
- name: "RedHat | Install basic repo file" - name: "RedHat | Install basic repo file"
ansible.builtin.yum_repository: ansible.builtin.yum_repository:
name: "{{ item.name }}" name: "{{ item.name }}"
description: "{{ item.description }}" description: "{{ item.description }}"
baseurl: "{{ item.baseurl }}" baseurl: "{{ item.baseurl }}"
gpgcheck: "{{ item.gpgcheck }}" gpgcheck: "{{ item.gpgcheck }}"
gpgkey: "{{ item.gpgkey }}" gpgkey: "{{ item.gpgkey }}"
mode: "{{ item.mode | default('0644') }}" mode: "{{ item.mode | default('0644') }}"
priority: "{{ item.priority | default('99') }}" priority: "{{ item.priority | default('99') }}"
state: "{{ item.state | default('present') }}" state: "{{ item.state | default('present') }}"
proxy: "{{ zabbix_http_proxy | default(omit) }}" proxy: "{{ zabbix_http_proxy | default(omit) }}"
with_items: "{{ zabbix_repo_yum }}" with_items: "{{ zabbix_repo_yum }}"
register: yum_repo_installed register: yum_repo_installed
become: true become: true
notify: notify:
- "clean repo files from proxy creds" - "clean repo files from proxy creds"
tags: tags:
- install - install
- name: Check if warn parameter can be used for shell module - name: Check if warn parameter can be used for shell module
ansible.builtin.set_fact: ansible.builtin.set_fact:
produce_warn: False produce_warn: False
when: ansible_version.full is version("2.14", "<") when: ansible_version.full is version("2.14", "<")
tags: tags:
- always - always
- name: "RedHat | Installing zabbix-agent" - name: "RedHat | Installing zabbix-agent"
ansible.builtin.package: ansible.builtin.package:
pkg: pkg:
- "{{ zabbix_agent_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_agent_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}"
disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}"
state: "{{ zabbix_agent_package_state }}" state: "{{ zabbix_agent_package_state }}"
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_package_installed register: zabbix_agent_package_installed
until: zabbix_agent_package_installed is succeeded until: zabbix_agent_package_installed is succeeded
become: true become: true
tags: tags:
- install - install
- name: "RedHat | Installing zabbix-{sender,get}" - name: "RedHat | Installing zabbix-{sender,get}"
ansible.builtin.package: ansible.builtin.package:
pkg: pkg:
- "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}"
- "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}"
disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}"
state: "{{ zabbix_agent_package_state }}" state: "{{ zabbix_agent_package_state }}"
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_package_installed register: zabbix_agent_package_installed
until: zabbix_agent_package_installed is succeeded until: zabbix_agent_package_installed is succeeded
when: when:
- not zabbix_agent_install_agent_only - not zabbix_agent_install_agent_only
become: true become: true
tags: tags:
- install - install
- name: "RedHat | Enable the service" - name: "RedHat | Enable the service"
ansible.builtin.service: ansible.builtin.service:
name: "{{ zabbix_agent_service }}" name: "{{ zabbix_agent_service }}"
enabled: true enabled: true
use: service use: service
become: true become: true
tags: tags:
- service - service

View File

@@ -1,96 +1,96 @@
--- ---
- name: "API | Create host groups" - name: "API | Create host groups"
community.zabbix.zabbix_group: community.zabbix.zabbix_group:
host_group: "{{ zabbix_host_groups }}" host_group: "{{ zabbix_host_groups }}"
state: "{{ zabbix_agent_hostgroups_state }}" state: "{{ zabbix_agent_hostgroups_state }}"
when: when:
- zabbix_api_create_hostgroup | bool - zabbix_api_create_hostgroup | bool
register: zabbix_api_hostgroup_created register: zabbix_api_hostgroup_created
until: zabbix_api_hostgroup_created is succeeded until: zabbix_api_hostgroup_created is succeeded
delegate_to: "{{ zabbix_api_server_host }}" delegate_to: "{{ zabbix_api_server_host }}"
tags: tags:
- api - api
- name: "API | Create a new host or update an existing host's info" - name: "API | Create a new host or update an existing host's info"
community.zabbix.zabbix_host: community.zabbix.zabbix_host:
host_name: "{{ zabbix_agent_hostname }}" host_name: "{{ zabbix_agent_hostname }}"
host_groups: "{{ zabbix_host_groups }}" host_groups: "{{ zabbix_host_groups }}"
link_templates: "{{ zabbix_agent_link_templates }}" link_templates: "{{ zabbix_agent_link_templates }}"
status: "{{ zabbix_host_status }}" status: "{{ zabbix_host_status }}"
state: "{{ zabbix_agent_host_state }}" state: "{{ zabbix_agent_host_state }}"
force: "{{ zabbix_agent_host_update }}" force: "{{ zabbix_agent_host_update }}"
proxy: "{{ zabbix_agent_proxy }}" proxy: "{{ zabbix_agent_proxy }}"
inventory_mode: "{{ zabbix_agent_inventory_mode }}" inventory_mode: "{{ zabbix_agent_inventory_mode }}"
interfaces: "{{ zabbix_agent_interfaces }}" interfaces: "{{ zabbix_agent_interfaces }}"
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}" visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}"
tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}" tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}"
tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}" tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}"
tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}" tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}"
tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}" tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}"
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}" tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}"
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}" tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}"
description: "{{ zabbix_agent_description | default(omit) }}" description: "{{ zabbix_agent_description | default(omit) }}"
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}" inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}" ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}"
ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}" ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}"
ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}" ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}"
ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}" ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}"
tags: "{{ zabbix_agent_tags }}" tags: "{{ zabbix_agent_tags }}"
when: when:
- not zabbix_agent2 - not zabbix_agent2
register: zabbix_api_host_created register: zabbix_api_host_created
until: zabbix_api_host_created is succeeded until: zabbix_api_host_created is succeeded
delegate_to: "{{ zabbix_api_server_host }}" delegate_to: "{{ zabbix_api_server_host }}"
changed_when: false changed_when: false
tags: tags:
- api - api
- name: "API | Create a new host using agent2 or update an existing host's info" - name: "API | Create a new host using agent2 or update an existing host's info"
community.zabbix.zabbix_host: community.zabbix.zabbix_host:
host_name: "{{ zabbix_agent2_hostname }}" host_name: "{{ zabbix_agent2_hostname }}"
host_groups: "{{ zabbix_host_groups }}" host_groups: "{{ zabbix_host_groups }}"
link_templates: "{{ zabbix_agent_link_templates }}" link_templates: "{{ zabbix_agent_link_templates }}"
status: "{{ zabbix_host_status }}" status: "{{ zabbix_host_status }}"
state: "{{ zabbix_agent_host_state }}" state: "{{ zabbix_agent_host_state }}"
force: "{{ zabbix_agent_host_update }}" force: "{{ zabbix_agent_host_update }}"
proxy: "{{ zabbix_agent_proxy }}" proxy: "{{ zabbix_agent_proxy }}"
inventory_mode: "{{ zabbix_agent_inventory_mode }}" inventory_mode: "{{ zabbix_agent_inventory_mode }}"
interfaces: "{{ zabbix_agent_interfaces }}" interfaces: "{{ zabbix_agent_interfaces }}"
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent2_hostname) }}" visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent2_hostname) }}"
tls_psk: "{{ zabbix_agent2_tlspsk_secret | default(omit) }}" tls_psk: "{{ zabbix_agent2_tlspsk_secret | default(omit) }}"
tls_psk_identity: "{{ zabbix_agent2_tlspskidentity | default(omit) }}" tls_psk_identity: "{{ zabbix_agent2_tlspskidentity | default(omit) }}"
tls_issuer: "{{ zabbix_agent2_tlsservercertissuer | default(omit) }}" tls_issuer: "{{ zabbix_agent2_tlsservercertissuer | default(omit) }}"
tls_subject: "{{ zabbix_agent2_tls_subject | default(omit) }}" tls_subject: "{{ zabbix_agent2_tls_subject | default(omit) }}"
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsaccept if zabbix_agent2_tlsaccept else 'unencrypted'] }}" tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsaccept if zabbix_agent2_tlsaccept else 'unencrypted'] }}"
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsconnect if zabbix_agent2_tlsconnect else 'unencrypted'] }}" tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsconnect if zabbix_agent2_tlsconnect else 'unencrypted'] }}"
description: "{{ zabbix_agent_description | default(omit) }}" description: "{{ zabbix_agent_description | default(omit) }}"
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}" inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}" ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}"
ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}" ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}"
ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}" ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}"
ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}" ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}"
tags: "{{ zabbix_agent_tags }}" tags: "{{ zabbix_agent_tags }}"
when: when:
- zabbix_agent2 | bool - zabbix_agent2 | bool
register: zabbix_api_host_created register: zabbix_api_host_created
until: zabbix_api_host_created is succeeded until: zabbix_api_host_created is succeeded
delegate_to: "{{ zabbix_api_server_host }}" delegate_to: "{{ zabbix_api_server_host }}"
changed_when: false changed_when: false
tags: tags:
- api - api
- name: "API | Updating host configuration with macros" - name: "API | Updating host configuration with macros"
community.zabbix.zabbix_hostmacro: community.zabbix.zabbix_hostmacro:
host_name: "{{ (zabbix_agent2 | bool) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname) }}" host_name: "{{ (zabbix_agent2 | bool) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname) }}"
macro_name: "{{ item.macro_key }}" macro_name: "{{ item.macro_key }}"
macro_value: "{{ item.macro_value }}" macro_value: "{{ item.macro_value }}"
macro_type: "{{ item.macro_type|default('text') }}" macro_type: "{{ item.macro_type|default('text') }}"
with_items: "{{ zabbix_agent_macros | default([]) }}" with_items: "{{ zabbix_agent_macros | default([]) }}"
when: when:
- zabbix_agent_macros is defined - zabbix_agent_macros is defined
- item.macro_key is defined - item.macro_key is defined
register: zabbix_api_hostmarcro_created register: zabbix_api_hostmarcro_created
until: zabbix_api_hostmarcro_created is succeeded until: zabbix_api_hostmarcro_created is succeeded
delegate_to: "{{ zabbix_api_server_host }}" delegate_to: "{{ zabbix_api_server_host }}"
tags: tags:
- api - api

View File

@@ -1,22 +1,22 @@
--- ---
# Tasks specific for macOS # Tasks specific for macOS
- name: "macOS | Check installed package version" - name: "macOS | Check installed package version"
ansible.builtin.shell: | ansible.builtin.shell: |
set -o pipefail set -o pipefail
pkgutil --pkg-info 'com.zabbix.pkg.ZabbixAgent' | grep 'version:' | cut -d ' ' -f 2 pkgutil --pkg-info 'com.zabbix.pkg.ZabbixAgent' | grep 'version:' | cut -d ' ' -f 2
register: pkgutil_version register: pkgutil_version
check_mode: false check_mode: false
changed_when: false changed_when: false
failed_when: pkgutil_version.rc == 2 failed_when: pkgutil_version.rc == 2
- name: "macOS | Download the Zabbix package" - name: "macOS | Download the Zabbix package"
ansible.builtin.get_url: ansible.builtin.get_url:
url: "{{ zabbix_mac_download_link }}" url: "{{ zabbix_mac_download_link }}"
dest: "/tmp/{{ zabbix_mac_package }}" dest: "/tmp/{{ zabbix_mac_package }}"
mode: 0644 mode: 0644
when: pkgutil_version.stdout != zabbix_version_long when: pkgutil_version.stdout != zabbix_version_long
- name: "macOS | Install the Zabbix package" - name: "macOS | Install the Zabbix package"
ansible.builtin.command: installer -pkg "/tmp/{{ zabbix_mac_package }}" -target / ansible.builtin.command: installer -pkg "/tmp/{{ zabbix_mac_package }}" -target /
become: true become: true
when: pkgutil_version.stdout != zabbix_version_long when: pkgutil_version.stdout != zabbix_version_long

View File

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

View File

@@ -1,25 +1,25 @@
--- ---
- name: Pull service facts - name: Pull service facts
ansible.builtin.service_facts: ansible.builtin.service_facts:
- name: 'Remove | Make sure the "old" zabbix-agent service stopped' - name: 'Remove | Make sure the "old" zabbix-agent service stopped'
ansible.builtin.service: ansible.builtin.service:
name: "zabbix-agent" name: "zabbix-agent"
state: stopped state: stopped
enabled: false enabled: false
become: true become: true
when: | when: |
ansible_facts.services["zabbix-agent.service"] is defined or ansible_facts.services["zabbix-agent.service"] is defined or
ansible_facts.services["zabbix-agent"] is defined ansible_facts.services["zabbix-agent"] is defined
- name: "Remove | Package removal" - name: "Remove | Package removal"
ansible.builtin.package: ansible.builtin.package:
name: "zabbix-agent" name: "zabbix-agent"
state: absent state: absent
become: true become: true
- name: "Remove | Remove the agent-include-dir" - name: "Remove | Remove the agent-include-dir"
ansible.builtin.file: ansible.builtin.file:
path: "{{ zabbix_agent_include }}" path: "{{ zabbix_agent_include }}"
state: absent state: absent
become: true become: true

View File

@@ -1,110 +1,110 @@
--- ---
- name: "SELinux | Debian | Install policycoreutils-python" - name: "SELinux | Debian | Install policycoreutils-python"
ansible.builtin.apt: ansible.builtin.apt:
pkg: policycoreutils-python-utils pkg: policycoreutils-python-utils
state: present state: present
update_cache: true update_cache: true
cache_valid_time: 0 cache_valid_time: 0
force_apt_get: "{{ zabbix_apt_force_apt_get }}" force_apt_get: "{{ zabbix_apt_force_apt_get }}"
install_recommends: "{{ zabbix_apt_install_recommends }}" install_recommends: "{{ zabbix_apt_install_recommends }}"
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_policycoreutils_installed register: zabbix_agent_policycoreutils_installed
until: zabbix_agent_package_installed is succeeded until: zabbix_agent_package_installed is succeeded
become: true become: true
when: when:
- ansible_os_family == "Debian" - ansible_os_family == "Debian"
tags: tags:
- install - install
- name: "SELinux | RedHat | Install policycoreutils-python" - name: "SELinux | RedHat | Install policycoreutils-python"
ansible.builtin.package: ansible.builtin.package:
name: policycoreutils-python name: policycoreutils-python
state: installed state: installed
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_policycoreutils_installed register: zabbix_agent_policycoreutils_installed
until: zabbix_agent_policycoreutils_installed is succeeded until: zabbix_agent_policycoreutils_installed is succeeded
when: when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
- (zabbix_agent_distribution_major_version == "6" or zabbix_agent_distribution_major_version == "7") - (zabbix_agent_distribution_major_version == "6" or zabbix_agent_distribution_major_version == "7")
become: true become: true
tags: tags:
- install - install
- name: "SELinux | RedHat | Install python3-policycoreutils on RHEL8" - name: "SELinux | RedHat | Install python3-policycoreutils on RHEL8"
ansible.builtin.package: ansible.builtin.package:
name: python3-policycoreutils name: python3-policycoreutils
state: installed state: installed
environment: environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}" http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}" https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_policycoreutils_installed register: zabbix_agent_policycoreutils_installed
until: zabbix_agent_policycoreutils_installed is succeeded until: zabbix_agent_policycoreutils_installed is succeeded
when: when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
- ansible_distribution_major_version == "8" - ansible_distribution_major_version == "8"
become: true become: true
tags: tags:
- install - install
- name: "SELinux | RedHat | Install selinux-policy-targeted" - name: "SELinux | RedHat | Install selinux-policy-targeted"
ansible.builtin.package: ansible.builtin.package:
name: selinux-policy-targeted name: selinux-policy-targeted
state: installed state: installed
register: zabbix_agent_selinuxpolicytargeted_installed register: zabbix_agent_selinuxpolicytargeted_installed
until: zabbix_agent_selinuxpolicytargeted_installed is succeeded until: zabbix_agent_selinuxpolicytargeted_installed is succeeded
when: when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
become: true become: true
tags: tags:
- install - install
# straight to getenforce binary , workaround for missing python_selinux library # straight to getenforce binary , workaround for missing python_selinux library
- name: "SELinux | Get getenforce binary" - name: "SELinux | Get getenforce binary"
ansible.builtin.stat: ansible.builtin.stat:
path: /usr/sbin/getenforce path: /usr/sbin/getenforce
register: getenforce_bin register: getenforce_bin
become: true become: true
tags: tags:
- always - always
- name: "SELinux | Collect getenforce output" - name: "SELinux | Collect getenforce output"
ansible.builtin.command: /usr/sbin/getenforce ansible.builtin.command: /usr/sbin/getenforce
register: sestatus register: sestatus
when: "getenforce_bin.stat.exists" when: "getenforce_bin.stat.exists"
changed_when: false changed_when: false
become: true become: true
check_mode: false check_mode: false
tags: tags:
- always - always
- name: "SELinux | Set zabbix_selinux to true if getenforce returns Enforcing or Permissive" - name: "SELinux | Set zabbix_selinux to true if getenforce returns Enforcing or Permissive"
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_selinux: "{{ true }}" zabbix_selinux: "{{ true }}"
when: when:
- 'getenforce_bin.stat.exists and ("Enforcing" in sestatus.stdout or "Permissive" in sestatus.stdout)' - 'getenforce_bin.stat.exists and ("Enforcing" in sestatus.stdout or "Permissive" in sestatus.stdout)'
tags: tags:
- always - always
- name: "SELinux | Allow zabbix_agent to start (SELinux)" - name: "SELinux | Allow zabbix_agent to start (SELinux)"
community.general.selinux_permissive: community.general.selinux_permissive:
name: zabbix_agent_t name: zabbix_agent_t
permissive: true permissive: true
become: true become: true
tags: tags:
- config - config
- name: "SELinux | Allow zabbix to run sudo commands (SELinux)" - name: "SELinux | Allow zabbix to run sudo commands (SELinux)"
ansible.posix.seboolean: ansible.posix.seboolean:
name: zabbix_run_sudo name: zabbix_run_sudo
persistent: true persistent: true
state: true state: true
become: true become: true
when: when:
- ansible_selinux.status == "enabled" - ansible_selinux.status == "enabled"
- selinux_allow_zabbix_run_sudo|bool - selinux_allow_zabbix_run_sudo|bool
tags: tags:
- config - config

View File

@@ -1,14 +1,14 @@
--- ---
- ansible.builtin.include_tasks: tlspsk_auto_linux.yml - ansible.builtin.include_tasks: tlspsk_auto_linux.yml
when: (ansible_os_family != "Windows") or (zabbix_agent_docker | bool) when: (ansible_os_family != "Windows") or (zabbix_agent_docker | bool)
- ansible.builtin.include_tasks: tlspsk_auto_windows.yml - ansible.builtin.include_tasks: tlspsk_auto_windows.yml
when: ansible_os_family == "Windows" when: ansible_os_family == "Windows"
- name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK - name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlsaccept: psk zabbix_agent_tlsaccept: psk
zabbix_agent_tlsconnect: psk zabbix_agent_tlsconnect: psk
when: zabbix_api_create_hosts when: zabbix_api_create_hosts
tags: tags:
- config - config

View File

@@ -1,14 +1,14 @@
--- ---
- include_tasks: tlspsk_auto_agent2_linux.yml - include_tasks: tlspsk_auto_agent2_linux.yml
when: (ansible_os_family != "Windows") or (zabbix_agent_docker | bool) when: (ansible_os_family != "Windows") or (zabbix_agent_docker | bool)
- include_tasks: tlspsk_auto_agent2_windows.yml - include_tasks: tlspsk_auto_agent2_windows.yml
when: ansible_os_family == "Windows" when: ansible_os_family == "Windows"
- name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK - name: AutoPSK | Default tlsaccept and tlsconnect to enforce PSK
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlsaccept: psk zabbix_agent2_tlsaccept: psk
zabbix_agent2_tlsconnect: psk zabbix_agent2_tlsconnect: psk
when: zabbix_api_create_hosts when: zabbix_api_create_hosts
tags: tags:
- config - config

View File

@@ -1,53 +1,53 @@
--- ---
# Process PSK Secret # Process PSK Secret
- name: AutoPSK | Save existing TLS PSK secret - name: AutoPSK | Save existing TLS PSK secret
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspsk_read: "{{ zabbix_agent2_tlspsk_base64['content'] | b64decode | trim }}" zabbix_agent2_tlspsk_read: "{{ zabbix_agent2_tlspsk_base64['content'] | b64decode | trim }}"
when: zabbix_agent2_tlspskcheck.stat.exists when: zabbix_agent2_tlspskcheck.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Use existing TLS PSK secret - name: AutoPSK | Use existing TLS PSK secret
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspsk_secret: "{{ zabbix_agent2_tlspsk_read }}" zabbix_agent2_tlspsk_secret: "{{ zabbix_agent2_tlspsk_read }}"
when: when:
- zabbix_agent2_tlspskcheck.stat.exists - zabbix_agent2_tlspskcheck.stat.exists
- zabbix_agent2_tlspsk_read|length >= 32 - zabbix_agent2_tlspsk_read|length >= 32
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Generate new TLS PSK secret - name: AutoPSK | Generate new TLS PSK secret
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}" zabbix_agent2_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}"
when: when:
- not zabbix_agent2_tlspskcheck.stat.exists - not zabbix_agent2_tlspskcheck.stat.exists
- (zabbix_agent2_tlspsk_read is not defined) or (zabbix_agent2_tlspsk_read|length < 32) - (zabbix_agent2_tlspsk_read is not defined) or (zabbix_agent2_tlspsk_read|length < 32)
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
# Process PSK Identity # Process PSK Identity
- name: AutoPSK | Use existing TLS PSK identity - name: AutoPSK | Use existing TLS PSK identity
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspskidentity: "{{ zabbix_agent2_tlspskidentity_base64['content'] | b64decode | trim }}" zabbix_agent2_tlspskidentity: "{{ zabbix_agent2_tlspskidentity_base64['content'] | b64decode | trim }}"
when: when:
- zabbix_agent2_tlspskidentity_check.stat.exists - zabbix_agent2_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Generate new TLS PSK identity - name: AutoPSK | Generate new TLS PSK identity
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspskidentity: >- zabbix_agent2_tlspskidentity: >-
{{ {{
zabbix_agent_visible_hostname zabbix_agent_visible_hostname
| default(((zabbix_agent2 == True) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname))) | default(((zabbix_agent2 == True) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname)))
+ '_' + '_'
+ lookup('password', '/dev/null chars=hexdigits length=4') + lookup('password', '/dev/null chars=hexdigits length=4')
}} }}
when: not zabbix_agent2_tlspskidentity_check.stat.exists when: not zabbix_agent2_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config

View File

@@ -1,80 +1,80 @@
--- ---
- name: AutoPSK | Set default path variables (Linux) - name: AutoPSK | Set default path variables (Linux)
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspskfile: "/etc/zabbix/tls_psk_auto.secret" zabbix_agent2_tlspskfile: "/etc/zabbix/tls_psk_auto.secret"
zabbix_agent2_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" zabbix_agent2_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity"
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK file (Linux) - name: AutoPSK | Check for existing TLS PSK file (Linux)
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ zabbix_agent2_tlspskfile }}" path: "{{ zabbix_agent2_tlspskfile }}"
register: zabbix_agent2_tlspskcheck register: zabbix_agent2_tlspskcheck
become: true become: true
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK identity (Linux) - name: AutoPSK | Check for existing TLS PSK identity (Linux)
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ zabbix_agent2_tlspskidentity_file }}" path: "{{ zabbix_agent2_tlspskidentity_file }}"
register: zabbix_agent2_tlspskidentity_check register: zabbix_agent2_tlspskidentity_check
become: true become: true
tags: tags:
- config - config
- name: AutoPSK | read existing TLS PSK file (Linux) - name: AutoPSK | read existing TLS PSK file (Linux)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent2_tlspskfile }}" src: "{{ zabbix_agent2_tlspskfile }}"
register: zabbix_agent2_tlspsk_base64 register: zabbix_agent2_tlspsk_base64
become: true become: true
when: when:
- zabbix_agent2_tlspskcheck.stat.exists - zabbix_agent2_tlspskcheck.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Read existing TLS PSK identity file (Linux) - name: AutoPSK | Read existing TLS PSK identity file (Linux)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent2_tlspskidentity_file }}" src: "{{ zabbix_agent2_tlspskidentity_file }}"
register: zabbix_agent2_tlspskidentity_base64 register: zabbix_agent2_tlspskidentity_base64
become: true become: true
when: zabbix_agent2_tlspskidentity_check.stat.exists when: zabbix_agent2_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- include_tasks: tlspsk_auto_agent2_common.yml - include_tasks: tlspsk_auto_agent2_common.yml
- name: AutoPSK | Template TLS PSK identity in file (Linux) - name: AutoPSK | Template TLS PSK identity in file (Linux)
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ zabbix_agent2_tlspskidentity_file }}" dest: "{{ zabbix_agent2_tlspskidentity_file }}"
content: "{{ zabbix_agent2_tlspskidentity }}" content: "{{ zabbix_agent2_tlspskidentity }}"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0400 mode: 0400
become: true become: true
when: when:
- zabbix_agent2_tlspskidentity_file is defined - zabbix_agent2_tlspskidentity_file is defined
- zabbix_agent2_tlspskidentity is defined - zabbix_agent2_tlspskidentity is defined
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
tags: tags:
- config - config
- name: AutoPSK | Template TLS PSK secret in file (Linux) - name: AutoPSK | Template TLS PSK secret in file (Linux)
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ zabbix_agent2_tlspskfile }}" dest: "{{ zabbix_agent2_tlspskfile }}"
content: "{{ zabbix_agent2_tlspsk_secret }}" content: "{{ zabbix_agent2_tlspsk_secret }}"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0400 mode: 0400
become: true become: true
when: when:
- zabbix_agent2_tlspskfile is defined - zabbix_agent2_tlspskfile is defined
- zabbix_agent2_tlspsk_secret is defined - zabbix_agent2_tlspsk_secret is defined
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
tags: tags:
- config - config

View File

@@ -1,66 +1,66 @@
--- ---
- name: AutoPSK | Set default path variables for Windows - name: AutoPSK | Set default path variables for Windows
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent2_tlspskfile: "{{ zabbix_win_install_dir }}\\tls_psk_auto.secret.txt" zabbix_agent2_tlspskfile: "{{ zabbix_win_install_dir }}\\tls_psk_auto.secret.txt"
zabbix_agent2_tlspskidentity_file: "{{ zabbix_win_install_dir }}\\tls_psk_auto.identity.txt" zabbix_agent2_tlspskidentity_file: "{{ zabbix_win_install_dir }}\\tls_psk_auto.identity.txt"
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK file (Windows) - name: AutoPSK | Check for existing TLS PSK file (Windows)
ansible.windows.win_stat: ansible.windows.win_stat:
path: "{{ zabbix_agent2_tlspskfile }}" path: "{{ zabbix_agent2_tlspskfile }}"
register: zabbix_agent2_tlspskcheck register: zabbix_agent2_tlspskcheck
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK identity (Windows) - name: AutoPSK | Check for existing TLS PSK identity (Windows)
ansible.windows.win_stat: ansible.windows.win_stat:
path: "{{ zabbix_agent2_tlspskidentity_file }}" path: "{{ zabbix_agent2_tlspskidentity_file }}"
register: zabbix_agent2_tlspskidentity_check register: zabbix_agent2_tlspskidentity_check
tags: tags:
- config - config
- name: AutoPSK | read existing TLS PSK file (Windows) - name: AutoPSK | read existing TLS PSK file (Windows)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent2_tlspskfile }}" src: "{{ zabbix_agent2_tlspskfile }}"
register: zabbix_agent2_tlspsk_base64 register: zabbix_agent2_tlspsk_base64
when: when:
- zabbix_agent2_tlspskcheck.stat.exists - zabbix_agent2_tlspskcheck.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Read existing TLS PSK identity file (Windows) - name: AutoPSK | Read existing TLS PSK identity file (Windows)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent2_tlspskidentity_file }}" src: "{{ zabbix_agent2_tlspskidentity_file }}"
register: zabbix_agent2_tlspskidentity_base64 register: zabbix_agent2_tlspskidentity_base64
when: zabbix_agent2_tlspskidentity_check.stat.exists when: zabbix_agent2_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- ansible.builtin.include_tasks: tlspsk_auto_agent2_common.yml - ansible.builtin.include_tasks: tlspsk_auto_agent2_common.yml
- name: Windows | AutoPSK | Template TLS PSK identity in file (Windows) - name: Windows | AutoPSK | Template TLS PSK identity in file (Windows)
ansible.windows.win_copy: ansible.windows.win_copy:
dest: "{{ zabbix_agent2_tlspskidentity_file }}" dest: "{{ zabbix_agent2_tlspskidentity_file }}"
content: "{{ zabbix_agent2_tlspskidentity }}" content: "{{ zabbix_agent2_tlspskidentity }}"
when: when:
- zabbix_agent2_tlspskidentity_file is defined - zabbix_agent2_tlspskidentity_file is defined
- zabbix_agent2_tlspskidentity is defined - zabbix_agent2_tlspskidentity is defined
notify: notify:
- restart win zabbix agent - restart win zabbix agent
tags: tags:
- config - config
- name: AutoPSK | Template TLS PSK secret in file (Windows) - name: AutoPSK | Template TLS PSK secret in file (Windows)
ansible.windows.win_copy: ansible.windows.win_copy:
dest: "{{ zabbix_agent2_tlspskfile }}" dest: "{{ zabbix_agent2_tlspskfile }}"
content: "{{ zabbix_agent2_tlspsk_secret }}" content: "{{ zabbix_agent2_tlspsk_secret }}"
when: when:
- zabbix_agent2_tlspskfile is defined - zabbix_agent2_tlspskfile is defined
- zabbix_agent2_tlspsk_secret is defined - zabbix_agent2_tlspsk_secret is defined
notify: notify:
- restart win zabbix agent - restart win zabbix agent
tags: tags:
- config - config

View File

@@ -1,52 +1,52 @@
--- ---
# Process PSK Secret # Process PSK Secret
- name: AutoPSK | Save existing TLS PSK secret - name: AutoPSK | Save existing TLS PSK secret
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspsk_read: "{{ zabbix_agent_tlspsk_base64['content'] | b64decode | trim }}" zabbix_agent_tlspsk_read: "{{ zabbix_agent_tlspsk_base64['content'] | b64decode | trim }}"
when: zabbix_agent_tlspskcheck.stat.exists when: zabbix_agent_tlspskcheck.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Use existing TLS PSK secret - name: AutoPSK | Use existing TLS PSK secret
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspsk_secret: "{{ zabbix_agent_tlspsk_read }}" zabbix_agent_tlspsk_secret: "{{ zabbix_agent_tlspsk_read }}"
when: when:
- zabbix_agent_tlspskcheck.stat.exists - zabbix_agent_tlspskcheck.stat.exists
- zabbix_agent_tlspsk_read|length >= 32 - zabbix_agent_tlspsk_read|length >= 32
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Generate new TLS PSK secret - name: AutoPSK | Generate new TLS PSK secret
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}" zabbix_agent_tlspsk_secret: "{{ lookup('password', '/dev/null chars=hexdigits length=64') }}"
when: when:
- (not zabbix_agent_tlspskcheck.stat.exists) or (zabbix_agent_tlspsk_read|length < 32) - (not zabbix_agent_tlspskcheck.stat.exists) or (zabbix_agent_tlspsk_read|length < 32)
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
# Process PSK Identity # Process PSK Identity
- name: AutoPSK | Use existing TLS PSK identity - name: AutoPSK | Use existing TLS PSK identity
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspskidentity: "{{ zabbix_agent_tlspskidentity_base64['content'] | b64decode | trim }}" zabbix_agent_tlspskidentity: "{{ zabbix_agent_tlspskidentity_base64['content'] | b64decode | trim }}"
when: when:
- zabbix_agent_tlspskidentity_check.stat.exists - zabbix_agent_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Generate new TLS PSK identity - name: AutoPSK | Generate new TLS PSK identity
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspskidentity: >- zabbix_agent_tlspskidentity: >-
{{ {{
zabbix_agent_visible_hostname zabbix_agent_visible_hostname
| default(((zabbix_agent2 != True) | ternary(zabbix_agent_hostname, zabbix_agent_hostname))) | default(((zabbix_agent2 != True) | ternary(zabbix_agent_hostname, zabbix_agent_hostname)))
+ '_' + '_'
+ lookup('password', '/dev/null chars=hexdigits length=4') + lookup('password', '/dev/null chars=hexdigits length=4')
}} }}
when: not zabbix_agent_tlspskidentity_check.stat.exists when: not zabbix_agent_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config

View File

@@ -1,80 +1,80 @@
--- ---
- name: AutoPSK | Set default path variables (Linux) - name: AutoPSK | Set default path variables (Linux)
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspskfile: "/etc/zabbix/tls_psk_auto.secret" zabbix_agent_tlspskfile: "/etc/zabbix/tls_psk_auto.secret"
zabbix_agent_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" zabbix_agent_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity"
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK file (Linux) - name: AutoPSK | Check for existing TLS PSK file (Linux)
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ zabbix_agent_tlspskfile }}" path: "{{ zabbix_agent_tlspskfile }}"
register: zabbix_agent_tlspskcheck register: zabbix_agent_tlspskcheck
become: true become: true
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK identity (Linux) - name: AutoPSK | Check for existing TLS PSK identity (Linux)
ansible.builtin.stat: ansible.builtin.stat:
path: "{{ zabbix_agent_tlspskidentity_file }}" path: "{{ zabbix_agent_tlspskidentity_file }}"
register: zabbix_agent_tlspskidentity_check register: zabbix_agent_tlspskidentity_check
become: true become: true
tags: tags:
- config - config
- name: AutoPSK | read existing TLS PSK file (Linux) - name: AutoPSK | read existing TLS PSK file (Linux)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent_tlspskfile }}" src: "{{ zabbix_agent_tlspskfile }}"
register: zabbix_agent_tlspsk_base64 register: zabbix_agent_tlspsk_base64
become: true become: true
when: when:
- zabbix_agent_tlspskcheck.stat.exists - zabbix_agent_tlspskcheck.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Read existing TLS PSK identity file (Linux) - name: AutoPSK | Read existing TLS PSK identity file (Linux)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent_tlspskidentity_file }}" src: "{{ zabbix_agent_tlspskidentity_file }}"
register: zabbix_agent_tlspskidentity_base64 register: zabbix_agent_tlspskidentity_base64
become: true become: true
when: zabbix_agent_tlspskidentity_check.stat.exists when: zabbix_agent_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- include_tasks: tlspsk_auto_common.yml - include_tasks: tlspsk_auto_common.yml
- name: AutoPSK | Template TLS PSK identity in file (Linux) - name: AutoPSK | Template TLS PSK identity in file (Linux)
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ zabbix_agent_tlspskidentity_file }}" dest: "{{ zabbix_agent_tlspskidentity_file }}"
content: "{{ zabbix_agent_tlspskidentity }}" content: "{{ zabbix_agent_tlspskidentity }}"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0400 mode: 0400
become: true become: true
when: when:
- zabbix_agent_tlspskidentity_file is defined - zabbix_agent_tlspskidentity_file is defined
- zabbix_agent_tlspskidentity is defined - zabbix_agent_tlspskidentity is defined
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
tags: tags:
- config - config
- name: AutoPSK | Template TLS PSK secret in file (Linux) - name: AutoPSK | Template TLS PSK secret in file (Linux)
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ zabbix_agent_tlspskfile }}" dest: "{{ zabbix_agent_tlspskfile }}"
content: "{{ zabbix_agent_tlspsk_secret }}" content: "{{ zabbix_agent_tlspsk_secret }}"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0400 mode: 0400
become: true become: true
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- zabbix_agent_tlspsk_secret is defined - zabbix_agent_tlspsk_secret is defined
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
tags: tags:
- config - config

View File

@@ -1,67 +1,67 @@
--- ---
- name: AutoPSK | Set default path variables for Windows - name: AutoPSK | Set default path variables for Windows
ansible.builtin.set_fact: ansible.builtin.set_fact:
zabbix_agent_tlspskfile: "{{ zabbix_win_install_dir }}\\tls_psk_auto.secret.txt" zabbix_agent_tlspskfile: "{{ zabbix_win_install_dir }}\\tls_psk_auto.secret.txt"
zabbix_agent_tlspskidentity_file: "{{ zabbix_win_install_dir }}\\tls_psk_auto.identity.txt" zabbix_agent_tlspskidentity_file: "{{ zabbix_win_install_dir }}\\tls_psk_auto.identity.txt"
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK file (Windows) - name: AutoPSK | Check for existing TLS PSK file (Windows)
ansible.windows.win_stat: ansible.windows.win_stat:
path: "{{ zabbix_agent_tlspskfile }}" path: "{{ zabbix_agent_tlspskfile }}"
register: zabbix_agent_tlspskcheck register: zabbix_agent_tlspskcheck
tags: tags:
- config - config
- name: AutoPSK | Check for existing TLS PSK identity (Windows) - name: AutoPSK | Check for existing TLS PSK identity (Windows)
ansible.windows.win_stat: ansible.windows.win_stat:
path: "{{ zabbix_agent_tlspskidentity_file }}" path: "{{ zabbix_agent_tlspskidentity_file }}"
register: zabbix_agent_tlspskidentity_check register: zabbix_agent_tlspskidentity_check
tags: tags:
- config - config
- name: AutoPSK | read existing TLS PSK file (Windows) - name: AutoPSK | read existing TLS PSK file (Windows)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent_tlspskfile }}" src: "{{ zabbix_agent_tlspskfile }}"
register: zabbix_agent_tlspsk_base64 register: zabbix_agent_tlspsk_base64
when: when:
- zabbix_agent_tlspskcheck.stat.exists - zabbix_agent_tlspskcheck.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- name: AutoPSK | Read existing TLS PSK identity file (Windows) - name: AutoPSK | Read existing TLS PSK identity file (Windows)
ansible.builtin.slurp: ansible.builtin.slurp:
src: "{{ zabbix_agent_tlspskidentity_file }}" src: "{{ zabbix_agent_tlspskidentity_file }}"
register: zabbix_agent_tlspskidentity_base64 register: zabbix_agent_tlspskidentity_base64
when: zabbix_agent_tlspskidentity_check.stat.exists when: zabbix_agent_tlspskidentity_check.stat.exists
no_log: "{{ ansible_verbosity < 3 }}" no_log: "{{ ansible_verbosity < 3 }}"
tags: tags:
- config - config
- include_tasks: tlspsk_auto_common.yml - include_tasks: tlspsk_auto_common.yml
- name: AutoPSK | Template TLS PSK identity in file (Windows) - name: AutoPSK | Template TLS PSK identity in file (Windows)
ansible.windows.win_copy: ansible.windows.win_copy:
dest: "{{ zabbix_agent_tlspskidentity_file }}" dest: "{{ zabbix_agent_tlspskidentity_file }}"
content: "{{ zabbix_agent_tlspskidentity }}" content: "{{ zabbix_agent_tlspskidentity }}"
when: when:
- zabbix_agent_tlspskidentity_file is defined - zabbix_agent_tlspskidentity_file is defined
- zabbix_agent_tlspskidentity is defined - zabbix_agent_tlspskidentity is defined
notify: notify:
- restart win zabbix agent - restart win zabbix agent
tags: tags:
- config - config
- name: AutoPSK | Template TLS PSK secret in file (Windows) - name: AutoPSK | Template TLS PSK secret in file (Windows)
ansible.windows.win_copy: ansible.windows.win_copy:
dest: "{{ zabbix_agent_tlspskfile }}" dest: "{{ zabbix_agent_tlspskfile }}"
content: "{{ zabbix_agent_tlspsk_secret }}" content: "{{ zabbix_agent_tlspsk_secret }}"
when: when:
- zabbix_agent_tlspskfile is defined - zabbix_agent_tlspskfile is defined
- zabbix_agent_tlspsk_secret is defined - zabbix_agent_tlspsk_secret is defined
- ansible_os_family == "Windows" - ansible_os_family == "Windows"
notify: notify:
- restart win zabbix agent - restart win zabbix agent
tags: tags:
- config - config

View File

@@ -1,87 +1,87 @@
--- ---
- block: - block:
- name: "Windows | Installing user-defined userparameters" - name: "Windows | Installing user-defined userparameters"
ansible.windows.win_template: ansible.windows.win_template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: '{{ zabbix_agent_win_include }}\{{ item.name }}.conf' dest: '{{ zabbix_agent_win_include }}\{{ item.name }}.conf'
notify: notify:
- restart win zabbix agent - restart win zabbix agent
with_items: "{{ zabbix_agent_userparameters }}" with_items: "{{ zabbix_agent_userparameters }}"
- name: "Windows | Installing user-defined scripts" - name: "Windows | Installing user-defined scripts"
ansible.windows.win_copy: ansible.windows.win_copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: '{{ zabbix_win_install_dir }}\scripts\' dest: '{{ zabbix_win_install_dir }}\scripts\'
notify: notify:
- restart win zabbix agent - restart win zabbix agent
with_items: "{{ zabbix_agent_userparameters }}" with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is defined when: item.scripts_dir is defined
when: ansible_os_family == "Windows" when: ansible_os_family == "Windows"
tags: tags:
- config - config
- block: - block:
- name: "Installing user-defined userparameters" - name: "Installing user-defined userparameters"
ansible.builtin.template: ansible.builtin.template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: "{{ zabbix_agent_include }}/userparameter_{{ item.name }}.conf" dest: "{{ zabbix_agent_include }}/userparameter_{{ item.name }}.conf"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0644 mode: 0644
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
become: true become: true
with_items: "{{ zabbix_agent_userparameters }}" with_items: "{{ zabbix_agent_userparameters }}"
- name: "Installing user-defined scripts" - name: "Installing user-defined scripts"
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: "/etc/zabbix/scripts/" dest: "/etc/zabbix/scripts/"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0755 mode: 0755
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
become: true become: true
with_items: "{{ zabbix_agent_userparameters }}" with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is defined when: item.scripts_dir is defined
when: when:
- ansible_os_family != "Windows" - ansible_os_family != "Windows"
- not zabbix_agent2 - not zabbix_agent2
tags: tags:
- config - config
- block: - block:
- name: "Installing user-defined userparameters" - name: "Installing user-defined userparameters"
ansible.builtin.template: ansible.builtin.template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2" src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: "{{ zabbix_agent2_include }}/userparameter_{{ item.name }}.conf" dest: "{{ zabbix_agent2_include }}/userparameter_{{ item.name }}.conf"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0644 mode: 0644
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
become: true become: true
with_items: "{{ zabbix_agent_userparameters }}" with_items: "{{ zabbix_agent_userparameters }}"
- name: "Installing user-defined scripts" - name: "Installing user-defined scripts"
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}" src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: "/etc/zabbix/scripts/" dest: "/etc/zabbix/scripts/"
owner: zabbix owner: zabbix
group: zabbix group: zabbix
mode: 0755 mode: 0755
notify: notify:
- restart zabbix-agent - restart zabbix-agent
- restart mac zabbix agent - restart mac zabbix agent
become: true become: true
with_items: "{{ zabbix_agent_userparameters }}" with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is defined when: item.scripts_dir is defined
when: when:
- ansible_os_family != "Windows" - ansible_os_family != "Windows"
- zabbix_agent2 - zabbix_agent2
tags: tags:
- config - config

View File

@@ -1,3 +1,3 @@
# This is an sample userparameters file. # This is an sample userparameters file.
UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive

View File

@@ -1 +1 @@
UserParameter=do.something, powershell -NoProfile -ExecutionPolicy Bypass -File {{ zabbix_win_install_dir }}\scripts\{{ item.name }}\doSomething.ps1 UserParameter=do.something, powershell -NoProfile -ExecutionPolicy Bypass -File {{ zabbix_win_install_dir }}\scripts\{{ item.name }}\doSomething.ps1

View File

@@ -1,140 +1,140 @@
{{ ansible_managed | comment }} {{ ansible_managed | comment }}
# This is a configuration file for Zabbix Agent 2 # This is a configuration file for Zabbix Agent 2
# To get more information about Zabbix, visit http://www.zabbix.com # To get more information about Zabbix, visit http://www.zabbix.com
# This configuration file is "minimalized", which means all the original comments # This configuration file is "minimalized", which means all the original comments
# are removed. The full documentation for your Zabbix Agent 2 can be found here: # are removed. The full documentation for your Zabbix Agent 2 can be found here:
# https://www.zabbix.com/documentation/{{ zabbix_agent_version }}/en/manual/appendix/config/zabbix_agent2{{ "_win" if ansible_os_family == "Windows" else "" }} # https://www.zabbix.com/documentation/{{ zabbix_agent_version }}/en/manual/appendix/config/zabbix_agent2{{ "_win" if ansible_os_family == "Windows" else "" }}
{% if ansible_os_family != "Windows" %} {% if ansible_os_family != "Windows" %}
PidFile={{ zabbix_agent2_pidfile }} PidFile={{ zabbix_agent2_pidfile }}
{% endif %} {% endif %}
LogType={{ zabbix_agent2_logtype }} LogType={{ zabbix_agent2_logtype }}
{% if ansible_os_family == "Windows" %} {% if ansible_os_family == "Windows" %}
LogFile={{ zabbix_agent2_win_logfile }} LogFile={{ zabbix_agent2_win_logfile }}
{% else %} {% else %}
LogFile={{ zabbix_agent2_logfile }} LogFile={{ zabbix_agent2_logfile }}
{% endif %} {% endif %}
LogFileSize={{ zabbix_agent2_logfilesize }} LogFileSize={{ zabbix_agent2_logfilesize }}
DebugLevel={{ zabbix_agent2_debuglevel }} DebugLevel={{ zabbix_agent2_debuglevel }}
{% if zabbix_agent2_sourceip is defined and zabbix_agent2_sourceip %} {% if zabbix_agent2_sourceip is defined and zabbix_agent2_sourceip %}
SourceIP={{ zabbix_agent2_sourceip }} SourceIP={{ zabbix_agent2_sourceip }}
{% endif %} {% endif %}
Server={{ zabbix_agent2_server }} Server={{ zabbix_agent2_server }}
ListenPort={{ zabbix_agent2_listenport }} ListenPort={{ zabbix_agent2_listenport }}
{% if zabbix_agent2_listenip is defined and zabbix_agent2_listenip !='0.0.0.0' and zabbix_agent2_listenip %} {% if zabbix_agent2_listenip is defined and zabbix_agent2_listenip !='0.0.0.0' and zabbix_agent2_listenip %}
ListenIP={{ zabbix_agent2_listenip }} ListenIP={{ zabbix_agent2_listenip }}
{% endif %} {% endif %}
{% if zabbix_agent2_statusport is defined and zabbix_agent2_statusport %} {% if zabbix_agent2_statusport is defined and zabbix_agent2_statusport %}
StatusPort={{ zabbix_agent2_statusport }} StatusPort={{ zabbix_agent2_statusport }}
{% endif %} {% endif %}
ServerActive={{ zabbix_agent2_serveractive }} ServerActive={{ zabbix_agent2_serveractive }}
{% if zabbix_agent2_hostname is defined and zabbix_agent2_hostname %} {% if zabbix_agent2_hostname is defined and zabbix_agent2_hostname %}
Hostname={{ zabbix_agent2_hostname }} Hostname={{ zabbix_agent2_hostname }}
{% endif %} {% endif %}
{% if zabbix_agent2_hostnameitem is defined and zabbix_agent2_hostnameitem %} {% if zabbix_agent2_hostnameitem is defined and zabbix_agent2_hostnameitem %}
HostnameItem={{ zabbix_agent2_hostnameitem }} HostnameItem={{ zabbix_agent2_hostnameitem }}
{% endif %} {% endif %}
{% if zabbix_agent2_hostmetadata is defined and zabbix_agent2_hostmetadata %} {% if zabbix_agent2_hostmetadata is defined and zabbix_agent2_hostmetadata %}
HostMetadata={{ zabbix_agent2_hostmetadata }} HostMetadata={{ zabbix_agent2_hostmetadata }}
{% endif %} {% endif %}
{% if zabbix_agent2_hostmetadataitem is defined and zabbix_agent2_hostmetadataitem %} {% if zabbix_agent2_hostmetadataitem is defined and zabbix_agent2_hostmetadataitem %}
HostMetadataItem={{ zabbix_agent2_hostmetadataitem }} HostMetadataItem={{ zabbix_agent2_hostmetadataitem }}
{% endif %} {% endif %}
{% if zabbix_agent2_hostinterface is defined and zabbix_agent2_hostinterface %} {% if zabbix_agent2_hostinterface is defined and zabbix_agent2_hostinterface %}
HostInterface={{ zabbix_agent2_hostinterface }} HostInterface={{ zabbix_agent2_hostinterface }}
{% endif %} {% endif %}
{% if zabbix_agent2_hostinterfaceitem is defined and zabbix_agent2_hostinterfaceitem %} {% if zabbix_agent2_hostinterfaceitem is defined and zabbix_agent2_hostinterfaceitem %}
HostInterfaceItem={{ zabbix_agent2_hostinterfaceitem }} HostInterfaceItem={{ zabbix_agent2_hostinterfaceitem }}
{% endif %} {% endif %}
{% if zabbix_agent2_allow_key is defined and zabbix_agent2_allow_key %} {% if zabbix_agent2_allow_key is defined and zabbix_agent2_allow_key %}
{% for item in zabbix_agent2_allow_key %} {% for item in zabbix_agent2_allow_key %}
AllowKey={{ item }} AllowKey={{ item }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if zabbix_agent2_deny_key is defined and zabbix_agent2_deny_key %} {% if zabbix_agent2_deny_key is defined and zabbix_agent2_deny_key %}
{% for item in zabbix_agent2_deny_key %} {% for item in zabbix_agent2_deny_key %}
DenyKey={{ item }} DenyKey={{ item }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
RefreshActiveChecks={{ zabbix_agent2_refreshactivechecks }} RefreshActiveChecks={{ zabbix_agent2_refreshactivechecks }}
BufferSend={{ zabbix_agent2_buffersend }} BufferSend={{ zabbix_agent2_buffersend }}
BufferSize={{ zabbix_agent2_buffersize }} BufferSize={{ zabbix_agent2_buffersize }}
{% if zabbix_agent2_enablepersistentbuffer is defined and zabbix_agent2_enablepersistentbuffer %} {% if zabbix_agent2_enablepersistentbuffer is defined and zabbix_agent2_enablepersistentbuffer %}
EnablePersistentBuffer={{ zabbix_agent2_enablepersistentbuffer }} EnablePersistentBuffer={{ zabbix_agent2_enablepersistentbuffer }}
{% endif %} {% endif %}
{% if zabbix_agent2_persistentbufferperiod is defined and zabbix_agent2_persistentbufferperiod %} {% if zabbix_agent2_persistentbufferperiod is defined and zabbix_agent2_persistentbufferperiod %}
PersistentBufferPeriod={{ zabbix_agent2_persistentbufferperiod }} PersistentBufferPeriod={{ zabbix_agent2_persistentbufferperiod }}
{% endif %} {% endif %}
{% if zabbix_agent2_persistentbufferfile is defined and zabbix_agent2_persistentbufferfile %} {% if zabbix_agent2_persistentbufferfile is defined and zabbix_agent2_persistentbufferfile %}
PersistentBufferFile={{ zabbix_agent2_persistentbufferfile }} PersistentBufferFile={{ zabbix_agent2_persistentbufferfile }}
{% endif %} {% endif %}
{% if zabbix_agent2_zabbix_alias is defined and zabbix_agent2_zabbix_alias %} {% if zabbix_agent2_zabbix_alias is defined and zabbix_agent2_zabbix_alias %}
{% if zabbix_agent2_zabbix_alias is string %} {% if zabbix_agent2_zabbix_alias is string %}
Alias={{ zabbix_agent2_zabbix_alias }} Alias={{ zabbix_agent2_zabbix_alias }}
{% else %} {% else %}
{% for item in zabbix_agent2_zabbix_alias %} {% for item in zabbix_agent2_zabbix_alias %}
Alias={{ item }} Alias={{ item }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %} {% endif %}
Timeout={{ zabbix_agent2_timeout }} Timeout={{ zabbix_agent2_timeout }}
{% if ansible_os_family == "Windows" %} {% if ansible_os_family == "Windows" %}
Include={{ zabbix_agent_win_include }} Include={{ zabbix_agent_win_include }}
{% else %} {% else %}
Include={{ zabbix_agent2_include }}/{{ zabbix_agent2_include_pattern }} Include={{ zabbix_agent2_include }}/{{ zabbix_agent2_include_pattern }}
{% endif %} {% endif %}
{% if zabbix_agent2_additional_include is defined and zabbix_agent2_additional_include is iterable and zabbix_agent2_additional_include is not string %} {% if zabbix_agent2_additional_include is defined and zabbix_agent2_additional_include is iterable and zabbix_agent2_additional_include is not string %}
{% for include in zabbix_agent2_additional_include %} {% for include in zabbix_agent2_additional_include %}
Include={{ include }} Include={{ include }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
UnsafeUserParameters={{ zabbix_agent2_unsafeuserparameters }} UnsafeUserParameters={{ zabbix_agent2_unsafeuserparameters }}
{% if ansible_os_family != "Windows" %} {% if ansible_os_family != "Windows" %}
ControlSocket={{ zabbix_agent2_controlsocket }} ControlSocket={{ zabbix_agent2_controlsocket }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlsconnect is defined and zabbix_agent2_tlsconnect %} {% if zabbix_agent2_tlsconnect is defined and zabbix_agent2_tlsconnect %}
TLSConnect={{ zabbix_agent2_tlsconnect }} TLSConnect={{ zabbix_agent2_tlsconnect }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlsaccept is defined and zabbix_agent2_tlsaccept %} {% if zabbix_agent2_tlsaccept is defined and zabbix_agent2_tlsaccept %}
TLSAccept={{ zabbix_agent2_tlsaccept }} TLSAccept={{ zabbix_agent2_tlsaccept }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlscafile is defined and zabbix_agent2_tlscafile %} {% if zabbix_agent2_tlscafile is defined and zabbix_agent2_tlscafile %}
TLSCAFile={{ zabbix_agent2_tlscafile }} TLSCAFile={{ zabbix_agent2_tlscafile }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlscrlfile is defined and zabbix_agent2_tlscrlfile %} {% if zabbix_agent2_tlscrlfile is defined and zabbix_agent2_tlscrlfile %}
TLSCRLFile={{ zabbix_agent2_tlscrlfile }} TLSCRLFile={{ zabbix_agent2_tlscrlfile }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlsservercertissuer is defined and zabbix_agent2_tlsservercertissuer %} {% if zabbix_agent2_tlsservercertissuer is defined and zabbix_agent2_tlsservercertissuer %}
TLSServerCertIssuer={{ zabbix_agent2_tlsservercertissuer }} TLSServerCertIssuer={{ zabbix_agent2_tlsservercertissuer }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlsservercertsubject is defined and zabbix_agent2_tlsservercertsubject %} {% if zabbix_agent2_tlsservercertsubject is defined and zabbix_agent2_tlsservercertsubject %}
TLSServerCertSubject={{ zabbix_agent2_tlsservercertsubject }} TLSServerCertSubject={{ zabbix_agent2_tlsservercertsubject }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlscertfile is defined and zabbix_agent2_tlscertfile %} {% if zabbix_agent2_tlscertfile is defined and zabbix_agent2_tlscertfile %}
TLSCertFile={{ zabbix_agent2_tlscertfile }} TLSCertFile={{ zabbix_agent2_tlscertfile }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlskeyfile is defined and zabbix_agent2_tlskeyfile %} {% if zabbix_agent2_tlskeyfile is defined and zabbix_agent2_tlskeyfile %}
TLSKeyFile={{ zabbix_agent2_tlskeyfile }} TLSKeyFile={{ zabbix_agent2_tlskeyfile }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlspskidentity is defined and zabbix_agent2_tlspskidentity %} {% if zabbix_agent2_tlspskidentity is defined and zabbix_agent2_tlspskidentity %}
TLSPSKIdentity={{ zabbix_agent2_tlspskidentity }} TLSPSKIdentity={{ zabbix_agent2_tlspskidentity }}
{% endif %} {% endif %}
{% if zabbix_agent2_tlspskfile is defined and zabbix_agent2_tlspskfile %} {% if zabbix_agent2_tlspskfile is defined and zabbix_agent2_tlspskfile %}
TLSPSKFile={{ zabbix_agent2_tlspskfile }} TLSPSKFile={{ zabbix_agent2_tlspskfile }}
{% endif %} {% endif %}
{% if zabbix_agent2_plugins is defined and zabbix_agent2_plugins is iterable %} {% if zabbix_agent2_plugins is defined and zabbix_agent2_plugins is iterable %}
{% for entry in zabbix_agent2_plugins %} {% for entry in zabbix_agent2_plugins %}
{% set my_name = entry['name'] %} {% set my_name = entry['name'] %}
{% for property in entry['options'] %} {% for property in entry['options'] %}
{% set param = property['parameter'] %} {% set param = property['parameter'] %}
{% set value = property['value'] %} {% set value = property['value'] %}
Plugins.{{ my_name }}.{{ param }}={{ value }} Plugins.{{ my_name }}.{{ param }}={{ value }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if zabbix_agent_version is version('6.0', '>=') %} {% if zabbix_agent_version is version('6.0', '>=') %}
{% if zabbix_agent2_listenbacklog is defined and zabbix_agent2_listenbacklog %} {% if zabbix_agent2_listenbacklog is defined and zabbix_agent2_listenbacklog %}
ListenBacklog={{ zabbix_agent2_listenbacklog }} ListenBacklog={{ zabbix_agent2_listenbacklog }}
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@@ -1,149 +1,149 @@
{{ ansible_managed | comment }} {{ ansible_managed | comment }}
# This is a configuration file for Zabbix Agent # This is a configuration file for Zabbix Agent
# To get more information about Zabbix, visit http://www.zabbix.com # To get more information about Zabbix, visit http://www.zabbix.com
# This configuration file is "minimalized", which means all the original comments # This configuration file is "minimalized", which means all the original comments
# are removed. The full documentation for your Zabbix Agent can be found here: # are removed. The full documentation for your Zabbix Agent can be found here:
# https://www.zabbix.com/documentation/{{ zabbix_agent_version }}/en/manual/appendix/config/zabbix_agentd{{ "_win" if ansible_os_family == "Windows" else "" }} # https://www.zabbix.com/documentation/{{ zabbix_agent_version }}/en/manual/appendix/config/zabbix_agentd{{ "_win" if ansible_os_family == "Windows" else "" }}
{% if ansible_os_family != "Windows" %} {% if ansible_os_family != "Windows" %}
PidFile={{ zabbix_agent_pidfile }} PidFile={{ zabbix_agent_pidfile }}
{% endif %} {% endif %}
{% if zabbix_agent_version is version('3.0', '>=') %} {% if zabbix_agent_version is version('3.0', '>=') %}
LogType={{ zabbix_agent_logtype }} LogType={{ zabbix_agent_logtype }}
{% endif %} {% endif %}
{% if ansible_os_family == "Windows" %} {% if ansible_os_family == "Windows" %}
LogFile={{ zabbix_agent_win_logfile }} LogFile={{ zabbix_agent_win_logfile }}
{% else %} {% else %}
LogFile={{ zabbix_agent_logfile }} LogFile={{ zabbix_agent_logfile }}
{% endif %} {% endif %}
LogFileSize={{ zabbix_agent_logfilesize }} LogFileSize={{ zabbix_agent_logfilesize }}
DebugLevel={{ zabbix_agent_debuglevel }} DebugLevel={{ zabbix_agent_debuglevel }}
{% if zabbix_agent_sourceip is defined and zabbix_agent_sourceip %} {% if zabbix_agent_sourceip is defined and zabbix_agent_sourceip %}
SourceIP={{ zabbix_agent_sourceip }} SourceIP={{ zabbix_agent_sourceip }}
{% endif %} {% endif %}
{% if zabbix_agent_version is version('6.0', '<=') %} {% if zabbix_agent_version is version('6.0', '<=') %}
EnableRemoteCommands={{ zabbix_agent_enableremotecommands }} EnableRemoteCommands={{ zabbix_agent_enableremotecommands }}
{% else %} {% else %}
{% if zabbix_agent_allowkeys is defined and zabbix_agent_allowkeys %} {% if zabbix_agent_allowkeys is defined and zabbix_agent_allowkeys %}
AllowKey={{ zabbix_agent_allowkeys }} AllowKey={{ zabbix_agent_allowkeys }}
{% endif %} {% endif %}
{% if zabbix_agent_denykeys is defined and zabbix_agent_denykeys %} {% if zabbix_agent_denykeys is defined and zabbix_agent_denykeys %}
DenyKey={{ zabbix_agent_denykeys }} DenyKey={{ zabbix_agent_denykeys }}
{% endif %} {% endif %}
{% endif %} {% endif %}
LogRemoteCommands={{ zabbix_agent_logremotecommands }} LogRemoteCommands={{ zabbix_agent_logremotecommands }}
Server={{ zabbix_agent_server }} Server={{ zabbix_agent_server }}
ListenPort={{ zabbix_agent_listenport }} ListenPort={{ zabbix_agent_listenport }}
{% if zabbix_agent_listenip is defined and zabbix_agent_listenip !='0.0.0.0' and zabbix_agent_listenip %} {% if zabbix_agent_listenip is defined and zabbix_agent_listenip !='0.0.0.0' and zabbix_agent_listenip %}
ListenIP={{ zabbix_agent_listenip }} ListenIP={{ zabbix_agent_listenip }}
{% endif %} {% endif %}
StartAgents={{ zabbix_agent_startagents }} StartAgents={{ zabbix_agent_startagents }}
ServerActive={{ zabbix_agent_serveractive }} ServerActive={{ zabbix_agent_serveractive }}
{% if zabbix_agent_hostname is defined and zabbix_agent_hostname %} {% if zabbix_agent_hostname is defined and zabbix_agent_hostname %}
Hostname={{ zabbix_agent_hostname }} Hostname={{ zabbix_agent_hostname }}
{% endif %} {% endif %}
{% if zabbix_agent_hostnameitem is defined and zabbix_agent_hostnameitem %} {% if zabbix_agent_hostnameitem is defined and zabbix_agent_hostnameitem %}
HostnameItem={{ zabbix_agent_hostnameitem }} HostnameItem={{ zabbix_agent_hostnameitem }}
{% endif %} {% endif %}
{% if zabbix_agent_hostmetadata is defined and zabbix_agent_hostmetadata %} {% if zabbix_agent_hostmetadata is defined and zabbix_agent_hostmetadata %}
HostMetadata={{ zabbix_agent_hostmetadata }} HostMetadata={{ zabbix_agent_hostmetadata }}
{% endif %} {% endif %}
{% if zabbix_agent_hostmetadataitem is defined and zabbix_agent_hostmetadataitem %} {% if zabbix_agent_hostmetadataitem is defined and zabbix_agent_hostmetadataitem %}
HostMetadataItem={{ zabbix_agent_hostmetadataitem }} HostMetadataItem={{ zabbix_agent_hostmetadataitem }}
{% endif %} {% endif %}
{% if zabbix_agent_allow_key is defined and zabbix_agent_allow_key %} {% if zabbix_agent_allow_key is defined and zabbix_agent_allow_key %}
{% for item in zabbix_agent_allow_key %} {% for item in zabbix_agent_allow_key %}
AllowKey={{ item }} AllowKey={{ item }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if zabbix_agent_deny_key is defined and zabbix_agent_deny_key %} {% if zabbix_agent_deny_key is defined and zabbix_agent_deny_key %}
{% for item in zabbix_agent_deny_key %} {% for item in zabbix_agent_deny_key %}
DenyKey={{ item }} DenyKey={{ item }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
RefreshActiveChecks={{ zabbix_agent_refreshactivechecks }} RefreshActiveChecks={{ zabbix_agent_refreshactivechecks }}
BufferSend={{ zabbix_agent_buffersend }} BufferSend={{ zabbix_agent_buffersend }}
BufferSize={{ zabbix_agent_buffersize }} BufferSize={{ zabbix_agent_buffersize }}
MaxLinesPerSecond={{ zabbix_agent_maxlinespersecond }} MaxLinesPerSecond={{ zabbix_agent_maxlinespersecond }}
{% if zabbix_agent_version is version_compare('6.2', '>=') %} {% if zabbix_agent_version is version_compare('6.2', '>=') %}
HeartbeatFrequency={{ zabbix_agent_heartbeatfrequency }} HeartbeatFrequency={{ zabbix_agent_heartbeatfrequency }}
{% endif %} {% endif %}
{% if zabbix_agent_zabbix_alias is defined and zabbix_agent_zabbix_alias %} {% if zabbix_agent_zabbix_alias is defined and zabbix_agent_zabbix_alias %}
{% if zabbix_agent_zabbix_alias is string %} {% if zabbix_agent_zabbix_alias is string %}
Alias={{ zabbix_agent_zabbix_alias }} Alias={{ zabbix_agent_zabbix_alias }}
{% else %} {% else %}
{% for item in zabbix_agent_zabbix_alias %} {% for item in zabbix_agent_zabbix_alias %}
Alias={{ item }} Alias={{ item }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %} {% endif %}
Timeout={{ zabbix_agent_timeout }} Timeout={{ zabbix_agent_timeout }}
{% if ansible_os_family != "Windows" %} {% if ansible_os_family != "Windows" %}
AllowRoot={{ zabbix_agent_allowroot }} AllowRoot={{ zabbix_agent_allowroot }}
{% endif %} {% endif %}
{% if zabbix_agent_runas_user is defined and zabbix_agent_runas_user %} {% if zabbix_agent_runas_user is defined and zabbix_agent_runas_user %}
User={{ zabbix_agent_runas_user }} User={{ zabbix_agent_runas_user }}
{% endif %} {% endif %}
{% if ansible_os_family == "Windows" %} {% if ansible_os_family == "Windows" %}
Include={{ zabbix_agent_win_include }} Include={{ zabbix_agent_win_include }}
{% else %} {% else %}
Include={{ zabbix_agent_include }}/{{ zabbix_agent_include_pattern }} Include={{ zabbix_agent_include }}/{{ zabbix_agent_include_pattern }}
{% endif %} {% endif %}
{% if zabbix_agent_additional_include is defined and zabbix_agent_additional_include is iterable and zabbix_agent_additional_include is not string %} {% if zabbix_agent_additional_include is defined and zabbix_agent_additional_include is iterable and zabbix_agent_additional_include is not string %}
{% for include in zabbix_agent_additional_include %} {% for include in zabbix_agent_additional_include %}
Include={{ include }} Include={{ include }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
UnsafeUserParameters={{ zabbix_agent_unsafeuserparameters }} UnsafeUserParameters={{ zabbix_agent_unsafeuserparameters }}
{% if zabbix_agent_version is version_compare('2.2', '>=') %} {% if zabbix_agent_version is version_compare('2.2', '>=') %}
{% if ansible_os_family != "Windows" %} {% if ansible_os_family != "Windows" %}
LoadModulePath={{ zabbix_agent_loadmodulepath }} LoadModulePath={{ zabbix_agent_loadmodulepath }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if zabbix_agent_loadmodule is defined and zabbix_agent_loadmodule %} {% if zabbix_agent_loadmodule is defined and zabbix_agent_loadmodule %}
{% if zabbix_agent_loadmodule is string %} {% if zabbix_agent_loadmodule is string %}
LoadModule={{ zabbix_agent_loadmodule }} LoadModule={{ zabbix_agent_loadmodule }}
{% else %} {% else %}
{% for module in zabbix_agent_loadmodule %} {% for module in zabbix_agent_loadmodule %}
LoadModule={{ module }} LoadModule={{ module }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if zabbix_agent_version is version_compare('3.0', '>=') %} {% if zabbix_agent_version is version_compare('3.0', '>=') %}
{% if zabbix_agent_tlsconnect is defined and zabbix_agent_tlsconnect %} {% if zabbix_agent_tlsconnect is defined and zabbix_agent_tlsconnect %}
TLSConnect={{ zabbix_agent_tlsconnect }} TLSConnect={{ zabbix_agent_tlsconnect }}
{% endif %} {% endif %}
{% if zabbix_agent_tlsaccept is defined and zabbix_agent_tlsaccept %} {% if zabbix_agent_tlsaccept is defined and zabbix_agent_tlsaccept %}
TLSAccept={{ zabbix_agent_tlsaccept }} TLSAccept={{ zabbix_agent_tlsaccept }}
{% endif %} {% endif %}
{% if zabbix_agent_tlscafile is defined and zabbix_agent_tlscafile %} {% if zabbix_agent_tlscafile is defined and zabbix_agent_tlscafile %}
TLSCAFile={{ zabbix_agent_tlscafile }} TLSCAFile={{ zabbix_agent_tlscafile }}
{% endif %} {% endif %}
{% if zabbix_agent_tlscrlfile is defined and zabbix_agent_tlscrlfile %} {% if zabbix_agent_tlscrlfile is defined and zabbix_agent_tlscrlfile %}
TLSCRLFile={{ zabbix_agent_tlscrlfile }} TLSCRLFile={{ zabbix_agent_tlscrlfile }}
{% endif %} {% endif %}
{% if zabbix_agent_tlsservercertissuer is defined and zabbix_agent_tlsservercertissuer %} {% if zabbix_agent_tlsservercertissuer is defined and zabbix_agent_tlsservercertissuer %}
TLSServerCertIssuer={{ zabbix_agent_tlsservercertissuer }} TLSServerCertIssuer={{ zabbix_agent_tlsservercertissuer }}
{% endif %} {% endif %}
{% if zabbix_agent_tlsservercertsubject is defined and zabbix_agent_tlsservercertsubject %} {% if zabbix_agent_tlsservercertsubject is defined and zabbix_agent_tlsservercertsubject %}
TLSServerCertSubject={{ zabbix_agent_tlsservercertsubject }} TLSServerCertSubject={{ zabbix_agent_tlsservercertsubject }}
{% endif %} {% endif %}
{% if zabbix_agent_tlscertfile is defined and zabbix_agent_tlscertfile %} {% if zabbix_agent_tlscertfile is defined and zabbix_agent_tlscertfile %}
TLSCertFile={{ zabbix_agent_tlscertfile }} TLSCertFile={{ zabbix_agent_tlscertfile }}
{% endif %} {% endif %}
{% if zabbix_agent_tlskeyfile is defined and zabbix_agent_tlskeyfile %} {% if zabbix_agent_tlskeyfile is defined and zabbix_agent_tlskeyfile %}
TLSKeyFile={{ zabbix_agent_tlskeyfile }} TLSKeyFile={{ zabbix_agent_tlskeyfile }}
{% endif %} {% endif %}
{% if zabbix_agent_tlspskidentity is defined and zabbix_agent_tlspskidentity %} {% if zabbix_agent_tlspskidentity is defined and zabbix_agent_tlspskidentity %}
TLSPSKIdentity={{ zabbix_agent_tlspskidentity }} TLSPSKIdentity={{ zabbix_agent_tlspskidentity }}
{% endif %} {% endif %}
{% if zabbix_agent_tlspskfile is defined and zabbix_agent_tlspskfile %} {% if zabbix_agent_tlspskfile is defined and zabbix_agent_tlspskfile %}
TLSPSKFile={{ zabbix_agent_tlspskfile }} TLSPSKFile={{ zabbix_agent_tlspskfile }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if zabbix_agent_version is version('6.0', '>=') %} {% if zabbix_agent_version is version('6.0', '>=') %}
{% if zabbix_agent_listenbacklog is defined and zabbix_agent_listenbacklog %} {% if zabbix_agent_listenbacklog is defined and zabbix_agent_listenbacklog %}
ListenBacklog={{ zabbix_agent_listenbacklog }} ListenBacklog={{ zabbix_agent_listenbacklog }}
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@@ -1,48 +1,48 @@
--- ---
# vars file for zabbix_agent (Debian) # vars file for zabbix_agent (Debian)
zabbix_agent: zabbix-agent zabbix_agent: zabbix-agent
zabbix_agent_service: zabbix-agent zabbix_agent_service: zabbix-agent
zabbix_agent_conf: zabbix_agentd.conf zabbix_agent_conf: zabbix_agentd.conf
zabbix_agent2_conf: zabbix_agent2.conf zabbix_agent2_conf: zabbix_agent2.conf
zabbix_valid_agent_versions: zabbix_valid_agent_versions:
# Debian # Debian
"12": "12":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"11": "11":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"10": "10":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"9": "9":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
# Ubuntu # Ubuntu
"22": "22":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"20": "20":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"18": "18":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
debian_keyring_path: /etc/apt/keyrings/ debian_keyring_path: /etc/apt/keyrings/
zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc" zabbix_gpg_key: "{{ debian_keyring_path }}/zabbix-official-repo.asc"
_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}" _zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}"

View File

@@ -1,21 +1,21 @@
--- ---
# vars file for zabbix_agent (RedHat) # vars file for zabbix_agent (RedHat)
zabbix_agent: zabbix-agent zabbix_agent: zabbix-agent
zabbix_agent_service: zabbix-agent zabbix_agent_service: zabbix-agent
zabbix_agent_conf: zabbix_agentd.conf zabbix_agent_conf: zabbix_agentd.conf
zabbix_agent2_conf: zabbix_agent2.conf zabbix_agent2_conf: zabbix_agent2.conf
zabbix_valid_agent_versions: zabbix_valid_agent_versions:
"9": "9":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"8": "8":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0
"7": "7":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0

View File

@@ -1,7 +1,7 @@
--- ---
# vars file for zabbix_agent (Windows) # vars file for zabbix_agent (Windows)
zabbix_valid_agent_versions: zabbix_valid_agent_versions:
"10": "10":
- 6.4 - 6.4
- 6.2 - 6.2
- 6.0 - 6.0

View File

@@ -1,24 +1,24 @@
--- ---
- hosts: all - hosts: all
roles: roles:
- role: zabbix-agent - role: zabbix-agent
zabbix_api_server_host: 10.10.43.252 zabbix_api_server_host: 10.10.43.252
zabbix_api_server_port: 80 zabbix_api_server_port: 80
ansible_zabbix_url_path: "/" ansible_zabbix_url_path: "/"
zabbix_api_login_user: sa8001 zabbix_api_login_user: sa8001
zabbix_api_login_pass: ios2011a zabbix_api_login_pass: ios2011a
zabbix_api_create_hostgroup: false zabbix_api_create_hostgroup: false
zabbix_api_create_hosts: true zabbix_api_create_hosts: true
zabbix_agent_host_state: present zabbix_agent_host_state: present
zabbix_host_groups: zabbix_host_groups:
- Linux servers - Linux servers
- Virtual machines - Virtual machines
zabbix_agent_visible_hostname: "{{ ansible_fqdn }}" zabbix_agent_visible_hostname: "{{ ansible_fqdn }}"
zabbix_agent_server: 10.10.43.252 zabbix_agent_server: 10.10.43.252
zabbix_agent_serveractive: 10.10.43.252 zabbix_agent_serveractive: 10.10.43.252
zabbix_agent_link_templates: zabbix_agent_link_templates:
- Linux by Zabbix agent - Linux by Zabbix agent
zabbix_agent_version: 6.4 zabbix_agent_version: 6.4
zabbix_agent_unsafeuserparameters: 1 zabbix_agent_unsafeuserparameters: 1
zabbix_agent_userparameters: zabbix_agent_userparameters:
- name: zombie - name: zombie