add an update task

This commit is contained in:
meaz 2023-08-04 07:58:27 +02:00
parent a38980aabe
commit 9c087cde38
Signed by: meaz
GPG Key ID: CD7A47B2F1ED43B4
2 changed files with 37 additions and 0 deletions

View File

@ -1,5 +1,8 @@
---
- name: Update
include: update.yml
- name: Manage apt apt_repository
include: apt.yml

34
tasks/update.yml Normal file
View File

@ -0,0 +1,34 @@
---
- name: "[Update] - Check installed version"
shell:
cmd: "apt-cache policy zabbix-server-mysql | grep Installed | cut -f 3 -d':' | cut -f1,2 -d'.'"
register: installed_version
- name: "[Update] - Make sure the server is stopped"
systemd:
name: zabbix-server
state: stopped
when: installed_version.stdout != zabbix_version
ignore_errors: true # needed otherwise there is an error on first installation as it doesn't exist
- name: "[Update] - Make sure the agent is stopped"
systemd:
name: zabbix-agent
state: stopped
when: installed_version != zabbix_version
ignore_errors: true # needed otherwise there is an error on first installation as it doesn't exist
- name: "[Update] - Make sure the proxy is stopped"
systemd:
name: zabbix-proxy
state: stopped
when: installed_version != zabbix_version
ignore_errors: true # needed otherwise there is an error on first installation as it doesn't exist
- name: '[Update] - Remove current repository'
file:
path: '/etc/apt/sources.list.d/zabbix.list'
state: 'absent'
when: installed_version != zabbix_version