Debian Codegraph @

ansible_collections/community/zabbix/roles/zabbix_agent/README.md

raw
1 # community.zabbix.zabbix_agent role
2
3 ![Zabbix Agent](https://github.com/ansible-collections/community.zabbix/workflows/community.zabbix.zabbix_agent/badge.svg)
4
5 **Table of Contents**
6
7 - [Requirements](#requirements)
8 * [Operating systems](#operating-systems)
9 + [Windows](#windows)
10 * [Local system access](#local-system-access)
11 * [Zabbix Versions](#zabbix-versions)
12 - [Getting started](#getting-started)
13 * [Minimal Configuration](#minimal-configuration)
14 * [Issues](#issues)
15 - [Role Variables](#role-variables)
16 * [Main variables](#main-variables)
17 + [Overall Zabbix](#overall-zabbix)
18 + [SElinux](#selinux)
19 + [Zabbix Agent](#zabbix-agent)
20 + [Zabbix Agent vs Zabbix Agent 2 configuration](#zabbix-agent-vs-zabbix-agent-2-configuration)
21 * [TLS Specific configuration](#tls-specific-configuration)
22 * [Zabbix API variables](#zabbix-api-variables)
23 * [Windows Variables](#windows-variables)
24 * [macOS Variables](#macos-variables)
25 * [Docker Variables](#docker-variables)
26 * [FirewallD/Iptables](#firewalld-iptables)
27 * [IPMI variables](#ipmi-variables)
28 * [proxy](#proxy)
29 - [Dependencies](#dependencies)
30 - [Example Playbook](#example-playbook)
31 * [agent_interfaces](#agent-interfaces)
32 * [Other interfaces](#other-interfaces)
33 * [Vars in role configuration](#vars-in-role-configuration)
34 * [Combination of group_vars and playbook](#combination-of-group-vars-and-playbook)
35 * [Example for TLS PSK encrypted agent communication](#example-for-tls-psk-encrypted-agent-communication)
36 - [Molecule](#molecule)
37 - [Deploying Userparameters](#deploying-userparameters)
38 - [License](#license)
39 - [Author Information](#author-information)
40
41 # Requirements
42 ## Operating systems
43 This role will work on the following operating systems:
44
45 * Red Hat
46 * Debian
47 * Ubuntu
48 * Windows (Best effort)
49 * macOS (Best effort)
50 * FreeBSD (Best effort)
51
52 ## Ansible 2.10 and higher
53
54 With the release of Ansible 2.10, modules have been moved into collections. With the exception of ansible.builtin modules, this means additonal collections must be installed in order to use modules such as seboolean (now ansible.posix.seboolean). The following collections are now required: `ansible.posix`and `community.general`. Installing the collections:
55
56 ```sh
57 ansible-galaxy collection install ansible.posix
58 ansible-galaxy collection install community.general
59 ```
60 If you are wanting to create host_groups and hosts in Zabbix via API as a part of this role execution then you need to install `ansible.netcommon` collection too:
61
62 ```
63 ansible-galaxy collection install ansible.netcommon
64 ```
65
66 ### Docker
67
68 When you are a Docker user and using Ansible 2.10 or newer, then there is a dependency on the collection named `community.docker`. This collection is needed as the `docker_` modules are now part of collections and not standard in Ansible anymmore. Installing the collection:
69
70 ```sh
71 ansible-galaxy collection install community.docker
72 ```
73
74 ### Windows
75
76 When you are a Windows user and using Ansible 2.10 or newer, then there are dependencies on collections named `ansible.windows` and `community.windows`. These collections are needed as the `win_` modules are now part of collections and not standard in Ansible anymmore. Installing the collections:
77
78 ```sh
79 ansible-galaxy collection install ansible.windows
80 ansible-galaxy collection install community.windows
81 ```
82
83 For more information, see: https://github.com/ansible-collections/community.zabbix/issues/236
84
85 ## Local system access
86
87 To successfully complete the install the role requires `python-netaddr` on the controller to be able to manage IP addresses. This requires that the library is available on your local machine (or that `pip` is installed to be able to run). This will likely mean that running the role will require `sudo` access to your local machine and therefore you may need the `-K` flag to be able to enter your local machine password if you are not running under root.
88
89 ## Zabbix Versions
90
91 See the following list of supported Operating systems with the Zabbix releases:
92
93 | Zabbix | 7.4 | 7.2 | 7.0 | 6.0 |
94 |---------------------|-----|-----|-----|-----|
95 | Red Hat Fam 9 | V | V | V | V |
96 | Red Hat Fam 8 | V | V | V | V |
97 | Ubuntu 24.04 noble | V | V | V | V |
98 | Ubuntu 22.04 jammy | V | V | V | V |
99 | Debian 12 bookworm | V | V | V | V |
100 | Debian 11 bullseye | V | V | V | V |
101 | Suse Fam 15 | V | V | V | V |
102 | FreeBSD 15 | V | V | V | V |
103 | FreeBSD 14 | V | V | V | V |
104 | FreeBSD 13 | V | V | V | V |
105
106 You can bypass this matrix by setting `zabbix_agent_version_check: false`
107
108 # Role Variables
109
110 ## Main variables
111
112 The following is an overview of all available configuration default for this role.
113
114 ### Overall Zabbix
115
116 * `zabbix_agent_version`: This is the version of zabbix. Default: The highest supported version for the operating system. Can be overridden to 6.4 or 6.0
117 * `zabbix_agent_version_minor`: When you want to specify a minor version to be installed. Is also used for `zabbix_sender` and `zabbix_get`. RedHat only. Default set to: `*` (latest available)
118 * `zabbix_repo_yum`: A list with Yum repository configuration.
119 * `zabbix_repo_yum_schema`: Default: `https`. Option to change the web schema for the yum repository (http/https)
120 * `zabbix_agent_disable_repo`: A list of repos to disable during install. Default `epel`.
121 * `zabbix_repo_deb_url`: The URL to the Zabbix repository. Default `http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}`
122 * `zabbix_repo_deb_component`: The repository component for Debian installs. Default `main`.
123 * `zabbix_repo_deb_gpg_key_url`: The URL to download the Zabbix GPG key from. Default http://repo.zabbix.com/zabbix-official-repo.key.
124 * `zabbix_repo_deb_include_deb_src`: True, if deb-src should be included in the zabbix.sources entry. Default `true`.
125 * `zabbix_manage_repo`: Have the collection install and configure the Zabbix repo. Default `true`.
126
127 ### SElinux
128
129 Selinux changes will be installed based on the status of selinux running on the target system.
130
131 * `selinux_allow_zabbix_run_sudo`: Default: `False`. Enable Zabbix root access on system.
132
133 ### Zabbix Agent
134
135 * `zabbix_agent2`: Default: `False`. When you want to install the `Zabbix Agent2` instead of the "old" `Zabbix Agent`.
136 * `zabbix_agent_chassis`: Default: `false`. When set to `true`, it will give Zabbix Agent access to the Linux DMI table allowing system.hw.chassis info to populate.
137 * `zabbix_agent_conf_mode`: Default: `0644`. The "mode" for the Zabbix configuration file.
138 * `zabbix_agent_detect_ip`: Default `true`. When set to `false`, it won't detect available ip addresses on the host and no need for the Python module `netaddr` to be installed.
139 * `zabbix_agent_get_package`: The name of the zabbix-get package. Default: `zabbix-get`.
140 * `zabbix_agent_include_mode`: The mode for the directory mentioned above.
141 * `zabbix_agent_install_agent_only`: Only install the Zabbix Agent and not the `zabbix-sender` and `zabbix-get` packages. Default: `False`
142 * `zabbix_agent_package_remove`: If `zabbix_agent2: True` and you want to remove the old installation. Default: `False`.
143 * `zabbix_agent_package_state`: If Zabbix-agent needs to be `present` (default) or `latest`.
144 * `zabbix_agent_package`: The name of the zabbix-agent package. Default: `zabbix-agent` if `zabbix_agent2` is false and `zabbix-agent2` if `true`.
145 * `zabbix_agent_sender_package`: The name of the zabbix-sender package. Default: `zabbix-sender`.
146 * `zabbix_agent_userparameters`: Default: `[]`. List of userparameter names and scripts (if any). Detailed description is given in the [Deploying Userparameters](#deploying-userparameters) section.
147 * `name`: Userparameter name (should be the same with userparameter template file name)
148 * `scripts_dir`: Directory name of the custom scripts needed for userparameters
149 * `zabbix_agent_userparameters_scripts_src`: indicates the relative path (from `files/`) where userparameter scripts are searched
150 * `zabbix_agent_userparameters_templates_src`: indicates the relative path (from `templates/`) where userparameter templates are searched
151 * `zabbix_agent_visible_hostname` : Configure Zabbix visible name inside Zabbix web UI for the node.
152
153 ## TLS Specific configuration
154 * `zabbix_agent_tlspsk_auto`: Enables auto generation and storing of individual pre-shared keys and identities on clients. Is false by default. If set to true and if `zabbix_agent_tlspskfile` and `zabbix_agent_tlspsk_secret` are undefined, it generates the files `/etc/zabbix/tls_psk_auto.identity` and `/etc/zabbix/tls_psk_auto.secret`, which are populated by values automatically (identity is set to hostname, underscore and 4 random alphanumeric digits; secret is 64 random alphanumeric digits) in such a way that the values are generated once and are never overwritten.
155
156 * `zabbix_agent_tlsconnect`: How the agent should connect to server or proxy. Used for active checks.
157 Possible values:
158 * unencrypted
159 * psk
160 * cert
161 * `zabbix_agent_tlsaccept`: What incoming connections to accept.
162 Possible values:
163 * unencrypted
164 * psk
165 * cert
166
167 * `zabbix_agent_tlscafile`: Full pathname of a file containing the top-level CA(s) certificates for peer certificate verification.
168 * `zabbix_agent_tlscertfile`: Full pathname of a file containing the agent certificate or certificate chain.
169 * `zabbix_agent_tlscrlfile`: Full pathname of a file containing revoked certificates.
170 * `zabbix_agent_tlskeyfile`: Full pathname of a file containing the agent private key.
171 * `zabbix_agent_tlspskfile`: Full pathname of a file containing the pre-shared key.
172 * `zabbix_agent_tlspskidentity`: Unique, case sensitive string used to identify the pre-shared key.
173 * `zabbix_agent_tlspskidentity_file`: Full pathname of a file containing the pre-shared key identity.
174 * `zabbix_agent_tlspsk_secret`: The pre-shared secret key for the agent.
175 * `zabbix_agent_tlsservercertissuer`: Allowed server certificate issuer.
176 * `zabbix_agent_tlsservercertsubject`: Allowed server certificate subject.
177 * `zabbix_agent_tls_subject`: The subject of the TLS certificate.
178
179 The results are stored in the Ansible variables `zabbix_agent_tlspskidentity` and `zabbix_agent_tlspsk_secret`, so that they may be used later in the code, for example with [zabbix_host](https://docs.ansible.com/projects/ansible/latest/collections/community/zabbix/zabbix_host_module.html) to configure the Zabbix server or with `debug: msg:` to display them to the user.
180
181 ## Zabbix API variables
182
183 These variables need to be overridden when you want to make use of the Zabbix API for automatically creating and or updating hosts.
184
185 Host encryption configuration will be set to match agent configuration.
186
187 * `zabbix_agent_description`: Description of the host in Zabbix.
188 * `zabbix_agent_host_state`: present (Default) if the host needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_hosts` is set to `True`.
189 * `zabbix_agent_host_update`: yes (Default) if the host should be updated if already present. This only works when `zabbix_api_create_hosts` is set to `True`.
190 * `zabbix_agent_interfaces`: A list of interfaces and their configurations you can use when configuring via API.
191 * `zabbix_agent_inventory_mode`: Configure Zabbix inventory mode. Needed for building inventory data, manually when configuring a host or automatically by using some automatic population options. This has to be set to `automatic` if you want to make automatically building inventory data. Default `disabled`
192 * `zabbix_agent_inventory_zabbix`: Adds Facts for a zabbix inventory. Default `{}`
193 * `zabbix_agent_ip`: The IP address of the host. When not provided, it will be determined via the `ansible_default_ipv4` fact, with a fallback to the first available IP address.
194 * `zabbix_agent_link_templates`: A list of templates which needs to be link to this host. The templates should exist. Default: "Templated Linux by Zabbix agent"
195 * `zabbix_agent_macros`: A list with macro_key and macro_value for creating hostmacro's.
196 * `zabbix_agent_monitored_by`: How the agent is monitored. Choices are 'zabbix_server', 'proxy', and 'proxy_group'. (Zabbix 7.0 or greater)
197 * `zabbix_agent_proxy`: The name of the Zabbix proxy (if used). Default `null`
198 * `zabbix_agent_proxy_group`: The name of the Zabbix proxy group (if used) (Zabbix 7.0 or later).
199 * `zabbix_agent_tags`: A list with tag and (optionally) value for creating host tags.
200 * `zabbix_api_create_hostgroup`: When you want to enable the Zabbix API to create/delete the hostgroups. Default: `False`
201 * `zabbix_api_create_hosts`: Default: `False`. When you want to enable the Zabbix API to create/delete the host. This has to be set to `True` if you want to make use of `zabbix_agent_host_state`.
202 * `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth (if your Zabbix is behind a proxy with HTTP Basic Auth).
203 * `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth (if your Zabbix is behind a proxy with HTTP Basic Auth).
204 * `zabbix_api_login_pass`: Password for the user which has API access.
205 * `zabbix_api_login_user`: Username of user which has API access.
206 * `zabbix_api_server_host`: The IP or hostname/FQDN of Zabbix server. Example: zabbix.example.com
207 * `zabbix_api_server_port`: 80 if `zabbix_api_use_ssl` is `false` and 443 if `true` (Default) TCP port to use to connect to Zabbix server. Example: 8080
208 * `zabbix_api_use_ssl`: Is SSL required to connect to the Zabbix API server? Default: `false`
209 * `zabbix_api_validate_certs`: `True` if we need to validate tls certificates of the API. Use `False` in case self-signed certificates are used. Default: `False`
210 * `zabbix_host_groups`: A list of hostgroups which this host belongs to. Default: "Linux Servers"
211 * `zabbix_host_status`: enabled (Default) when host in monitored, disabled when host is disabled for monitoring.
212 * `zabbix_useuip`: 1 if connection to zabbix-agent is made via ip, 0 for fqdn.
213
214 ## Windows Variables
215
216 **NOTE**
217
218 Supporting Windows is a best effort (We don't have the possibility to either test/verify changes on the various amount of available Windows instances). PRs specific to Windows will almost immediately be merged, unless someone is able to provide a Windows test mechanism via Travis for Pull Requests.
219 When `` is used in the name of the property, like `zabbix_agent_win_logfile`, it will show that you can configure `zabbix_agent_win_logfile` for the Zabbix Agent configuration file and `zabbix_agent2_win_logfile` for the Zabbix Agent 2 configuration file.
220
221 Otherwise it just for the Zabbix Agent or for the Zabbix Agent 2.
222
223 * `zabbix_agent_win_include`: The directory in which the Zabbix Agent specific configuration files are stored.
224 * `zabbix_agent_win_logfile`: The full path to the logfile for the Zabbix Agent.
225 * `zabbix_agent_version_long`: The long (major.minor.patch) version of the Zabbix Agent. This will be used to generate the `zabbix_win_package` and `zabbix_win_download_link` variables. This takes precedence over `zabbix_agent_version`.
226 * `zabbix_win_download_link`: The download url to the `win.zip` file.
227 * `zabbix_win_firewall_management`: Enable Windows firewall management (add service and port to allow rules). Default: `True`
228 * `zabbix_agent_win_install_dir`: The directory where Zabbix needs to be installed. Default: `C:\Program Files\Zabbix Agent 2` when variable `zabbix_agent2` is true, `C:\Program Files\Zabbix Agent` when `zabbix_agent2` is false.
229 * `zabbix_agent_win_install_dir_conf`: The directory where Zabbix configuration file needs to be installed. Default: `zabbix_agent_win_install_dir`
230 * `zabbix_win_package`: file name pattern (zip only). This will be used to generate the `zabbix_win_download_link` variable.
231
232 ### Tweaking the windows service
233
234 There might be times where the service is unpredictable, and rather than
235 investigating or dealing with it, you can just have it restart upon failure.
236 Here are some suggested values for tweaking the service.
237
238 * `zabbix_agent_service_start_mode:` `auto`, zabbix comes by default with `delayed`.
239 * ```yaml
240 zabbix_agent_service_failure_actions:
241 - type: restart
242 delay_ms: 10000
243 - type: restart
244 delay_ms: 20000
245 - type: restart
246 delay_ms: 40000
247 ```
248 * `zabbix_agent_service_failure_reset_period_sec:` `86400` is probably a reasonable time
249
250
251 ## macOS Variables
252
253 **NOTE**
254
255 _Supporting macOS is a best effort (We don't have the possibility to either test/verify changes on the various amount of available macOS instances). PRs specific to macOS will almost immediately be merged, unless someone is able to provide a macOS test mechanism via Travis for Pull Requests._
256
257 * `zabbix_mac_download_link`: The download url to the `pkg` file.
258 * `zabbix_mac_download_url`: The download url. Default `https://cdn.zabbix.com/zabbix/binaries/stable`
259 * `zabbix_mac_package`: The name of the mac install package. Default `zabbix_agent-{{ zabbix_agent_version_long }}-macos-amd64-openssl.pkg`
260 * `zabbix_agent_version_long`: The long (major.minor.patch) version of the Zabbix Agent. This will be used to generate the `zabbix_mac_download_link` link.
261
262 ## Docker Variables
263
264 When you don't want to install the Zabbix Agent on the host, but would like to run it in a container then these properties are useful. When `zabbix_agent_docker` is set to `True`, then a
265 Docker image will be downloaded and a Container will be started. No other installations will be done on the host, with the exception of the PSK file and the "Zabbix Include Directory".
266
267 The following directories are mounted in the Container:
268
269 ```
270 - /etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d
271 - /:/hostfs:ro
272 - /etc:/hostfs/etc:ro
273 - /proc:/hostfs/proc:ro
274 - /sys:/hostfs/sys:ro
275 - /var/run:/var/run
276 ```
277
278 Keep in mind that using the Zabbix Agent in a Container requires changes to the Zabbix Template for Linux as `/proc`, `/sys` and `/etc` are mounted in a directory `/hostfs`.
279
280 * `zabbix_agent_docker`: Default: `False`. When set to `True`, it will install a Docker container on the target host instead of installation on the target.
281 * `zabbix_agent_docker_env`: A dict with all environment variables that needs to be set for the Container.
282 * `zabbix_agent_docker_image`: The name of the Docker image. Default: `zabbix/zabbix-agent`
283 * `zabbix_agent_docker_image_tag`: The tag of the Docker image.
284 * `zabbix_agent_docker_name`: The name of the Container. Default: `zabbix-agent`
285 * `zabbix_agent_docker_network_mode`: The name of the (Docker) network that should be used for the Container. Default `host`.
286 * `zabbix_agent_docker_restart_policy`: Default: `unless-stopped`. The restart policy of the Container.
287 * `zabbix_agent_docker_ports`: A list with `<PORT>:<PORT>` values to open ports to the container. Default `10050`
288 * `zabbix_agent_docker_privileged`: When set to `True`, the container is running in privileged mode. Default `false`
289 * `zabbix_agent_docker_security_opts`: A list with available security options.
290 * `zabbix_agent_docker_state`: Default: `started`
291 * `zabbix_agent_docker_user_gid`: The group id of the zabbix user in the Container.
292 * `zabbix_agent_docker_user_uid`: The user id of the zabbix user in the Container.
293 * `zabbix_agent_docker_volumes`: A list with all directories that needs to be available in the Container.
294
295 ## IPMI variables
296
297 * `zabbix_agent_ipmi_authtype`: IPMI authentication algorithm. Possible values are -1 (default), 0 (none), 1 (MD2), 2 (MD5), 4 (straight), 5 (OEM), 6 (RMCP+), with -1 being the API default.
298 * `zabbix_agent_ipmi_password`: IPMI password.
299 * `zabbix_agent_ipmi_privilege`: IPMI privilege level. Possible values are 1 (callback), 2 (user), 3 (operator), 4 (admin), 5 (OEM), with 2 being the API default.
300 * `zabbix_agent_ipmi_username`: IPMI username.
301
302 ## Configuration Variables
303 The following table lists all variables that are exposed to modify the configuration of the zabbix_agent.conf file. Specific details of each variable can be found in the Zabbix documentation.
304
305 **NOTE**: Only variables with a default value appear in the defaults file, all others must be added.
306
307 | Zabbix Name | Variable Name | Default Value | Notes |
308 |-----------|------------------|--------|--------|
309 | Alias | zabbix_agent_aliases | | Can be a string or list |
310 | AllowKey | zabbix_agent_allowkeys | | |
311 | AllowRoot | zabbix_agent_allowroot | `False` | `True`/`False` Agent Linux Systems Only |
312 | BufferSend | zabbix_agent_buffersend | 5 | |
313 | BufferSize | zabbix_agent_buffersize | 100 | |
314 | ControlSocket | zabbix_agent_controlsocket | /tmp/agent.sock | Agent 2 Only |
315 | DebugLevel | zabbix_agent_debuglevel | 3 | |
316 | DenyKey | zabbix_agent_denykeys | | Can be a string or a list |
317 | EnablePersistentBuffer | zabbix_agent_enablepersistentbuffer | `False` | `True`/`False` Agent 2 Only |
318 | EnableRemoteCommands | zabbix_agent_enableremotecommands | `False` | `True`/`False` Agent Only |
319 | ForceActiveChecksOnStart | zabbix_agent_forceactivechecksonstart | `False` | `True`/`False` Agent 2 Only |
320 | HeartbeatFrequency | zabbix_agent_heartbeatfrequency | 60 | Version >= 6.4 |
321 | HostInterface | zabbix_agent_hostinterface | | |
322 | HostInterfaceItem | zabbix_agent_hostinterfaceitem | | |
323 | HostMetadata | zabbix_agent_hostmetadata | | |
324 | HostMetadataItem | zabbix_agent_hostmetadataitem | | |
325 | Hostname | zabbix_agent_hostname | | `{{ inventory_hostname }}` |
326 | HostnameItem | zabbix_agent_hostnameitem | | |
327 | Include | zabbix_agent_include_dir | /etc/zabbix/`{{ agent version specific }}`.d/*.conf | |
328 | ListenBacklog | zabbix_agent_listenbacklog | | Agent Only |
329 | ListenIP | zabbix_agent_listenip | 0.0.0.0 | |
330 | ListenPort | zabbix_agent_listenport | 10050 | |
331 | LoadModule | zabbix_agent_loadmodule | | Agent On Linux Only |
332 | LoadModulePath | zabbix_agent_loadmodulepath | | Agent On Linux Only |
333 | LogFile | zabbix_agent_logfile | /var/log/zabbix/`{{ agent version specific }}`.log | |
334 | LogFileSize | zabbix_agent_logfilesize | 100 | |
335 | LogRemoteCommands | zabbix_agent_logremotecommands | `False` | `True`/`False` Agent Only |
336 | LogType | zabbix_agent_logtype | file | |
337 | MaxLinesPerSecond | zabbix_agent_maxlinespersecond | 20 | Agent Only |
338 | PerfCounter | zabbix_agent_perfcounter | | Agent Only |
339 | PerfCounterEn | zabbix_agent_perfcounteren | | Agent Only |
340 | PersistentBufferFile | zabbix_agent_persistentbufferfile | | Agent 2 Only |
341 | PersistentBufferPeriod | zabbix_agent_persistentbufferperiod | 1h | Agent 2 Only |
342 | PidFile | zabbix_agent_pidfile | /var/run/zabbix/`{{ agent version specific }}`.pid | Linux Systems Only |
343 | Plugin | zabbix_agent_plugins | | |
344 | PluginSocket | zabbix_agent_pluginsocket | /tmp/agent.plugin.sock | Agent 2 Only |
345 | PluginTimeout | zabbix_agent_plugintimeout | 3 | Agent 2 Only |
346 | RefreshActiveChecks | zabbix_agent_refreshactivechecks | | |
347 | Server | zabbix_agent_server | | |
348 | ServerActive | zabbix_agent_serveractive | | |
349 | SourceIP | zabbix_agent_sourceip | | |
350 | StartAgents | zabbix_agent_startagents | 3 | Agent Only |
351 | StatusPort | zabbix_agent_statusport | 9999 | Agent 2 Only |
352 | Timeout | zabbix_agent_timeout | 3 | |
353 | TLSAccept | zabbix_agent_tlsconnect | unencrypted | Is overridden with `zabbix_agent_tlspsk_auto` == True |
354 | TLSCAFile | zabbix_agent_tlscafile | /etc/zabbix/tls_psk_auto.secret | |
355 | TLSCertFile | zabbix_agent_tlscertfile | | |
356 | TLSCipherAll | zabbix_agent_tlscipherall | | Agent on Linux Only |
357 | TLSCipherAll13 | zabbix_agent_tlscipherall13 | | Agent on Linux Only |
358 | TLSCipherCert | zabbix_agent_tlsciphercert | | Agent on Linux Only |
359 | TLSCipherCert13 | zabbix_agent_tlsciphercert13 | | Agent on Linux Only |
360 | TLSCipherPSK | zabbix_agent_tlscipherpsk | | Agent on Linux Only |
361 | TLSCipherPSK13 | zabbix_agent_tlscipherpsk13 | | Agent on Linux Only |
362 | TLSConnect | zabbix_agent_tlsconnect | unencrypted | Is overridden with `zabbix_agent_tlspsk_auto` == True |
363 | TLSCRLFile | zabbix_agent_tlscrlfile | | |
364 | TLSKeyFile | zabbix_agent_tlskeyfile | | |
365 | TLSPSKFile | zabbix_agent_tlspskfile | | |
366 | TLSPSKIdentity | zabbix_agent_tlspskidentity | | |
367 | TLSServerCertIssuer | zabbix_agent_tlsservercertissuer | | |
368 | TLSServerCertSubject | zabbix_agent_tlsservercertsubject | | |
369 | UnsafeUserParameters | zabbix_agent_unsafeuserparameters | `False` | `True`/`False` |
370 | User | zabbix_agent_runas_user | zabbix | Agent on Linux Only |
371 | UserParameter | zabbix_agent_userparamater | | |
372 | UserParameterDir | zabbix_agent_userparamaterdir | | |
373
374
375 ## Proxy
376
377 When the target host does not have access to the internet, but you do have a proxy available then the following properties needs to be set to download the packages via the proxy:
378
379 * `zabbix_http_proxy`
380 * `zabbix_https_proxy`
381
382 ## Tags
383
384 The majority of tasks within this role are tagged as follows:
385
386 * `install`: Tasks associated with the installation of software.
387 * `dependencies`: Installation tasks related to dependencies that aren't part of the core zabbix installation.
388 * `database`: Tasks associated with the installation or configuration of the database.
389 * `api`: Tasks associated with using the Zabbix API to connect and modify the Zabbix server.
390 * `config`: Tasks associated with the configuration of Zabbix or a supporting service.
391 * `service`: Tasks associated with managing a service.
392
393 # Dependencies
394
395 There are no dependencies on other roles.
396
397 # Example Playbook
398
399 In the `zabbix_agent2.conf` an entry will be created with the following content:
400
401 ```
402 Plugins.SystemRun.LogRemoteCommands=0
403 ```
404
405 ## agent_interfaces
406
407 This will configure the Zabbix Agent interface on the host.
408 ```yaml
409 zabbix_agent_interfaces:
410 - type: 1
411 main: 1
412 useip: "{{ zabbix_useuip }}"
413 ip: "{{ zabbix_agent_ip }}"
414 dns: "{{ ansible_fqdn }}"
415 port: "{{ zabbix_agent_listenport }}"
416 ```
417
418 ## Other interfaces
419
420 You can also configure the `zabbix_agent_interfaces` to add/configure snmp, jmx and ipmi interfaces.
421
422 You'll have to use one of the following type numbers when configuring it:
423
424 | Type Interface | Nr |
425 |-----------------|-------|
426 | Zabbix Agent | 1 |
427 | snmp | 2 |
428 | ipmi | 3 |
429 | jmx | 4 |
430
431 Configuring a snmp interface will look like this:
432
433 ```
434 zabbix_agent_interfaces:
435 - type: 2
436 main: 1
437 useip: "{{ zabbix_useuip }}"
438 ip: "{{ agent_ip }}"
439 dns: "{{ ansible_fqdn }}"
440 port: "{{ agent_listenport }}"
441 ```
442
443 ## Vars in role configuration
444 Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
445
446 ```yaml
447 - hosts: all
448 roles:
449 - role: community.zabbix.zabbix_agent
450 vars:
451 zabbix_agent_server: 192.168.33.30
452 zabbix_agent_serveractive: 192.168.33.30
453 zabbix_api_server_host: zabbix.example.com
454 zabbix_api_login_user: Admin
455 zabbix_api_login_pass: zabbix
456 zabbix_api_create_hostgroup: true
457 zabbix_api_create_hosts: true
458 zabbix_agent_host_state: present
459 zabbix_host_groups:
460 - Linux Servers
461 zabbix_agent_link_templates:
462 - Template OS Linux
463 - Apache APP Template
464 zabbix_agent_macros:
465 - macro_key: apache_type
466 macro_value: reverse_proxy
467 macro_type: text
468 zabbix_agent_tags:
469 - tag: environment
470 value: production
471 ```
472
473 ## Combination of group_vars and playbook
474 You can also use the group_vars or the host_vars files for setting the variables needed for this role. File you should change: `group_vars/all` or `host_vars/<zabbix_server>` (Where <zabbix_server> is the hostname of the machine running Zabbix Server)
475
476 ```yaml
477 zabbix_agent_server: 192.168.33.30
478 zabbix_agent_serveractive: 192.168.33.30
479 zabbix_api_server_host: zabbix.example.com
480 zabbix_api_login_user: Admin
481 zabbix_api_login_pass: zabbix
482 zabbix_api_create_hostgroup: true
483 zabbix_api_create_hosts: true
484 zabbix_agent_host_state: present
485 zabbix_host_groups:
486 - Linux Servers
487 zabbix_agent_link_templates:
488 - Template OS Linux
489 - Apache APP Template
490 zabbix_agent_macros:
491 - macro_key: apache_type
492 macro_value: reverse_proxy
493 zabbix_agent_tags:
494 - tag: environment
495 value: production
496 ```
497
498 and in the playbook only specifying:
499
500 ```yaml
501 - hosts: all
502 roles:
503 - role: community.zabbix.zabbix_agent
504 ```
505
506 ## Example for TLS PSK encrypted agent communication
507
508 Variables e.g. in the playbook or in `host_vars/myhost`:
509
510 ```yaml
511 zabbix_agent_tlsaccept: psk
512 zabbix_agent_tlsconnect: psk
513 zabbix_agent_tlspskidentity: "myhost PSK"
514 zabbix_agent_tlspsk_secret: b7e3d380b9d400676d47198ecf3592ccd4795a59668aa2ade29f0003abbbd40d
515 zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent_pskfile.psk
516 ```
517
518 # Molecule
519
520 This role is configured to be tested with Molecule. You can find on this page some more information regarding Molecule:
521
522 * http://werner-dijkerman.nl/2016/07/10/testing-ansible-roles-with-molecule-testinfra-and-docker/
523 * http://werner-dijkerman.nl/2016/07/27/extending-ansible-role-testing-with-molecule-by-adding-group_vars-dependencies-and-using-travis-ci/
524 * http://werner-dijkerman.nl/2016/07/31/testing-ansible-roles-in-a-cluster-setup-with-docker-and-molecule/
525
526 With each Pull Request, Molecule will be executed via travis.ci. Pull Requests will only be merged once these tests run successfully.
527
528 # Deploying Userparameters
529
530 The following steps are required to install custom userparameters and/or scripts:
531
532 * Put the desired userparameter file in the `templates/userparameters` directory and name it as `<userparameter_name>.j2`. For example: `templates/userparameters/mysql.j2`. You can change the default directory to a custom one modifying `zabbix_agent_userparameters_templates_src` variable.
533 * Put the scripts directory (if any) in the `files/scripts` directory. For example: `files/scripts/mysql`. You can change the default directory to a custom one modifying `zabbix_agent_userparameters_scripts_src` variable.
534 * Add `zabbix_agent_userparameters` variable to the playbook as a list of dictionaries and define userparameter name and scripts directory name (if there are no scripts just no not specify the `scripts_dir` variable).
535
536 Example:
537
538 ```yaml
539 - hosts: mysql_servers
540 tasks:
541 - include_role:
542 name: community.zabbix.zabbix_agent
543 vars:
544 zabbix_agent_server: zabbix.mydomain.com
545 zabbix_agent_userparameters:
546 - name: mysql
547 scripts_dir: mysql
548 - name: galera
549
550 ```
551
552 Example of the "templates/userparameters/mysql.j2" file:
553
554 ```
555 UserParameter=mysql.ping_to,mysqladmin -uroot ping | grep -c alive
556 ```
557
558 # License
559
560 GNU General Public License v3.0 or later
561
562 See LICENCE to see the full text.
563
564 # Author Information
565
566 Please send suggestion or pull requests to make this role better. Also let us know if you encounter any issues installing or using this role.
567
568 Github: https://github.com/ansible-collections/community.zabbix