ansible/roles/common/tasks/main.yml in subspace-2.4.2 vs ansible/roles/common/tasks/main.yml in subspace-2.5

- old
+ new

@@ -156,10 +156,46 @@ when: send_stats == true and stats_url is defined and stats_api_key is defined tags: - maintenance - stats + - name: Get unattended security updates + shell: + cmd: cat /var/log/unattended-upgrades/unattended-upgrades.log | grep "Packages that will be upgraded:" | grep $(date '+%Y-%m') | cut -d " " -f 9- | wc -w + register: out + tags: + - maintenance + - stats + + - name: get current date as month + shell: + cmd: date '+%Y-%m' + register: current_month + tags: + - maintenance + - stats + + - name: Save unattended updates to /opt/subspace/updates.log + lineinfile: + path: /opt/subspace/updates.log + line: "[{{current_month.stdout}}]\n{{ out.stdout }} unattended security updates" + insertafter: EOF + create: yes + become: true + tags: + - maintenance + - stats + when: out.stdout != "0" + + - name: Update unattended-upgrades.log + shell: + cmd: perl -i -pe 's/Packages that will be upgraded:/Packages already upgraded and logged in Subspace:/smg' /var/log/unattended-upgrades/unattended-upgrades.log + become: true + tags: + - maintenance + - stats + - name: Get os_security_upgrades stats shell: cmd: | sed -n "/$(date '+%Y-%m')/,+2p" updates.log | # Groups of lines from the current month grep 'security' | # Only lines matching 'security' @@ -251,10 +287,10 @@ become: true tags: - maintenance - name: Grab OS version - shell: uname --kernel-release + shell: uname -rv register: stats_os_version when: send_stats == true and stats_url is defined and stats_api_key is defined tags: - maintenance - stats