generated from GamingChaos/ansible-repository-template
also update checkmk agent
This commit is contained in:
parent
21b3b528cf
commit
a88df82e45
@ -1,12 +1,11 @@
|
|||||||
- name: Update checkmk on monitoring hosts
|
- name: Gather latest checkmk version
|
||||||
hosts: sites
|
hosts: all
|
||||||
become: true
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
# cannot be done with git module. It has no method to query the tags of a repo
|
# 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
|
- name: Get latest checkmk version # noqa: run-once[task] command-instead-of-module
|
||||||
register: checkmk_version
|
register: checkmk_version
|
||||||
run_once: true
|
delegate_to: localhost
|
||||||
changed_when: false
|
changed_when: false
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
@ -23,6 +22,16 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: checkmk_version.stdout
|
var: checkmk_version.stdout
|
||||||
|
|
||||||
|
- name: Set checkmk version fact # noqa: run-once[task]
|
||||||
|
run_once: true
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
checkmk_version: "{{ checkmk_version.stdout }}"
|
||||||
|
|
||||||
|
- name: Update checkmk on monitoring hosts
|
||||||
|
hosts: sites
|
||||||
|
become: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
- name: Snapshot VM before update
|
- name: Snapshot VM before update
|
||||||
become: false
|
become: false
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
@ -33,16 +42,16 @@
|
|||||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
hostname: "{{ inventory_hostname_short }}"
|
hostname: "{{ inventory_hostname_short }}"
|
||||||
snapname: "checkmk_{{ checkmk_version.stdout | replace('.', '_') | replace('-', '_') }}"
|
snapname: "checkmk_{{ checkmk_version | replace('.', '_') | replace('-', '_') }}"
|
||||||
description: "Pre-update snapshot before checkmk {{ checkmk_version.stdout }}"
|
description: "Pre-update snapshot before checkmk {{ checkmk_version }}"
|
||||||
timeout: 120
|
timeout: 120
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install new checkmk version
|
- name: Install new checkmk version
|
||||||
vars:
|
vars:
|
||||||
filename: "check-mk-raw-{{ checkmk_version.stdout }}_0.{{ ansible_facts.lsb.codename }}_amd64.deb"
|
filename: "check-mk-raw-{{ checkmk_version }}_0.{{ ansible_facts.lsb.codename }}_amd64.deb"
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
deb: "https://download.checkmk.com/checkmk/{{ checkmk_version.stdout }}/{{ filename }}"
|
deb: "https://download.checkmk.com/checkmk/{{ checkmk_version }}/{{ filename }}"
|
||||||
when: ansible_facts.lsb.id == 'Ubuntu'
|
when: ansible_facts.lsb.id == 'Ubuntu'
|
||||||
|
|
||||||
- name: Stop omd sites
|
- name: Stop omd sites
|
||||||
@ -51,7 +60,7 @@
|
|||||||
loop: "{{ checkmk_sites }}"
|
loop: "{{ checkmk_sites }}"
|
||||||
ansible.builtin.command: "omd stop {{ item }}"
|
ansible.builtin.command: "omd stop {{ item }}"
|
||||||
|
|
||||||
- name: Create backup of site (/tmp/backup-{ item }.tar.gz)
|
- name: Create backup of site (/tmp/backup-{{ item }}.tar.gz)
|
||||||
changed_when: true
|
changed_when: true
|
||||||
loop: "{{ checkmk_sites }}"
|
loop: "{{ checkmk_sites }}"
|
||||||
ansible.builtin.command: "omd backup {{ item }} /tmp/backup-{{ item }}.tar.gz"
|
ansible.builtin.command: "omd backup {{ item }} /tmp/backup-{{ item }}.tar.gz"
|
||||||
@ -66,3 +75,13 @@
|
|||||||
changed_when: start_cmd.rc == 0
|
changed_when: start_cmd.rc == 0
|
||||||
loop: "{{ checkmk_sites }}"
|
loop: "{{ checkmk_sites }}"
|
||||||
ansible.builtin.command: "omd start {{ item }}"
|
ansible.builtin.command: "omd start {{ item }}"
|
||||||
|
|
||||||
|
- name: Update checkmk agents on monitored hosts
|
||||||
|
hosts: agents
|
||||||
|
become: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Install new checkmk agent
|
||||||
|
ansible.builtin.apt:
|
||||||
|
deb: "https://checkmk.stuyckv.com/local/check_mk/agents/check-mk-agent_{{ checkmk_version }}-1_all.deb"
|
||||||
|
when: ansible_facts.lsb.id == 'Ubuntu'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user