added new zabbix role
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Configure Zabbix agent
|
||||
ansible.builtin.template:
|
||||
src: zabbix_agent2.conf.j2
|
||||
dest: "{{ monitoring_zabbix_config_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: Restart Zabbix Agent
|
||||
@@ -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
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Install Zabbix agent package
|
||||
ansible.builtin.apt:
|
||||
name: "{{ monitoring_zabbix_agent_package }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure Zabbix agent service is enabled and started
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ monitoring_zabbix_agent_service }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: Install repository prerequisites
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- ca-certificates
|
||||
state: present
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Download Zabbix release package
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ monitoring_zabbix_release_url }}"
|
||||
dest: "{{ monitoring_zabbix_release_path }}"
|
||||
mode: '0644'
|
||||
|
||||
- name: Install Zabbix release package
|
||||
ansible.builtin.apt:
|
||||
deb: "{{ monitoring_zabbix_release_path }}"
|
||||
|
||||
- name: Update apt cache after Zabbix repository setup
|
||||
ansible.builtin.apt:
|
||||
update_cache: yes
|
||||
@@ -0,0 +1,14 @@
|
||||
- import_tasks: validate.yml
|
||||
tags: monitoring
|
||||
|
||||
- import_tasks: install-repository.yml
|
||||
tags: monitoring
|
||||
|
||||
- import_tasks: install-agent.yml
|
||||
tags: monitoring
|
||||
|
||||
- import_tasks: configure-docker.yml
|
||||
tags: monitoring
|
||||
|
||||
- import_tasks: configure-agent.yml
|
||||
tags: monitoring
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Stop playbook if system is not Debian
|
||||
ansible.builtin.fail:
|
||||
msg: "This role only supports Debian."
|
||||
when: ansible_facts['os_family'] != "Debian"
|
||||
|
||||
- name: Ensure Zabbix passive servers are defined
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- monitoring_zabbix_passive_servers | length > 0
|
||||
fail_msg: "Set monitoring_zabbix_passive_servers to the IPs, CIDRs or DNS names allowed to query the agent."
|
||||
Reference in New Issue
Block a user