- 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 }}"