Skip to content

Commit

Permalink
Add zabbix agent configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
João Andrade authored and zerwes committed Dec 9, 2024
1 parent ab48212 commit deddd68
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
7 changes: 7 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,11 @@
- config is defined
- config.changed | bool

# zabbix agent
- name: restart zabbix agent # noqa no-changed-when
ansible.builtin.command: configctl zabbixagent restart
when:
- config is defined
- config.changed | bool

...
8 changes: 8 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@
apply:
tags: nut

- name: zabbix agent
tags:
- always
ansible.builtin.include_tasks:
file: zabbixagent.yml
apply:
tags: zabbix-agent

- name: trim EOF
delegate_to: localhost
ansible.builtin.lineinfile:
Expand Down
77 changes: 77 additions & 0 deletions tasks/zabbixagent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---

# requires plugin os-zabbix*-agent to be installed
#
# opn_zabbixagent:
# local:
# hostname: my-opnsense-instance
# settings:
# main:
# enabled: 1
# serverList: <proxy/server IP>
# listenPort: 10050
# listenIP: 0.0.0.0
# sudoRoot: 1
# tuning:
# timeout: 10
# features:
# enableActiveChecks: 1
# activeCheckServers: <proxy/server IP>
# enableRemoteCommands: 1
# encryption: 1
# encryptionidentity: my-opnsense-instance
# encryptionpsk: zabbixpsk
# userparameters:
# 980e7ff4-6f59-4072-82a1-e78655ecd70b:
# key: opn.version
# command: opnsense-version

- name: zabbix agent - hostname
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: /opnsense/OPNsense/ZabbixAgent/local/{{ item.key }}
value: "{{ item.value }}"
pretty_print: true
notify: restart zabbix agent
with_dict: "{{ opn_zabbixagent.local | default({}) }}"

- name: zabbix agent - main settings
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: /opnsense/OPNsense/ZabbixAgent/settings/main/{{ item.key }}
value: "{{ item.value }}"
pretty_print: true
notify: restart zabbix agent
with_dict: "{{ opn_zabbixagent.settings.main | default({}) }}"

- name: zabbix agent - tuning
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: /opnsense/OPNsense/ZabbixAgent/settings/tuning/{{ item.key }}
value: "{{ item.value }}"
pretty_print: true
notify: restart zabbix agent
with_dict: "{{ opn_zabbixagent.settings.tuning | default({}) }}"

- name: zabbix agent - features
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: /opnsense/OPNsense/ZabbixAgent/settings/features/{{ item.key }}
value: "{{ item.value }}"
pretty_print: true
notify: restart zabbix agent
with_dict: "{{ opn_zabbixagent.settings.features | default({}) }}"

- name: zabbix agent - userparameters
ansible.builtin.include_tasks: zabbixagentuserparameters.yml
vars:
uuid: "{{ userparameter.key }}"
cfg: "{{ userparameter.value }}"
with_dict:
- "{{ opn_zabbixagent.userparameters | default({}) }}"
loop_control:
loop_var: userparameter
21 changes: 21 additions & 0 deletions tasks/zabbixagentuserparameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

- name: zabbix agent - userparameter id config
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: /opnsense/OPNsense/ZabbixAgent/userparameters/userparameter[@uuid='{{ uuid }}']/id
value: "{{ uuid }}"
pretty_print: true
notify: restart zabbix agent

- name: zabbix agent - userparameter configs
delegate_to: localhost
community.general.xml:
path: "{{ local_config_path }}"
xpath: /opnsense/OPNsense/ZabbixAgent/userparameters/userparameter[@uuid='{{ uuid }}']/{{ item.key }}
value: "{{ item.value }}"
pretty_print: true
notify: restart zabbix agent
with_dict:
- "{{ cfg | default({}) }}"

0 comments on commit deddd68

Please sign in to comment.