From 40fc3fb5f9f8e53a37fe05361bbdf14188799933 Mon Sep 17 00:00:00 2001 From: Max Buz <79866323+xopek-by@users.noreply.github.com> Date: Tue, 5 Mar 2024 13:34:41 +0100 Subject: [PATCH] Started working with Ansible. Added some playbooks. --- .vscode/settings.json | 3 +++ Ansible/apt_upgrade.yml | 14 ++++++++++++++ Ansible/zabbix_agent_upgrade.yml | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 Ansible/apt_upgrade.yml create mode 100644 Ansible/zabbix_agent_upgrade.yml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2c9692e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "ansible.python.interpreterPath": "c:\\Users\\Max\\AppData\\Local\\Programs\\Python\\Python310\\python.exe" +} \ No newline at end of file diff --git a/Ansible/apt_upgrade.yml b/Ansible/apt_upgrade.yml new file mode 100644 index 0000000..ba32fda --- /dev/null +++ b/Ansible/apt_upgrade.yml @@ -0,0 +1,14 @@ +- name: Upgrade packages + hosts: vms + become: true + + tasks: + - name: Update cache + ansible.builtin.apt: + update_cache: true + register: cache_updated + + - name: Upgrade packages if something is changed + ansible.builtin.apt: + upgrade: "yes" + when: cache_updated.changed \ No newline at end of file diff --git a/Ansible/zabbix_agent_upgrade.yml b/Ansible/zabbix_agent_upgrade.yml new file mode 100644 index 0000000..17e01d1 --- /dev/null +++ b/Ansible/zabbix_agent_upgrade.yml @@ -0,0 +1,16 @@ +- name: Upgrade zabbix agent + hosts: zagents + become: true + + tasks: + - name: Ensure that Zabbix agent is at the latest version + ansible.builtin.apt: + name: zabbix-agent2 + state: latest + register: zabbix_agent2_status + + - name: Upgrade Zabbix agent if not latest + ansible.builtin.apt: + name: zabbix-agent2 + upgrade: yes + when: zabbix_agent2_status.changed \ No newline at end of file