From cfc052c1293365b92af9a5a6291ffa7f0e4960e5 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 20 Jun 2025 15:50:24 +0200 Subject: [PATCH] Solved bugs appearing during backup-server setup (light weigth installation) --- .../tasks/main.yml | 17 ++++++++++--- roles/health-journalctl/handlers/main.yml | 4 ++-- roles/health-msmtp/handlers/main.yml | 6 ++--- roles/pkgmgr/meta/main.yml | 1 + roles/python-yaml/README.md | 20 ++++++++++++++++ roles/python-yaml/meta/main.yml | 24 +++++++++++++++++++ roles/python-yaml/tasks/main.yml | 11 +++++++++ tasks/plays/01_constructor.yml | 2 +- 8 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 roles/python-yaml/README.md create mode 100644 roles/python-yaml/meta/main.yml create mode 100644 roles/python-yaml/tasks/main.yml diff --git a/roles/cleanup-docker-anonymous-volumes/tasks/main.yml b/roles/cleanup-docker-anonymous-volumes/tasks/main.yml index ec3a1875..9fc2f66b 100644 --- a/roles/cleanup-docker-anonymous-volumes/tasks/main.yml +++ b/roles/cleanup-docker-anonymous-volumes/tasks/main.yml @@ -1,16 +1,27 @@ +- name: Check if docker is installed + ansible.builtin.stat: + path: /usr/bin/docker + register: docker_bin + - name: "pkgmgr install" include_role: name: pkgmgr-install vars: package_name: dockreap - when: run_once_cleanup_docker_anonymous_volumes is not defined + when: + - run_once_cleanup_docker_anonymous_volumes is not defined + - docker_bin.stat.exists - name: run dockreap with --no-confirmation command: cmd: "dockreap --no-confirmation" - when: run_once_cleanup_docker_anonymous_volumes is not defined + when: + - run_once_cleanup_docker_anonymous_volumes is not defined + - docker_bin.stat.exists - name: mark dockreap as run set_fact: run_once_cleanup_docker_anonymous_volumes: true - when: run_once_cleanup_docker_anonymous_volumes is not defined + when: + - run_once_cleanup_docker_anonymous_volumes is not defined + - docker_bin.stat.exists diff --git a/roles/health-journalctl/handlers/main.yml b/roles/health-journalctl/handlers/main.yml index 4f80b4a1..16a18dda 100644 --- a/roles/health-journalctl/handlers/main.yml +++ b/roles/health-journalctl/handlers/main.yml @@ -1,5 +1,5 @@ -- name: reload health-msmtp.cymais.service +- name: "reload health-journalctl.cymais.service" systemd: - name: health-msmtp.cymais.service + name: health-journalctl.cymais.service enabled: yes daemon_reload: yes \ No newline at end of file diff --git a/roles/health-msmtp/handlers/main.yml b/roles/health-msmtp/handlers/main.yml index 83fa7f0b..4f80b4a1 100644 --- a/roles/health-msmtp/handlers/main.yml +++ b/roles/health-msmtp/handlers/main.yml @@ -1,5 +1,5 @@ -- name: "reload health-journalctl.cymais.service" +- name: reload health-msmtp.cymais.service systemd: - name: health-journalctl.cymais.service + name: health-msmtp.cymais.service enabled: yes - daemon_reload: yes + daemon_reload: yes \ No newline at end of file diff --git a/roles/pkgmgr/meta/main.yml b/roles/pkgmgr/meta/main.yml index bc15b2be..dd6757bf 100644 --- a/roles/pkgmgr/meta/main.yml +++ b/roles/pkgmgr/meta/main.yml @@ -35,3 +35,4 @@ galaxy_info: dependencies: - git - make + - python-yaml diff --git a/roles/python-yaml/README.md b/roles/python-yaml/README.md new file mode 100644 index 00000000..61cc005f --- /dev/null +++ b/roles/python-yaml/README.md @@ -0,0 +1,20 @@ +# Python-Yaml + +## Description + +This Ansible role installs the **python-yaml** package on the target system. It ensures that the Python `yaml` library is available for loading and processing YAML files. + +## Overview + +Optimized for simplicity and idempotency, this role provides: +- Installation of the `python-yaml` package via the Pacman package manager. +- A mechanism to run the installation only once. + +## Purpose + +The purpose of this role is to reliably provide the Python-YAML package so that Python scripts can work with YAML files. + +## Features + +- **YAML Support:** Installs the `python-yaml` package, which supplies the `yaml` library for Python. +- **Idempotency:** Uses a fact to ensure that the installation runs only on the first execution. \ No newline at end of file diff --git a/roles/python-yaml/meta/main.yml b/roles/python-yaml/meta/main.yml new file mode 100644 index 00000000..e19374f7 --- /dev/null +++ b/roles/python-yaml/meta/main.yml @@ -0,0 +1,24 @@ +galaxy_info: + author: "Kevin Veen-Birkenbach" + description: > + Installs the `python-yaml` package to enable YAML support in Python. + license: "CyMaIS NonCommercial License (CNCL)" + license_url: "https://s.veen.world/cncl" + company: | + Kevin Veen-Birkenbach + Consulting & Coaching Solutions + https://www.veen.world + min_ansible_version: "2.9" + platforms: + - name: Archlinux + versions: + - rolling + galaxy_tags: + - python + - yaml + - package + - installation + - automation + repository: "https://s.veen.world/cymais" + issue_tracker_url: "https://s.veen.world/cymaisissues" + documentation: "https://s.veen.world/cymais" diff --git a/roles/python-yaml/tasks/main.yml b/roles/python-yaml/tasks/main.yml new file mode 100644 index 00000000..9bab477f --- /dev/null +++ b/roles/python-yaml/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: python-yaml install + pacman: + name: python-yaml + state: present + when: run_once_python_yaml is not defined + +- name: run the python_yaml tasks once + set_fact: + run_once_python_yaml: true + when: run_once_python_yaml is not defined diff --git a/tasks/plays/01_constructor.yml b/tasks/plays/01_constructor.yml index c4146405..c4090065 100644 --- a/tasks/plays/01_constructor.yml +++ b/tasks/plays/01_constructor.yml @@ -44,7 +44,7 @@ redirect_domain_mappings: "{{ [] | add_redirect_if_group('assets-server', domains | get_domain('assets-server'), domains | get_domain('file-server'), group_names) | - merge_mapping(redirect_domain_mappings, 'source') + merge_mapping(redirect_domain_mappings| default([]), 'source') }}" - name: Set current play redirect domain mappings