浏览代码

Added reporting

chagood 9 月之前
父节点
当前提交
4bd5ad510a
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26 0
      Playbooks/Updates_with_reporting.yaml

+ 26 - 0
Playbooks/Updates_with_reporting.yaml

@@ -0,0 +1,26 @@
+---
+- hosts: all
+  gather_facts: yes
+  become: yes
+
+  tasks:
+    - name: Perform a dist-upgrade.
+      ansible.builtin.apt:
+        update_cache: yes      
+        upgrade: dist
+      register: apt_result
+      ignore_errors: yes
+
+    - name: Check if a reboot is required.
+      ansible.builtin.stat:
+        path: /var/run/reboot-required
+        get_md5: no
+      register: reboot_required_file
+
+    - name: Reboot the server (if required).
+      ansible.builtin.reboot:
+      when: reboot_required_file.stat.exists == true
+
+    - name: Remove dependencies that are no longer required.
+      ansible.builtin.apt:
+        autoremove: yes