ansible: Add flag to snapshot-rootnode to run package upgrades master
authorKienan Stewart <kstewart@efficios.com>
Mon, 7 Oct 2024 13:28:17 +0000 (09:28 -0400)
committerKienan Stewart <kstewart@efficios.com>
Mon, 7 Oct 2024 13:28:17 +0000 (09:28 -0400)
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 <kstewart@efficios.com>
automation/ansible/playbooks/snapshot-rootnode.yml

index 91809a710f0b348452f1724933a262dd91b46250..da57122b419246b57d83120a51c5475d5c5e68c2 100644 (file)
@@ -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
                     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.
This page took 0.023867 seconds and 4 git commands to generate.