ansible: modernize dist-upgrade playbook
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 9 Aug 2024 18:02:32 +0000 (14:02 -0400)
committerMichael Jeanson <mjeanson@efficios.com>
Wed, 14 Aug 2024 17:57:50 +0000 (13:57 -0400)
Use ansible.builtin.apt in a single operation.

Change-Id: Iaccd7a5aaa90fdfd5bb68ee16ef092ea1132b830
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
automation/ansible/playbooks/dist-upgrade.yml

index 57d011da6942571aeaddf00591096829b3fa341e..9d01aa16126d174c9e9745daf9c809e9731b7fa3 100644 (file)
@@ -1,5 +1,5 @@
 ---
-- name: Dist upgrade and optional reboot
+- name: "Dist upgrade and optional reboot"
   hosts: all
   vars:
     restart: 'no'
     private: no
 
   tasks:
-   - name: apt-get update
-     apt: update_cache=yes cache_valid_time=3600
+   - name: "apt update && apt dist-upgrade && apt clean && apt autoremove --purge"
+     ansible.builtin.apt:
+       update_cache: yes
+       cache_valid_time: 3600
+       upgrade: dist
+       clean: yes
+       autoremove: yes
+       purge: yes
 
-   - name: apt-get dist-upgrade
-     apt: upgrade=dist
-
-   - name: apt-get autoremove
-     command:
-       cmd: apt-get -y --purge autoremove
-       warn: false
-     register: autoremove_output
-     changed_when: "'The following packages will be REMOVED' in autoremove_output.stdout"
-
-   - name: reboot server
+   - name: "Reboot server"
      command: /sbin/reboot
      async: 0
      poll: 0
This page took 0.024366 seconds and 4 git commands to generate.