diff --git a/docs/ZABBIX_AGENT_ROLE.md b/docs/ZABBIX_AGENT_ROLE.md index 68570133f..c49eb9c8e 100644 --- a/docs/ZABBIX_AGENT_ROLE.md +++ b/docs/ZABBIX_AGENT_ROLE.md @@ -288,45 +288,46 @@ The following table lists all variables that are exposed to modify the configura |-----------|------------------|--------|--------| | Alias | zabbix_agent_aliases | | Can be a string or list | | AllowKey | zabbix_agent_allowkeys | | | -| AllowRoot | zabbix_agent_allowroot | | Linux Systems Only | +| AllowRoot | zabbix_agent_allowroot | `False` | `True`/`False` Agent Linux Systems Only | | BufferSend | zabbix_agent_buffersend | 5 | | | BufferSize | zabbix_agent_buffersize | 100 | | | ControlSocket | zabbix_agent_controlsocket | /tmp/agent.sock | Agent 2 Only | | DebugLevel | zabbix_agent_debuglevel | 3 | | | DenyKey | zabbix_agent_denykeys | | Can be a string or a list | -| EnableRemoteCommands | zabbix_agent_enableremotecommands | 0 | Agent Only | -| ForceActiveChecksOnStart | zabbix_agent_forceactivechecksonstart | | Agent 2 Only | -| HeartbeatFrequency | zabbix_agent_heartbeatfrequency | 60 | Version >= 6.2 | +| EnablePersistentBuffer | zabbix_agent_enablepersistentbuffer | `False` | `True`/`False` Agent 2 Only | +| EnableRemoteCommands | zabbix_agent_enableremotecommands | `False` | `True`/`False` Agent Only | +| ForceActiveChecksOnStart | zabbix_agent_forceactivechecksonstart | `False` | `True`/`False` Agent 2 Only | +| HeartbeatFrequency | zabbix_agent_heartbeatfrequency | 60 | Version >= 6.4 | | HostInterface | zabbix_agent_hostinterface | | | | HostInterfaceItem | zabbix_agent_hostinterfaceitem | | | | HostMetadata | zabbix_agent_hostmetadata | | | | HostMetadataItem | zabbix_agent_hostmetadataitem | | | | Hostname | zabbix_agent_hostname | | `{{ inventory_hostname }}` | | HostnameItem | zabbix_agent_hostnameitem | | | -| Include | zabbix_agent_include | /etc/zabbix/`{ agent version specific }`.d | | +| Include | zabbix_agent_include | /etc/zabbix/`{ agent version specific }`.d/*.conf | | | ListenBacklog | zabbix_agent_listenbacklog | | Agent Only | -| ListenIP | zabbix_agent_listenip | | list of IPs | +| ListenIP | zabbix_agent_listenip | 0.0.0.0 | | | ListenPort | zabbix_agent_listenport | 10050 | | | LoadModule | zabbix_agent_loadmodule | | Agent On Linux Only | | LoadModulePath | zabbix_agent_loadmodulepath | | Agent On Linux Only | | LogFile | zabbix_agent_logfile | /var/log/zabbix/`{ agent version specific }`.log | | | LogFileSize | zabbix_agent_logfilesize | 100 | | -| LogRemoteCommands | zabbix_agent_logremotecommands | | Agent Only | +| LogRemoteCommands | zabbix_agent_logremotecommands | `False` | `True`/`False` Agent Only | | LogType | zabbix_agent_logtype | file | | -| MaxLinesPerSecond | zabbix_agent_maxlinespersecond | | Agent Only | +| MaxLinesPerSecond | zabbix_agent_maxlinespersecond | 20 | Agent Only | | PerfCounter | zabbix_agent_perfcounter | | Agent Only | | PerfCounterEn | zabbix_agent_perfcounteren | | Agent Only | | PersistentBufferFile | zabbix_agent_persistentbufferfile | | Agent 2 Only | | PersistentBufferPeriod | zabbix_agent_persistentbufferperiod | 1h | Agent 2 Only | | PidFile | zabbix_agent_pidfile | /var/run/zabbix/`{ agent version specific }`.pid | Linux Systems Only | | Plugin | zabbix_agent_plugins | | | -| PluginSocket | zabbix_agent_pluginsocket | | | -| PluginTimeout | zabbix_agent_plugintimeout | | | -| RefreshActiveChecks | zabbix_agent_refreshactivechecks | 120 | | +| PluginSocket | zabbix_agent_pluginsocket | /tmp/agent.plugin.sock | Agent 2 Only | +| PluginTimeout | zabbix_agent_plugintimeout | 3 | Agent 2 Only | +| RefreshActiveChecks | zabbix_agent_refreshactivechecks | | | | Server | zabbix_agent_server | | | | ServerActive | zabbix_agent_serveractive | | | | SourceIP | zabbix_agent_sourceip | | | -| StartAgents | zabbix_agent_startagents | | Agent Only | +| StartAgents | zabbix_agent_startagents | 3 | Agent Only | | StatusPort | zabbix_agent_statusport | 9999 | Agent 2 Only | | Timeout | zabbix_agent_timeout | 3 | | | TLSAccept | zabbix_agent_tlsconnect | | | @@ -345,9 +346,10 @@ The following table lists all variables that are exposed to modify the configura | TLSPSKIdentity | zabbix_agent_tlspskidentity | | | | TLSServerCertIssuer | zabbix_agent_tlsservercertissuer | | | | TLSServerCertSubject | zabbix_agent_tlsservercertsubject | | | -| UnsafeUserParameters | zabbix_agent_unsafeuserparameters | | | -| User | zabbix_agent_runas_user | | Agent on Linux Only | -| UserParameter | zabbix_agent_userparamater | 0 | | +| UnsafeUserParameters | zabbix_agent_unsafeuserparameters | `False` | `True`/`False` | +| User | zabbix_agent_runas_user | zabbix | Agent on Linux Only | +| UserParameter | zabbix_agent_userparamater | | | +| UserParameterDir | zabbix_agent_userparamaterdir | | | ## proxy diff --git a/roles/zabbix_agent/defaults/main.yml b/roles/zabbix_agent/defaults/main.yml index 8831cc759..318351cd4 100644 --- a/roles/zabbix_agent/defaults/main.yml +++ b/roles/zabbix_agent/defaults/main.yml @@ -5,15 +5,44 @@ zabbix_agent2: false zabbix_agent_version_minor: "*" zabbix_version_patch: 0 zabbix_agent_package_remove: false -zabbix_sender_package: zabbix-sender # Depricate in 3.0 -zabbix_agent_sender_package: "{{ zabbix_sender_package }}" -zabbix_get_package: zabbix-get # Depricate in 3.0 -zabbox_agent_get_package: "{{ zabbix_get_package }}" +zabbix_agent_sender_package: zabbix-sender +zabbox_agent_get_package: zabbix-get zabbix_agent_package_state: present zabbix_agent_selinux: false zabbix_agent_conf_mode: "0644" zabbix_agent_dont_detect_ip: false +zabbix_agent_listeninterface: +zabbix_agent_allowroot: false +zabbix_agent_buffersend: 5 +zabbix_agent_buffersize: 100 +zabbix_agent_controlsocket: /tmp/agent.sock +zabbix_agent_debuglevel: 3 +zabbix_agent_enablepersistentbuffer: false +zabbix_agent_enableremotecommands: false +zabbix_agent_forceactivechecksonstart: false +zabbix_agent_heartbeatfrequency: 60 +zabbix_agent_hostname: "{{ inventory_hostname }}" +zabbix_agent_include_mode: "0750" +zabbix_agent_listenip: 0.0.0.0 +zabbix_agent_listenport: 10050 +zabbix_agent_logfilesize: 100 +zabbix_agent_logtype: file +zabbix_agent_maxlinespersecond: 20 +zabbix_agent_persistentbufferperiod: 1h +zabbix_agent_pluginsocket: /tmp/agent.plugin.sock +zabbix_agent_plugintimeout: 3 +zabbix_agent_refreshactivechecks: 120 +zabbix_agent_statusport: 9999 +zabbix_agent_timeout: 3 +zabbix_agent_tlspsk_auto: false +zabbix_agent_tlspskfile: /etc/zabbix/tls_psk_auto.secret +zabbix_agent_unsafeuserparameters: false +zabbix_agent_runas_user: zabbix +zabbix_agent_loadmodulepath: ${libdir}/modules +zabbix_agent_logremotecommands: false +zabbix_agent_startagents: 3 + zabbix_agent_tlspskidentity_file: "/etc/zabbix/tls_psk_auto.identity" # Selinux related vars selinux_allow_zabbix_run_sudo: false @@ -60,11 +89,7 @@ zabbix_agent_interfaces: dns: "{{ ansible_fqdn }}" port: "{{ zabbix_agent_listenport }}" -# Zabbix configuration variables -zabbix_agent_listeninterface: - # statusportzabbix_agent_zabbix_alias: # Deprecate after 3.0 -zabbix_agent_alias: "{{ statusportzabbix_agent_zabbix_alias is defined | ternary(statusportzabbix_agent_zabbix_alias, zabbix_agent_alias) | default(omit) }}" zabbix_agent_userparameters_templates_src: "userparameters" zabbix_agent_userparameters_scripts_src: "scripts" zabbix_agent_chassis: false @@ -76,17 +101,10 @@ zabbix_agent_tls_config: # IPMI settings zabbix_agent_ipmi_authtype: -1 -zabbix_agent_ipmi_password: zabbix_agent_ipmi_privilege: 2 -zabbix_agent_ipmi_username: ####### Agent 1 Stuff Only -zabbix_agent_loadmodulepath: ${libdir}/modules -zabbix_agent_logremotecommands: 0 -zabbix_agent_maxlinespersecond: 100 -zabbix_agent_startagents: 3 - # Windows/macOS Related zabbix_version_long: 5.2.4 diff --git a/roles/zabbix_agent/tasks/RedHat.yml b/roles/zabbix_agent/tasks/RedHat.yml index 48ee3a2c2..b446a683e 100644 --- a/roles/zabbix_agent/tasks/RedHat.yml +++ b/roles/zabbix_agent/tasks/RedHat.yml @@ -19,8 +19,8 @@ - name: "RedHat | Installing zabbix-{sender,get}" ansible.builtin.package: pkg: - - "{{ zabbix_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" - - "{{ zabbix_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" + - "{{ zabbix_agent_sender_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" + - "{{ zabbox_agent_get_package }}-{{ zabbix_agent_version }}.{{ zabbix_agent_version_minor }}" disablerepo: "{{ zabbix_agent_disable_repo | default(omit) }}" state: "{{ zabbix_agent_package_state }}" environment: diff --git a/roles/zabbix_agent/templates/agent.conf.j2 b/roles/zabbix_agent/templates/agent.conf.j2 index ddce677ae..da3b8e15e 100644 --- a/roles/zabbix_agent/templates/agent.conf.j2 +++ b/roles/zabbix_agent/templates/agent.conf.j2 @@ -29,7 +29,7 @@ AllowKey={{ item }} # AllowKey= {% endif %} {% if not zabbix_agent2 and ansible_os_family != "Windows" %} -{{ (zabbix_agent_allowroot is defined and zabbix_agent_allowroot is not none) | ternary('', '# ') }}AllowRoot={{ zabbix_agent_allowroot | default('') }} +{{ (zabbix_agent_allowroot is defined and zabbix_agent_allowroot is not none) | ternary('', '# ') }}AllowRoot={{ zabbix_agent_allowroot | default (false) | ternary('1', '0') }} {% endif %} {{ (zabbix_agent_buffersend is defined and zabbix_agent_buffersend is not none) | ternary('', '# ') }}BufferSend={{ zabbix_agent_buffersend | default('') }} {{ (zabbix_agent_buffersize is defined and zabbix_agent_buffersize is not none) | ternary('', '# ') }}BufferSize={{ zabbix_agent_buffersize | default('') }} @@ -48,12 +48,14 @@ DenyKey={{ item }} {% else %} # DenyKey= {% endif %} -{{ (zabbix_agent_enablepersistentbuffer is defined and zabbix_agent_enablepersistentbuffer is not none) | ternary('', '# ') }}EnablePersistentBuffer={{ zabbix_agent_enablepersistentbuffer | default('') }} +{% if zabbix_agent2 %} +{{ (zabbix_agent_enablepersistentbuffer is defined and zabbix_agent_enablepersistentbuffer is not none) | ternary('', '# ') }}EnablePersistentBuffer={{ zabbix_agent_enablepersistentbuffer | default (false) | ternary('1', '0') }} +{% endif %} {% if not zabbix_agent2 %} -{{ (zabbix_agent_enableremotecommands is defined and zabbix_agent_enableremotecommands is not none) | ternary('', '# ') }}EnableRemoteCommands={{ zabbix_agent_enableremotecommands | default('') }} +{{ (zabbix_agent_enableremotecommands is defined and zabbix_agent_enableremotecommands is not none) | ternary('', '# ') }}EnableRemoteCommands={{ zabbix_agent_enableremotecommands | default (false) | ternary('1', '0') }} {% endif %} {% if zabbix_agent2 %} -{{ (zabbix_agent_forceactivechecksonstart is defined and zabbix_agent_forceactivechecksonstart is not none) | ternary('', '# ') }}ForceActiveChecksOnStart={{ zabbix_agent_forceactivechecksonstart | default('') }} +{{ (zabbix_agent_forceactivechecksonstart is defined and zabbix_agent_forceactivechecksonstart is not none) | ternary('', '# ') }}ForceActiveChecksOnStart={{ zabbix_agent_forceactivechecksonstart | default (false) | ternary('1', '0') }} {% endif %} {% if zabbix_agent_version is version_compare('6.2', '>=') %} {{ (zabbix_agent_heartbeatfrequency is defined and zabbix_agent_heartbeatfrequency is not none) | ternary('', '# ') }}HeartbeatFrequency={{ zabbix_agent_heartbeatfrequency | default('') }} @@ -77,7 +79,7 @@ DenyKey={{ item }} {{ (zabbix_agent_logfile is defined and zabbix_agent_logfile is not none) | ternary('', '# ') }}LogFile={{ zabbix_agent_logfile | default('') }} {{ (zabbix_agent_logfilesize is defined and zabbix_agent_logfilesize is not none) | ternary('', '# ') }}LogFileSize={{ zabbix_agent_logfilesize | default('') }} {% if not zabbix_agent2 %} -{{ (zabbix_agent_logremotecommands is defined and zabbix_agent_logremotecommands is not none) | ternary('', '# ') }}LogRemoteCommands={{ zabbix_agent_logremotecommands | default('') }} +{{ (zabbix_agent_logremotecommands is defined and zabbix_agent_logremotecommands is not none) | ternary('', '# ') }}LogRemoteCommands={{ zabbix_agent_logremotecommands | default (false) | ternary('1', '0') }} {% endif %} {{ (zabbix_agent_logtype is defined and zabbix_agent_logtype is not none) | ternary('', '# ') }}LogType={{ zabbix_agent_logtype | default('') }} {% if not zabbix_agent2 %} @@ -104,8 +106,10 @@ Plugins.{{ my_name }}.{{ param }}={{ value }} {% endfor %} {% endfor %} {% endif %} +{% if zabbix_agent2 %} {{ (zabbix_agent_pluginsocket is defined and zabbix_agent_pluginsocket is not none) | ternary('', '# ') }}PluginSocket={{ zabbix_agent_pluginsocket | default('') }} {{ (zabbix_agent_plugintimeout is defined and zabbix_agent_plugintimeout is not none) | ternary('', '# ') }}PluginTimeout={{ zabbix_agent_plugintimeout | default('') }} +{% endif %} {{ (zabbix_agent_refreshactivechecks is defined and zabbix_agent_refreshactivechecks is not none) | ternary('', '# ') }}RefreshActiveChecks={{ zabbix_agent_refreshactivechecks | default('') }} {{ (zabbix_agent_server is defined and zabbix_agent_server is not none) | ternary('', '# ') }}Server={{ zabbix_agent_server | default('') }} {{ (zabbix_agent_serveractive is defined and zabbix_agent_serveractive is not none) | ternary('', '# ') }}ServerActive={{ zabbix_agent_serveractive | default('') }} @@ -140,4 +144,4 @@ Plugins.{{ my_name }}.{{ param }}={{ value }} {{ (zabbix_agent_runas_user is defined and zabbix_agent_runas_user is not none) | ternary('', '# ') }}User={{ zabbix_agent_runas_user | default('') }} {% endif %} {{ (zabbix_agent_userparamater is defined and zabbix_agent_userparamater is not none) | ternary('', '# ') }}UserParameter={{ zabbix_agent_userparamater | default('') }} -{{ (zabbix_agent_userparamaterdir is defined and zabbix_agent_userparamaterdir is not none) | ternary('', '# ') }}UserParameterDir={{ zabbix_agent_userparamaterdir | default('') }} +{{ (zabbix_agent_userparamaterdir is defined and zabbix_agent_userparamaterdir is not none) | ternary('', '# ') }}UserParameterDir={{ zabbix_agent_userparamaterdir | default (false) | ternary('1', '0') }}