From ecfee8835337bbc506c1dc5dbc99dc7f07a156a9 Mon Sep 17 00:00:00 2001 From: rubenb Date: Mon, 23 Oct 2023 17:14:16 +0200 Subject: [PATCH] playbook and roles for zabbix-agent --- linux-config-zabbix-agent.yaml | 12 +++++ roles/config-zabbix-agent/handlers/main.yaml | 5 +++ roles/config-zabbix-agent/tasks/main.yaml | 47 ++++++++++++++++++++ roles/config-zabbix-agent/vars/main.yaml | 5 +++ 4 files changed, 69 insertions(+) create mode 100644 linux-config-zabbix-agent.yaml create mode 100644 roles/config-zabbix-agent/handlers/main.yaml create mode 100644 roles/config-zabbix-agent/tasks/main.yaml create mode 100644 roles/config-zabbix-agent/vars/main.yaml diff --git a/linux-config-zabbix-agent.yaml b/linux-config-zabbix-agent.yaml new file mode 100644 index 0000000..57a5c72 --- /dev/null +++ b/linux-config-zabbix-agent.yaml @@ -0,0 +1,12 @@ +--- + +- hosts: "{{ ip_addr }}" + become: yes + become_method: sudo + gather_facts: no + + tasks: + + - name: "[CONFIG ZABBIX AGENT] Install and configure ZABBIX AGENT" + import_role: + name: config-zabbix-agent \ No newline at end of file diff --git a/roles/config-zabbix-agent/handlers/main.yaml b/roles/config-zabbix-agent/handlers/main.yaml new file mode 100644 index 0000000..bf1c0ce --- /dev/null +++ b/roles/config-zabbix-agent/handlers/main.yaml @@ -0,0 +1,5 @@ +# restart zabbix-agent service +- name: restart zabbix-agent + service: + name: "{{ zabbix_agent_daemon }}" + state: restarted \ No newline at end of file diff --git a/roles/config-zabbix-agent/tasks/main.yaml b/roles/config-zabbix-agent/tasks/main.yaml new file mode 100644 index 0000000..9628470 --- /dev/null +++ b/roles/config-zabbix-agent/tasks/main.yaml @@ -0,0 +1,47 @@ +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Install and configure ZABBIX AGENT +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Paso1 +# Download zabbix repository +- name: Download deb package + get_url: + url: "{{ deb_url }}" + dest: /tmp/"{{ deb_package_repo }}" +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Paso2 +# Install zabbix repository +- name: Install zabbix repository + apt: + deb: /tmp/"{{ deb_package_repo }}" +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Paso3 +# Delete deb package from tmp +- name: Delete deb package from tmp + file: + path: /tmp/"{{ deb_package_repo }}" + state: absent +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Paso4 +# update packages +- name: update packages + apt: + name: "*" + state: latest + update_cache: true + force_apt_get: true +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Install zabbix agent +- name: Install zabbix agent + apt: + name: "{{ zabbix_package }}" + state: present + notify: restart zabbix-agent +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# service should start on boot. +- name: service should start on boot + service: + name: "{{ zabbix_agent_daemon }}" + enabled: yes +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/roles/config-zabbix-agent/vars/main.yaml b/roles/config-zabbix-agent/vars/main.yaml new file mode 100644 index 0000000..9457d88 --- /dev/null +++ b/roles/config-zabbix-agent/vars/main.yaml @@ -0,0 +1,5 @@ +# vars file +deb_url: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb +deb_package_repo: zabbix-release_6.4-1+debian12_all.deb +zabbix_package: zabbix-agent +zabbix_agent_daemon: zabbix-agent \ No newline at end of file