From 4edcb29499c0fbb6763603a6462c63dc75cac54d Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Thu, 23 Oct 2025 10:26:28 +0200 Subject: [PATCH] feat: move tags around --- tasks/main.yaml | 4 +- tasks/reboot.yaml | 1 + tasks/update.yaml | 115 ++++++++++++++++++++++++---------------------- 3 files changed, 62 insertions(+), 58 deletions(-) diff --git a/tasks/main.yaml b/tasks/main.yaml index da54751..b8c48fa 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -2,10 +2,8 @@ # install updates - name: "install updates" - tags: "update" ansible.builtin.include_tasks: "update.yaml" # initiate reboot -- name: "initiate rboot" - tags: "reboot" +- name: "initiate reboot" ansible.builtin.include_tasks: "reboot.yaml" diff --git a/tasks/reboot.yaml b/tasks/reboot.yaml index 7ef2507..8f70dd5 100644 --- a/tasks/reboot.yaml +++ b/tasks/reboot.yaml @@ -2,6 +2,7 @@ # reboot the system - name: "reboot the system" + tags: "reboot" ansible.builtin.reboot: msg: "Reboot initiated by Ansible" reboot_timeout: 120 diff --git a/tasks/update.yaml b/tasks/update.yaml index 7465419..c7df97c 100644 --- a/tasks/update.yaml +++ b/tasks/update.yaml @@ -1,61 +1,66 @@ --- -# install updates - debian -- name: "install updates - debian" - when: 'ansible_os_family == "Debian"' - block: - - # install updates - - name: "install updates - debian" - ansible.builtin.apt: - autoremove: true - update_cache: true - upgrade: "safe" - - # clean cache - - name: "clean cache - debian" - ansible.builtin.apt: - clean: true - - -# install updates - rhel -- name: "install updates - rhel" - when: 'ansible_os_family == "RedHat"' - block: - - # install updates - - name: "install updates - rhel" - ansible.builtin.dnf: - name: "*" - state: "latest" - update_cache: true - - # autoremove - - name: "autoremove unused packages - rhel" - ansible.builtin.dnf: - autoremove: true - - # clean cache - - name: "clean cache - rhel" - ansible.builtin.command: - cmd: "dnf clean all" - changed_when: false - - -# install updates - suse +# install updates - name: "install updates" - when: 'ansible_os_family == "Suse"' + tags: "update" block: - # install updates - - name: "install updates - suse" - community.general.zypper: - name: "*" - state: "latest" - update_cache: true + # install updates - debian + - name: "install updates - debian" + when: 'ansible_os_family == "Debian"' + block: - # clean cache - - name: "clean cache - suse" - ansible.builtin.command: - cmd: "zypper clean --all" - changed_when: false + # install updates + - name: "install updates - debian" + ansible.builtin.apt: + autoremove: true + update_cache: true + upgrade: "safe" + + # clean cache + - name: "clean cache - debian" + ansible.builtin.apt: + clean: true + + + # install updates - rhel + - name: "install updates - rhel" + when: 'ansible_os_family == "RedHat"' + block: + + # install updates + - name: "install updates - rhel" + ansible.builtin.dnf: + name: "*" + state: "latest" + update_cache: true + + # autoremove + - name: "autoremove unused packages - rhel" + ansible.builtin.dnf: + autoremove: true + + # clean cache + - name: "clean cache - rhel" + ansible.builtin.command: + cmd: "dnf clean all" + changed_when: false + + + # install updates - suse + - name: "install updates" + when: 'ansible_os_family == "Suse"' + block: + + # install updates + - name: "install updates - suse" + community.general.zypper: + name: "*" + state: "latest" + update_cache: true + + # clean cache + - name: "clean cache - suse" + ansible.builtin.command: + cmd: "zypper clean --all" + changed_when: false