Jelajahi Sumber

Rolle "linux_updates"
- mail template hinzugefügt

erdo_king 7 tahun lalu
induk
melakukan
19334175ed
2 mengubah file dengan 132 tambahan dan 4 penghapusan
  1. 20 4
      roles/linux_updates/tasks/main.yml
  2. 112 0
      roles/linux_updates/templates/mail_body.j2

+ 20 - 4
roles/linux_updates/tasks/main.yml

@@ -1,8 +1,24 @@
----
-- name: updates a server
-  apt: update_cache=yes
+---                                                                                                                                                                                      
+- name: updates a server                                                                                                                                                                                                                      
+  #  apt: 
+  #   update_cache: yes
+  #   force: yes
+  #   upgrade: yes
+  shell: cat /tmp/update.txt
+  register: apt_update
   when: ansible_os_family == "Debian"
 
-#- name: upgrade a server
+    #- name: upgrade a server
 #  apt: upgrade=dist
 
+- debug: var=apt_update
+  #.stdout_lines
+
+  #- 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
+

+ 112 - 0
roles/linux_updates/templates/mail_body.j2

@@ -0,0 +1,112 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
+<html xmlns="http://www.w3.org/1999/xhtml"> 
+<head> 
+<title></title> 
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" /> 
+<meta name="viewport" content="width=600" /> 
+
+<style>
+        table.blueTable {
+          border: 1px solid #CCCCCC;
+          width: 100%;
+          text-align: left;
+        }
+        table.blueTable td, table.blueTable th {
+        #  padding: 3px 3px;
+        }
+        table.blueTable tbody td {
+          font-size: 13px;
+          font-weight: bold;
+          color: #666666;
+        }
+        table.blueTable td:nth-child(even) {
+          font-weight: normal;
+        }
+        table.blueTable thead {
+          background: #CFCFCF;
+          border-bottom: 2px solid #444444;
+        }
+        table.blueTable thead th {
+          font-weight: bold;
+          color: #003399;
+        }
+        table.blueTable tfoot td {
+          font-size: 14px;
+        }
+        table.blueTable tfoot .links {
+          text-align: right;
+        }
+        table.blueTable tfoot .links a{
+          display: inline-block;
+          background: #1C6EA4;
+          color: #FFFFFF;
+          padding: 2px 8px;
+          border-radius: 5px;
+        }
+        h2 {
+          font-size: 10pt;
+          color: #666666;
+          border-bottom: 1px solid #CCCCCC;
+          margin-top: 15px;
+        }
+        </style>
+
+</head>
+
+
+<body>
+        <h2>Server &Uuml;bersicht</h2>
+        <table class="blueTable">
+                <thead>
+                        <tr>
+                                <th colspan="2">Host Informationen</th>
+                        </tr>
+                </thead>
+                <tbody>
+                        <tr>
+                                <td># Distribution:</td>
+                                <td>{{ ansible_distribution}} {{ansible_distribution_version}} ({{ ansible_distribution_release }})</td>
+                        </tr>
+                        <tr>
+                                <td># Vendor:</td>
+                                <td>{{ ansible_system_vendor }}</td>
+                        </tr>
+                        <tr>
+                                <td># FQDN:</td>
+                                <td>{{ ansible_fqdn }}</td>
+                        </tr>
+                        <tr>
+                                <td># Product:</td>
+                                <td>{{ ansible_product_name }}</td>
+                        </tr>
+                        <tr>
+                                <td># IP-Adressen:</td>
+                                <td>{{ ansible_eth0.ipv4.address }} ({{ ansible_eth0.device }})</td>
+                        </tr>
+
+                </tbody>
+                </tr>
+        </table>
+
+
+
+        <h2>neue Paketinformationen holen </h2>
+        <table class="blueTable">
+                <thead>
+                        <tr>
+                                <th colspan="2">apt-get update</th>
+                        </tr>
+                </thead>
+                <tbody>
+                        {% for line in apt_update.stdout_lines %}
+                        <tr>
+                                <td># LOG:</td>
+                                <td>{{ line }}</td>
+                        </tr>
+                        {% endfor %}
+                </tbody>
+                </tr>
+        </table>
+
+</body>
+