Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ansible-collections/community.zabbix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 09cc9e0b60ca5d27ab32608fa1fa2961a008eaa3
Choose a base ref
..
head repository: ansible-collections/community.zabbix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eab24ed43fa0db8ff829c5efdd76ff1877c3a2dc
Choose a head ref
Showing with 37 additions and 80 deletions.
  1. +2 −0 changelogs/fragments/1277-refactor-userparameters.yml
  2. +35 −80 roles/zabbix_agent/tasks/userparameter.yml
2 changes: 2 additions & 0 deletions changelogs/fragments/1277-refactor-userparameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- zabbix_agent role - refactored userparameter tasks to be more efficient.
115 changes: 35 additions & 80 deletions roles/zabbix_agent/tasks/userparameter.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,45 @@
---
- block:
- name: "Windows | Installing user-defined userparameters"
ansible.windows.win_template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: '{{ zabbix_agent_win_include }}\{{ item.name }}.conf'
notify:
- restart win zabbix agent
with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is not defined

- name: "Windows | Installing user-defined scripts"
ansible.windows.win_copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: '{{ zabbix_win_install_dir }}\scripts\'
notify:
- restart win zabbix agent
with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is defined
when: ansible_os_family == "Windows"
tags:
- tags:
- config

- block:
- name: "Installing user-defined userparameters"
ansible.builtin.template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: "{{ zabbix_agent_include }}/userparameter_{{ item.name }}.conf"
owner: zabbix
group: zabbix
mode: 0644
block:
- when:
- ansible_os_family == "Windows"
notify:
- restart zabbix-agent
- restart mac zabbix agent
become: true
with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is not defined
- restart win zabbix agent
block:
- name: Windows | Install user-defined userparameters
ansible.windows.win_template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: '{{ zabbix_agent_win_include }}\{{ item.name }}.conf'
loop: "{{ zabbix_agent_userparameters | rejectattr('scripts_dir', 'defined') }}"

- name: "Installing user-defined scripts"
ansible.builtin.copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: "/etc/zabbix/scripts/"
owner: zabbix
group: zabbix
mode: 0755
notify:
- restart zabbix-agent
- restart mac zabbix agent
become: true
with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is defined
when:
- ansible_os_family != "Windows"
- not zabbix_agent2
tags:
- config
- name: Windows | Install user-defined scripts
ansible.windows.win_copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: '{{ zabbix_win_install_dir }}\scripts\'
loop: "{{ zabbix_agent_userparameters | selectattr('scripts_dir', 'defined') }}"

- block:
- name: "Installing user-defined userparameters"
ansible.builtin.template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: "{{ zabbix_agent2_include }}/userparameter_{{ item.name }}.conf"
owner: zabbix
group: zabbix
mode: 0644
- when:
- ansible_os_family != 'Windows'
notify:
- restart zabbix-agent
- restart mac zabbix agent
become: true
with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is not defined
block:
- name: Install user-defined userparameters
ansible.builtin.template:
src: "{{ zabbix_agent_userparameters_templates_src }}/{{ item.name }}.j2"
dest: "{{ zabbix_agent_include }}/userparameter_{{ item.name }}.conf"
owner: zabbix
group: zabbix
mode: "0644"
loop: "{{ zabbix_agent_userparameters | rejectattr('scripts_dir', 'defined') }}"

- name: "Installing user-defined scripts"
ansible.builtin.copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: "/etc/zabbix/scripts/"
owner: zabbix
group: zabbix
mode: 0755
notify:
- restart zabbix-agent
- restart mac zabbix agent
become: true
with_items: "{{ zabbix_agent_userparameters }}"
when: item.scripts_dir is defined
when:
- ansible_os_family != "Windows"
- zabbix_agent2
tags:
- config
- name: Install user-defined scripts
ansible.builtin.copy:
src: "{{ zabbix_agent_userparameters_scripts_src }}/{{ item.scripts_dir }}"
dest: /etc/zabbix/scripts/
owner: zabbix
group: zabbix
mode: "0755"
loop: "{{ zabbix_agent_userparameters | selectattr('scripts_dir', 'defined') }}"