From 21be78c438f59affadb9fb6cf173ebcebf3c4bd0 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Mon, 7 Oct 2024 09:28:17 -0400 Subject: [PATCH] ansible: Add flag to snapshot-rootnode to run package upgrades This defaults to false because the snapshot-rootnode needs to be run anytime any configuration changes are made, and doing package upgrades is not always desired. Change-Id: Id1ab8dcd44c5e7172949bf251252cd6348e1f1c3 Signed-off-by: Kienan Stewart --- .../ansible/playbooks/snapshot-rootnode.yml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/automation/ansible/playbooks/snapshot-rootnode.yml b/automation/ansible/playbooks/snapshot-rootnode.yml index 91809a7..da57122 100644 --- a/automation/ansible/playbooks/snapshot-rootnode.yml +++ b/automation/ansible/playbooks/snapshot-rootnode.yml @@ -8,6 +8,7 @@ # Set to false when taking the first snapshot of a new rootnode - revert_before: true - snapshot_name: 'base-configuration' + - upgrade: false - wait_for_changes: true tasks: - ansible.builtin.set_fact: @@ -16,6 +17,7 @@ revert_before: "{{revert_before}}" snapshot_name: "{{snapshot_name}}" target_rootnode: "{{inventory_hostname}}" + upgrade: "{{upgrade}}" wait_for_changes: "{{wait_for_changes}}" - name: Shutdown and revert @@ -59,6 +61,36 @@ timeout=300 state=started + - when: upgrade + block: + - name: Update apt cache + when: ansible_os_family == 'Debian' + ansible.builtin.apt: + state: latest + update_cache: true + upgrade: yes + + - name: Update dnf + when: ansible_os_family in ['RedHat', 'Rocky'] + ansible.builtin.dnf: + state: latest + update_cache: true + update_only: true + + - name: Update zypper + when: ansible_os_family == 'Suse' + ansible.builtin.zypper: + name: '*' + state: latest + update_cache: true + + - name: Update apk + when: ansible_os_family == 'Alpine' + ansible.builtin.apk: + state: latest + update_cache: true + upgrade: true + # If the playbook isn't run with `-l node_standalone` or `-l ci-rootnode...`, then # this play errors out trying to find variables for the ci-hosts even if the condition # `inventory_hostname in groups.node_standalone` is false. -- 2.34.1