From 213b74ff84edd641977fe0a60d00a91e9d2c4769 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 1 Apr 2025 17:33:19 +0200 Subject: [PATCH] Solved package-manager bugs --- main.py | 9 ++++++--- roles/backup-directory-validator/tasks/main.yml | 2 +- roles/backup-docker-to-local/tasks/main.yml | 2 +- roles/cleanup-failed-docker-backups/tasks/main.yml | 2 +- roles/package-manager/tasks/main.yml | 9 ++++++++- .../package-manager/{files => templates}/config.yaml.j2 | 0 roles/package-manager/vars/main.yml | 3 --- roles/system-btrfs-auto-balancer/meta/main.yml | 2 +- roles/system-btrfs-auto-balancer/tasks/main.yml | 4 ++-- .../templates/system-btrfs-auto-balancer.service.j2 | 2 +- roles/system-swapfile/tasks/main.yml | 2 +- 11 files changed, 22 insertions(+), 15 deletions(-) rename roles/package-manager/{files => templates}/config.yaml.j2 (100%) diff --git a/main.py b/main.py index 1cbd80ab..207714b7 100755 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ def run_ansible_vault(action, filename, password_file): cmd = ["ansible-vault", action, filename, "--vault-password-file", password_file] subprocess.run(cmd, check=True) -def run_ansible_playbook(inventory:str, playbook:str, modes:[bool], limit:str=None, password_file:str=None, verbose:bool=False): +def run_ansible_playbook(inventory: str, playbook: str, modes: dict, limit: str = None, password_file: str = None, verbose: int = 0): """Execute an ansible-playbook command with optional parameters.""" cmd = ["ansible-playbook", "-i", inventory, playbook] @@ -28,7 +28,8 @@ def run_ansible_playbook(inventory:str, playbook:str, modes:[bool], limit:str=No cmd.extend(["--ask-vault-pass"]) if verbose: - cmd.append("-v") + # Append a single flag with multiple "v"s (e.g. -vvv) + cmd.append("-" + "v" * verbose) subprocess.run(cmd, check=True) @@ -59,7 +60,9 @@ def main(): playbook_parser.add_argument("--cleanup", action="store_true", help="Enable cleanup mode") playbook_parser.add_argument("--debug", action="store_true", help="Enable debugging output") playbook_parser.add_argument("--password-file", help="Path to the Vault password file") - playbook_parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output") + playbook_parser.add_argument("-v", "--verbose", action="count", default=0, + help=("Increase verbosity. This option can be specified multiple times " + "to increase the verbosity level (e.g., -vvv for more detailed debug output).")) args = parser.parse_args() diff --git a/roles/backup-directory-validator/tasks/main.yml b/roles/backup-directory-validator/tasks/main.yml index e2afefad..87ed8231 100644 --- a/roles/backup-directory-validator/tasks/main.yml +++ b/roles/backup-directory-validator/tasks/main.yml @@ -1,6 +1,6 @@ - name: install directory-validator command: - cmd: "pkgmgr install directory-validator" + cmd: "pkgmgr install directory-validator --clone-mode https" when: run_once_backup_directory_validator is not defined - name: run the backup_directory_validator tasks once diff --git a/roles/backup-docker-to-local/tasks/main.yml b/roles/backup-docker-to-local/tasks/main.yml index 9b321ed6..a2bb36b2 100644 --- a/roles/backup-docker-to-local/tasks/main.yml +++ b/roles/backup-docker-to-local/tasks/main.yml @@ -1,6 +1,6 @@ - name: install backup-docker-to-local command: - cmd: "pkgmgr install backup-docker-to-local" + cmd: "pkgmgr install backup-docker-to-local --clone-mode https" when: run_once_backup_docker_to_local is not defined - name: Retrieve backup-docker-to-local path from pkgmgr diff --git a/roles/cleanup-failed-docker-backups/tasks/main.yml b/roles/cleanup-failed-docker-backups/tasks/main.yml index 79b9df85..e4943201 100644 --- a/roles/cleanup-failed-docker-backups/tasks/main.yml +++ b/roles/cleanup-failed-docker-backups/tasks/main.yml @@ -1,6 +1,6 @@ - name: install cleanup-failed-docker-backups command: - cmd: "pkgmgr install cleanup-failed-docker-backups" + cmd: "pkgmgr install cleanup-failed-docker-backups --clone-mode https" when: run_once_cleanup_failed_docker_backups is not defined - name: Retrieve backup-docker-to-local path from pkgmgr diff --git a/roles/package-manager/tasks/main.yml b/roles/package-manager/tasks/main.yml index 9a741051..0e62edc2 100644 --- a/roles/package-manager/tasks/main.yml +++ b/roles/package-manager/tasks/main.yml @@ -1,4 +1,11 @@ --- +- name: Ensure GitHub host key is in known_hosts + known_hosts: + path: "~/.ssh/known_hosts" + name: github.com + key: "{{ lookup('pipe', 'ssh-keyscan -t ed25519 github.com | grep -v \"^#\"') }}" + become: yes + - name: Create installation directory for Kevin's Package Manager file: path: "{{ pkgmgr_install_path }}" @@ -31,7 +38,7 @@ when: run_once_package_manager is not defined - name: Run the Package Manager install command to create an alias for Kevins package manager - command: "{{ pkgmgr_install_command }}" + command: "make setup" args: chdir: "{{ pkgmgr_install_path }}" become: yes diff --git a/roles/package-manager/files/config.yaml.j2 b/roles/package-manager/templates/config.yaml.j2 similarity index 100% rename from roles/package-manager/files/config.yaml.j2 rename to roles/package-manager/templates/config.yaml.j2 diff --git a/roles/package-manager/vars/main.yml b/roles/package-manager/vars/main.yml index eb5a7e08..63890c4d 100644 --- a/roles/package-manager/vars/main.yml +++ b/roles/package-manager/vars/main.yml @@ -15,6 +15,3 @@ pkgmgr_config_path: "{{pkgmgr_install_path}}/config/config.yaml" # The directory where executable aliases will be installed (ensure it's in your PATH) binaries_directory: "/usr/local/bin" - -# The command to run to install/update the Package Manager's aliases -pkgmgr_install_command: "./main.py install pkgmgr" diff --git a/roles/system-btrfs-auto-balancer/meta/main.yml b/roles/system-btrfs-auto-balancer/meta/main.yml index 655e04c3..422de781 100644 --- a/roles/system-btrfs-auto-balancer/meta/main.yml +++ b/roles/system-btrfs-auto-balancer/meta/main.yml @@ -22,5 +22,5 @@ galaxy_info: issue_tracker_url: "https://s.veen.world/cymaisissues" documentation: "https://s.veen.world/cymais" dependencies: - - git + - package-manager - systemd-notifier diff --git a/roles/system-btrfs-auto-balancer/tasks/main.yml b/roles/system-btrfs-auto-balancer/tasks/main.yml index 9195d6dc..f912ed9e 100644 --- a/roles/system-btrfs-auto-balancer/tasks/main.yml +++ b/roles/system-btrfs-auto-balancer/tasks/main.yml @@ -1,6 +1,6 @@ -- name: install auto-btrfs-balancer +- name: install btrfs-auto-balancer command: - cmd: "pkgmgr install auto-btrfs-balancer" + cmd: "pkgmgr install btrfs-auto-balancer --clone-mode https" when: run_once_system_btrfs_auto_balancer is not defined - name: configure system-btrfs-auto-balancer.cymais.service diff --git a/roles/system-btrfs-auto-balancer/templates/system-btrfs-auto-balancer.service.j2 b/roles/system-btrfs-auto-balancer/templates/system-btrfs-auto-balancer.service.j2 index e2e0098a..a5a78e29 100644 --- a/roles/system-btrfs-auto-balancer/templates/system-btrfs-auto-balancer.service.j2 +++ b/roles/system-btrfs-auto-balancer/templates/system-btrfs-auto-balancer.service.j2 @@ -4,4 +4,4 @@ OnFailure=systemd-notifier.cymais@%n.service [Service] Type=oneshot -ExecStart=/bin/sh -c 'auto-btrfs-balancer 90 10' \ No newline at end of file +ExecStart=/bin/sh -c 'btrfs-auto-balancer 90 10' \ No newline at end of file diff --git a/roles/system-swapfile/tasks/main.yml b/roles/system-swapfile/tasks/main.yml index f48d2e91..45348b07 100644 --- a/roles/system-swapfile/tasks/main.yml +++ b/roles/system-swapfile/tasks/main.yml @@ -1,6 +1,6 @@ - name: install swap-forge command: - cmd: "pkgmgr install backup-docker-to-local" + cmd: "pkgmgr install backup-docker-to-local --clone-mode https" become: true - name: Execute create swapfile script