zabbix/tasks/update.yml

39 lines
1.2 KiB
YAML

---
- 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
notify:
- 'Restart zabbix_server'
- 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
notify:
- 'Restart zabbix_agent'
- 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
notify:
- 'Restart zabbix_proxy'
- name: '[Update] - Remove current repository'
file:
path: '/etc/apt/sources.list.d/zabbix.list'
state: 'absent'
when: installed_version != zabbix_version