added new zabbix role
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: Gather Docker group entries
|
||||
ansible.builtin.getent:
|
||||
database: group
|
||||
key: "{{ monitoring_zabbix_docker_group }}"
|
||||
failed_when: false
|
||||
|
||||
- name: Check whether Docker socket exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ monitoring_zabbix_docker_socket_path }}"
|
||||
register: monitoring_docker_socket
|
||||
|
||||
- name: Ensure Zabbix agent can access Docker socket
|
||||
ansible.builtin.user:
|
||||
name: "{{ monitoring_zabbix_agent_user }}"
|
||||
groups: "{{ monitoring_zabbix_docker_group }}"
|
||||
append: yes
|
||||
when:
|
||||
- monitoring_docker_socket.stat.exists
|
||||
- monitoring_zabbix_docker_group in (ansible_facts.getent_group | default({}))
|
||||
notify: Restart Zabbix Agent
|
||||
|
||||
- name: Ensure Docker plugin configuration directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ monitoring_zabbix_docker_plugin_config_file | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
when: monitoring_docker_socket.stat.exists
|
||||
|
||||
- name: Configure Docker plugin endpoint
|
||||
ansible.builtin.template:
|
||||
src: docker.conf.j2
|
||||
dest: "{{ monitoring_zabbix_docker_plugin_config_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
when: monitoring_docker_socket.stat.exists
|
||||
notify: Restart Zabbix Agent
|
||||
|
||||
- name: Remove Docker plugin configuration when Docker socket is absent
|
||||
ansible.builtin.file:
|
||||
path: "{{ monitoring_zabbix_docker_plugin_config_file }}"
|
||||
state: absent
|
||||
when: not monitoring_docker_socket.stat.exists
|
||||
notify: Restart Zabbix Agent
|
||||
Reference in New Issue
Block a user