Optimized update roles

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-15 15:18:07 +02:00
parent bbabc58cf9
commit bb7859ab44
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
12 changed files with 65 additions and 15 deletions

View File

@ -3,49 +3,76 @@
stat: stat:
path: "{{ path_docker_compose_instances }}" path: "{{ path_docker_compose_instances }}"
register: docker_compose_directory_stat register: docker_compose_directory_stat
when:
- run_once_update is not defined
- name: "Update with pacman" - name: "Update with pacman"
include_role: include_role:
name: update-pacman name: update-pacman
when: ansible_distribution == 'Archlinux' when:
- run_once_update is not defined
- ansible_distribution == 'Archlinux'
- name: "Update with apt" - name: "Update with apt"
include_role: include_role:
name: update-apt name: update-apt
when: ansible_distribution == "Debian" when:
- run_once_update is not defined
- ansible_distribution == "Debian"
- name: "Update Docker Images" - name: "Update Docker Images"
include_role: include_role:
name: update-docker name: update-docker
when: docker_compose_directory_stat.stat.exists when:
- run_once_update is not defined
- docker_compose_directory_stat.stat.exists
- name: "Check if yay is installed" - name: "Check if yay is installed"
command: which yay command: which yay
register: yay_installed register: yay_installed
changed_when: false changed_when: false
failed_when: false failed_when: false
when:
- run_once_update is not defined
- name: "Update with yay" - name: "Update with yay"
include_role: include_role:
name: update-yay name: update-yay
when: yay_installed.rc == 0 when:
- run_once_update is not defined
- yay_installed.rc == 0
- name: "Check if pip is installed" - name: "Check if pip is installed"
command: which pip command: which pip
register: pip_installed register: pip_installed
changed_when: false changed_when: false
failed_when: false failed_when: false
when:
- run_once_update is not defined
- name: "Update with pip" - name: "Update with pip"
include_role: include_role:
name: update-pip name: update-pip
when:
- run_once_update is not defined
- name: "Check if pkgmgr command is available" - name: "Check if pkgmgr command is available"
command: "which pkgmgr" command: "which pkgmgr"
register: pkgmgr_available register: pkgmgr_available
failed_when: false failed_when: false
when:
- run_once_update is not defined
- name: "Update all repositories using pkgmgr" - name: "Update all repositories using pkgmgr"
include_role: include_role:
name: update-pkgmgr name: update-pkgmgr
when: pkgmgr_available.rc == 0 when:
- pkgmgr_available.rc == 0
- run_once_update is not defined
- name: run the update tasks once
set_fact:
run_once_update: true
when: run_once_update is not defined

View File

@ -2,21 +2,31 @@
systemd: systemd:
name: sys-bkp-docker-2-loc-everything.cymais.service name: sys-bkp-docker-2-loc-everything.cymais.service
state: started state: started
when: mode_backup | bool when:
- run_once_update_docker is not defined
- mode_backup | bool
- name: create {{update_docker_script}} - name: create {{update_docker_script}}
template: template:
src: update-docker.py.j2 src: update-docker.py.j2
dest: "{{update_docker_script}}" dest: "{{update_docker_script}}"
when: run_once_update_docker is not defined
- name: configure update-docker.cymais.service - name: configure update-docker.cymais.service
template: template:
src: update-docker.service.j2 src: update-docker.service.j2
dest: /etc/systemd/system/update-docker.cymais.service dest: /etc/systemd/system/update-docker.cymais.service
when: run_once_update_docker is not defined
- name: "restart update-docker.cymais.service" - name: "restart update-docker.cymais.service"
systemd: systemd:
name: update-docker.cymais.service name: update-docker.cymais.service
state: restarted state: restarted
enabled: yes enabled: yes
daemon_reload: yes daemon_reload: yes
when: run_once_update_docker is not defined
- name: run the update docker tasks once
set_fact:
run_once_update_docker: true
when: run_once_update_docker is not defined

View File

@ -1,2 +1,2 @@
update_docker_script: '{{path_administrator_scripts}}update-docker.py' update_docker_script: '{{path_administrator_scripts}}update-docker.py'
application_id: docker application_id: update-docker

View File

@ -2,3 +2,9 @@
pacman: pacman:
update_cache: yes update_cache: yes
upgrade: yes upgrade: yes
when: run_once_update_pacman is not defined
- name: run update pacman once
set_fact:
run_once_update_pacman: true
when: run_once_update_pacman is not defined

View File

@ -1 +1 @@
application_id: pacman application_id: update-pacman

View File

@ -1 +1 @@
application_id: pip application_id: update-pip

View File

@ -1 +0,0 @@
pkgmgr_command: "pkgmgr"

View File

@ -1 +1 @@
application_id: pkgmgr application_id: update-pkgmgr

View File

@ -3,4 +3,10 @@
kewlfft.aur.aur: kewlfft.aur.aur:
upgrade: yes upgrade: yes
use: yay use: yay
aur_only: yes aur_only: yes
when: run_once_update_yay is not defined
- name: run update yay once
set_fact:
run_once_update_yay: true
when: run_once_update_yay is not defined

View File

@ -1 +1 @@
application_id: yay application_id: update-yay

View File

@ -96,6 +96,7 @@
include_role: include_role:
name: user-root name: user-root
# @todo change this to role based todo
- name: update device - name: update device
include_role: include_role:
name: update-compose name: update-compose

View File

@ -2,5 +2,6 @@
include_tasks: "./tasks/groups/{{ item }}-roles.yml" include_tasks: "./tasks/groups/{{ item }}-roles.yml"
loop: loop:
- svc-opt # Load optimation services - svc-opt # Load optimation services
- update # Do additional update routines @todo remove the update from the constructor and the main.py
loop_control: loop_control:
label: "{{ item }}-roles.yml" label: "{{ item }}-roles.yml"