ansible: Add flag to disable upgrades when updating CI nodes
authorKienan Stewart <kstewart@efficios.com>
Mon, 7 Oct 2024 13:27:17 +0000 (09:27 -0400)
committerKienan Stewart <kstewart@efficios.com>
Mon, 7 Oct 2024 13:27:17 +0000 (09:27 -0400)
This play defaults to "true", since the normal ansible
playbook (`site.yml`) can be used to install new packages and
configuration without running the package upgrades.

Change-Id: Ifcdce209f7cac1cc72ca27e5ad3d3f150793fdfc
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
automation/ansible/playbooks/update-node.yml

index 664b7450b67dc6e3429251965ff2215a6aa6c375..aa90087c72e6d4d43a42b691d7bbddbf1e5c070e 100644 (file)
@@ -3,12 +3,14 @@
   vars:
     - job_wait_to_end: true
     - job_abort: false
+    - upgrade: true
     - wait_for_changes: true
   tasks:
     - name: Initialize variables
       ansible.builtin.set_fact:
         job_wait_to_end: "{{job_wait_to_end}}"
         job_abort: "{{job_abort}}"
+        upgrade: "{{upgrade}}"
         wait_for_changes: "{{wait_for_changes}}"
 
     - name: Disable {{ansible_hostname}} in Jenkins
       delegate_to: localhost
       retries: 3
 
-    - name: Update apt cache
-      when: ansible_os_family == 'Debian'
-      ansible.builtin.apt:
-        state: latest
-        update_cache: true
-        upgrade: yes
+    - 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 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 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
+        - 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:!node_standalone` or similar, then
 # this play errors out trying to find variables for the ci-hosts even if the condition
This page took 0.024733 seconds and 4 git commands to generate.