Selaa lähdekoodia

Rolle linux_updates:
- anpassungen am Mail-Template

ansible 7 vuotta sitten
vanhempi
sitoutus
06c163cd6f

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

@@ -13,6 +13,7 @@
      upgrade: dist
   register: apt_upgrade
   when: ansible_os_family == "Debian"
+  ignore_errors: True
 
 - name: delete old packages
   apt: autoclean=yes
@@ -24,14 +25,20 @@
   register: lsof
   when: ansible_os_family == "Debian"
 
-#- debug: var=apt_autoclean
-#  with_items: 
-#     - apt_autoclean
-#     - apt_upgrade
-#     - lsof
+  #- debug: var=apt_upgrade
+  #  with_items: 
+  #     - apt_autoclean
+  #     - apt_upgrade
+       #   - lsof
+
+## set color green 
+- set_fact:
+    color: "#00CC33"
+    title_status: "successfully"
+  when: apt_upgrade.failed != false
 
 - mail: 
-        subject: "[U] {{ ansible_distribution }} Update Message # Installed updates on host {{ ansible_fqdn }}"
+        subject: "[U] {{ ansible_fqdn }} # updated {{ title_status }}"
         to: update <erdo@ichalsroot.de>
         body: "{{ lookup('template', 'templates/mail_body.j2') }}"
         subtype: html

+ 12 - 1
roles/linux_updates/templates/mail_body.j2

@@ -71,6 +71,12 @@
           border-bottom: 1px solid #CCCCCC;
           margin-top: 15px;
         }
+	div.block {
+	  height: 20px; 
+	  width: 20px; 
+	  background-color: {{ color }}; 
+	  display: inline-block;
+	}
     </style>
 </head>
 
@@ -79,7 +85,12 @@
         <table class="header">
                 <thead>
                         <tr>
-                                <th><h1>{{ ansible_distribution}} Update Message</h1></th>
+				<th>
+					<h1>
+						<div class="block">&nbsp;</div>
+						{{ ansible_distribution}} Update Message
+					</h1>
+				</th>
                         </tr>
                 </thead>
                 <tbody>

+ 4 - 0
roles/linux_updates/vars/main.yml

@@ -0,0 +1,4 @@
+---
+## default for mail template
+color: "#FF0000"
+title_status: "failed"