Skip to content

Commit

Permalink
Fix looping logic for creating dirs and ensuring ownership, fixed tem…
Browse files Browse the repository at this point in the history
…plate
  • Loading branch information
Thulium-Drake committed Jul 13, 2024
1 parent 1a853ba commit 2bdd5ca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 17 additions & 1 deletion roles/zabbix_agent/tasks/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
tags:
- config

- name: "Create include dir zabbix-agent"
- name: "Create include dirs zabbix-agent"
ansible.builtin.file:
path: "{{ zabbix_agent_include_dir }}"
owner: root
Expand All @@ -138,6 +138,22 @@
become: true
tags:
- config
when: zabbix_agent_include_dir is string

- name: "Create include dirs zabbix-agent"
ansible.builtin.file:
path: "{{ include_dir }}"
owner: root
group: zabbix
mode: "{{ zabbix_agent_include_mode }}"
state: directory
loop: "{{ zabbix_agent_include_dir }}"
loop_control:
loop_var: 'include_dir'
when: zabbix_agent_include_dir is iterable
become: true
tags:
- config

- name: "Install the Docker container"
ansible.builtin.include_tasks: Docker.yml
Expand Down
8 changes: 4 additions & 4 deletions roles/zabbix_agent/templates/agent.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ DenyKey={{ item }}
{{ (zabbix_agent_hostmetadataitem is defined and zabbix_agent_hostmetadataitem is not none) | ternary('', '# ') }}HostMetadataItem={{ zabbix_agent_hostmetadataitem | default('') }}
{{ (zabbix_agent_hostname is defined and zabbix_agent_hostname is not none) | ternary('', '# ') }}Hostname={{ zabbix_agent_hostname | default('') }}
{{ (zabbix_agent_hostnameitem is defined and zabbix_agent_hostnameitem is not none) | ternary('', '# ') }}HostnameItem={{ zabbix_agent_hostnameitem | default('') }}
{% if zabbix_agent_include is defined and zabbix_agent_include %}
{% if zabbix_agent_include is string %}
Include={{ zabbix_agent_include }}/*.conf
{% if zabbix_agent_include_dir is defined and zabbix_agent_include_dir %}
{% if zabbix_agent_include_dir is string %}
Include={{ zabbix_agent_include_dir }}/*.conf
{% else %}
{% for item in zabbix_agent_include %}
{% for item in zabbix_agent_include_dir %}
Include={{ item }}/*.conf
{% endfor %}
{% endif %}
Expand Down

0 comments on commit 2bdd5ca

Please sign in to comment.