Ver código fonte

Rolle: linux_update
- Mail template überarbeitet
- apt upgrade 'scharf' geschaltet

erdo_king 7 anos atrás
pai
commit
32e5122665

+ 29 - 13
roles/linux_updates/tasks/main.yml

@@ -1,24 +1,40 @@
----                                                                                                                                                                                      
-- name: updates a server                                                                                                                                                                                                                      
-  #  apt: 
-  #   update_cache: yes
-  #   force: yes
-  #   upgrade: yes
-  shell: cat /tmp/update.txt
-  register: apt_update
+---
+#- name: updates a server
+#  apt: 
+#     update_cache: yes
+#     cache_valid_time: 0
+#  #  shell: cat /tmp/update.txt
+#  register: apt_update
+#  when: ansible_os_family == "Debian"
+
+- name: upgrade a server
+  apt:
+     update_cache: yes
+     upgrade: dist
+  register: apt_upgrade
   when: ansible_os_family == "Debian"
 
-    #- name: upgrade a server
-#  apt: upgrade=dist
+- name: delete old packages
+  apt: autoclean=yes
+  register: apt_autoclean
+  when: ansible_os_family == "Debian"
 
-- debug: var=apt_update
-  #.stdout_lines
+- name: updates a server
+  shell: lsof +L1 -R
+  register: lsof
+  when: ansible_os_family == "Debian"
+
+#- debug: var=apt_autoclean
+#  with_items: 
+#     - apt_autoclean
+#     - apt_upgrade
+#     - lsof
 
-  #- local_action: 
 - mail: 
         subject: "[U] {{ ansible_distribution }} Update Message # Installed updates on host {{ ansible_fqdn }}"
         to: update <erdo@ichalsroot.de>
         body: "{{ lookup('template', 'templates/mail_body.j2') }}"
         subtype: html
   delegate_to: localhost
+  when: ansible_os_family == "Debian"
 

+ 83 - 23
roles/linux_updates/templates/mail_body.j2

@@ -6,42 +6,41 @@
 <meta name="viewport" content="width=600" /> 
 
 <style>
-        table.blueTable {
+        table {
           border: 1px solid #CCCCCC;
           width: 100%;
           text-align: left;
         }
-        table.blueTable td, table.blueTable th {
+        table td, table th {
         #  padding: 3px 3px;
         }
-        table.blueTable tbody td {
+        table tbody td {
           font-size: 13px;
           font-weight: bold;
           color: #666666;
         }
-        table.blueTable td:nth-child(even) {
+        table td:nth-child(even) {
           font-weight: normal;
         }
-        table.blueTable thead {
+        table thead {
           background: #CFCFCF;
           border-bottom: 2px solid #444444;
         }
-        table.blueTable thead th {
+        table thead th {
           font-weight: bold;
           color: #003399;
         }
-        table.blueTable tfoot td {
-          font-size: 14px;
-        }
-        table.blueTable tfoot .links {
-          text-align: right;
+        table.header thead th {
+          background: #FFFFFF;
+        }                                                 }
+        table.header tbody td {
+          background: #CFCFCF;
         }
-        table.blueTable tfoot .links a{
-          display: inline-block;
-          background: #1C6EA4;
-          color: #FFFFFF;
-          padding: 2px 8px;
-          border-radius: 5px;
+        h1 {
+          font-size: 15pt;
+          font-weight: bold;
+          color:#666666;
+          padding-left: 4px;
         }
         h2 {
           font-size: 10pt;
@@ -49,14 +48,36 @@
           border-bottom: 1px solid #CCCCCC;
           margin-top: 15px;
         }
+        h1 {
+          font-size: 15pt;
+          font-weight: bold;
+          color:#666666;
+        }
         </style>
-
 </head>
 
 
 <body>
+        <table class="header">
+                <thead>
+                        <tr>
+                                <th><h1>{{ ansible_distribution}} Update Message</h1></th>
+                        </tr>
+                </thead>
+                <tbody>
+                        <tr>   
+                                <td>[U] {{ ansible_distribution}} Update Message # Installed updates on host {{ ansible_hostname }}</td>
+                        </tr>
+                        <tr>   
+                                <td>{{ ansible_date_time.iso8601 }}</td>
+                                <td>{{ ansible_fqdn }}</td>
+                        </tr>
+                </tbody>
+        </table>
+
+
         <h2>Server &Uuml;bersicht</h2>
-        <table class="blueTable">
+        <table>
                 <thead>
                         <tr>
                                 <th colspan="2">Host Informationen</th>
@@ -89,16 +110,54 @@
         </table>
 
 
+      <h2>Upgrade (Paketaktualisierung) durchf&uuml;hren</h2>
+       <table>
+               <thead>
+                       <tr>
+                               <th colspan="2">apt update &amp;&amp; apt upgrade</th>
+                        </tr>
+                </thead>
+                <tbody>
+                        {% for line in apt_upgrade.stdout_lines %}
+                        <tr>
+                                <td># LOG:</td>
+                                <td>{{ line }}</td>
+                        </tr>  
+                        {% endfor %}
+                </tbody>
+                </tr>
+        </table>
+
+
+       <h2>Veraltete heruntergeladene Archive l&ouml;schen</h2>
+        <table>
+                <thead>
+                        <tr>   
+                                <th colspan="2">apt autoclean</th>
+                        </tr> 
+                </thead>
+                <tbody>
+                        {% for line in apt_autoclean.stdout_lines %}
+                        <tr>
+                                <td># LOG:</td>
+                                <td>{{ line }}</td>
+                        </tr>
+                        {% endfor %}
+                </tbody>
+                </tr>
+        </table>
+
+
 
-        <h2>neue Paketinformationen holen </h2>
-        <table class="blueTable">
+        <h2>Pr&uuml;fen laufender Prozesse</h2>
+        <table> 
                 <thead>
                         <tr>
-                                <th colspan="2">apt-get update</th>
+                                <th colspan="2">lsof +L1 -R</th>
                         </tr>
                 </thead>
                 <tbody>
-                        {% for line in apt_update.stdout_lines %}
+                        {% for line in lsof.stdout_lines %}
                         <tr>
                                 <td># LOG:</td>
                                 <td>{{ line }}</td>
@@ -108,5 +167,6 @@
                 </tr>
         </table>
 
+
 </body>