Compare commits

...

5 Commits

Author SHA1 Message Date
Vincent Stuyck
21b3b528cf create a snapshot before the update starts 2026-03-15 04:29:31 +01:00
Vincent Stuyck
e35c1cbf3c add requirements and an init script 2026-03-15 03:49:05 +01:00
Vincent Stuyck
ce33e8a689 add old update-checkmk playbook 2026-03-15 03:43:08 +01:00
Vincent Stuyck
79c3952e64 remove redundant honst entry 2026-03-15 03:41:52 +01:00
Vincent Stuyck
d7b53b1cf5 remove old folders 2026-03-15 03:41:35 +01:00
26 changed files with 114 additions and 5 deletions

4
.gitignore vendored
View File

@ -1,3 +1 @@
# ---> Ansible
*.retry
venv/

View File

View File

8
init.sh Executable file
View File

@ -0,0 +1,8 @@
# initialize venv
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
ansible-galaxy collection install -r requirements.yml

View File

@ -0,0 +1,4 @@
---
proxmox_api_host: rimeru.stuyckv.local
proxmox_api_user: ansible@pve
proxmox_api_token_id: ansible

View File

@ -0,0 +1,9 @@
$ANSIBLE_VAULT;1.1;AES256
66393831316666346565393032333961373365346633643730386661616332356431653331396334
3633373066646165636639646462376338366665376561650a643530306339666436323130383737
36373532623435336466386433326664356537326137363537343133323739343732383565346336
6630636236363261610a646336613436323462663339313364393833653539653238666437623261
65383864346165623730363136353838396131643962393134366362393266356365396231633064
65366631653437626666343465383338383637373139353130623961316662353431313037303834
36356131323233613461333163303537306635343065663435333961376264316235643335323661
36336331336537343432

View File

@ -1,5 +1,4 @@
[ubuntu]
charybdis.stuyckv.local
shion.stuyckv.local
charybdis.stuyckv.local
ramiris.stuyckv.local

View File

@ -0,0 +1,5 @@
checkmk_sites:
- local
- dev
vmid: 101

12
inventory/monitoring Normal file
View 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

View File

View File

View File

@ -0,0 +1,68 @@
- 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: Snapshot VM before update
become: false
delegate_to: localhost
community.proxmox.proxmox_snap:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
validate_certs: false
hostname: "{{ inventory_hostname_short }}"
snapname: "checkmk_{{ checkmk_version.stdout | replace('.', '_') | replace('-', '_') }}"
description: "Pre-update snapshot before checkmk {{ checkmk_version.stdout }}"
timeout: 120
state: present
- 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 }}"

View File

@ -22,4 +22,4 @@
- name: Remove dependencies that are no longer required.
ansible.builtin.apt:
autoremove: yes
autoremove: yes

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
proxmoxer
requests

4
requirements.yml Normal file
View File

@ -0,0 +1,4 @@
---
collections:
- name: community.proxmox
version: "1.6.0"