generated from GamingChaos/ansible-repository-template
add old update-checkmk playbook
This commit is contained in:
parent
79c3952e64
commit
ce33e8a689
3
inventory/host_vars/shion.stuyckv.local.yml
Normal file
3
inventory/host_vars/shion.stuyckv.local.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
checkmk_sites:
|
||||||
|
- local
|
||||||
|
- dev
|
||||||
12
inventory/monitoring
Normal file
12
inventory/monitoring
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[sites]
|
||||||
|
shion.stuyckv.local
|
||||||
|
|
||||||
|
[agents]
|
||||||
|
rimeru.stuyckv.local
|
||||||
|
shion.stuyckv.local
|
||||||
|
charybdis.stuyckv.local
|
||||||
|
ramiris.stuyckv.local
|
||||||
|
millim.stuyckv.local
|
||||||
|
guy.stuyckv.local
|
||||||
|
claymen.stuyckv.local
|
||||||
|
leon.stuyckv.local
|
||||||
53
playbooks/update-checkmk.yml
Normal file
53
playbooks/update-checkmk.yml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
- name: Update checkmk on monitoring hosts
|
||||||
|
hosts: sites
|
||||||
|
become: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
# cannot be done with git module. It has no method to query the tags of a repo
|
||||||
|
- name: Get latest checkmk version # noqa: run-once[task] command-instead-of-module
|
||||||
|
register: checkmk_version
|
||||||
|
run_once: true
|
||||||
|
changed_when: false
|
||||||
|
ansible.builtin.shell:
|
||||||
|
executable: /bin/bash
|
||||||
|
cmd: |
|
||||||
|
set -o pipefail
|
||||||
|
git -c 'versionsort.suffix=-' \
|
||||||
|
ls-remote --tags --sort='v:refname' \
|
||||||
|
https://github.com/Checkmk/checkmk.git |\
|
||||||
|
grep -v '\-rc.' | tail --lines=1 |\
|
||||||
|
cut --delimiter='/' --fields=3 | tr -d "v^{}"
|
||||||
|
|
||||||
|
- name: Output checkmk version # noqa: run-once[task]
|
||||||
|
run_once: true
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: checkmk_version.stdout
|
||||||
|
|
||||||
|
- name: Install new checkmk version
|
||||||
|
vars:
|
||||||
|
filename: "check-mk-raw-{{ checkmk_version.stdout }}_0.{{ ansible_facts.lsb.codename }}_amd64.deb"
|
||||||
|
ansible.builtin.apt:
|
||||||
|
deb: "https://download.checkmk.com/checkmk/{{ checkmk_version.stdout }}/{{ filename }}"
|
||||||
|
when: ansible_facts.lsb.id == 'Ubuntu'
|
||||||
|
|
||||||
|
- name: Stop omd sites
|
||||||
|
register: stop_cmd
|
||||||
|
changed_when: stop_cmd.rc == 0
|
||||||
|
loop: "{{ checkmk_sites }}"
|
||||||
|
ansible.builtin.command: "omd stop {{ item }}"
|
||||||
|
|
||||||
|
- name: Create backup of site (/tmp/backup-{ item }.tar.gz)
|
||||||
|
changed_when: true
|
||||||
|
loop: "{{ checkmk_sites }}"
|
||||||
|
ansible.builtin.command: "omd backup {{ item }} /tmp/backup-{{ item }}.tar.gz"
|
||||||
|
|
||||||
|
- name: Update omd site
|
||||||
|
changed_when: true
|
||||||
|
loop: "{{ checkmk_sites }}"
|
||||||
|
ansible.builtin.command: "omd -f update --conflict=keepold {{ item }}"
|
||||||
|
|
||||||
|
- name: Start omd sites
|
||||||
|
register: start_cmd
|
||||||
|
changed_when: start_cmd.rc == 0
|
||||||
|
loop: "{{ checkmk_sites }}"
|
||||||
|
ansible.builtin.command: "omd start {{ item }}"
|
||||||
Loading…
x
Reference in New Issue
Block a user