-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
028e9b1
commit 1711f1e
Showing
5 changed files
with
108 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,9 +68,10 @@ updates_categories: | |
# Automatically rolls back to snapshot in case of an error | ||
posthooks_rollback: true | ||
# Automatically removes snapshot after update installation | ||
posthooks_autoremove: true | ||
posthooks_autoremove: false | ||
|
||
# Enables Mail delivery after playbook run | ||
mail_enabled: true | ||
mail_enabled: false | ||
# Examples for the supported mail delivery settings: https://docs.ansible.com/ansible/latest/collections/community/general/mail_module.html | ||
mail: | ||
host: mail.local | ||
|
@@ -80,3 +81,6 @@ mail: | |
password: {} | ||
from: "[email protected] (Ansible No-Reply)" | ||
to: User <[email protected]> | ||
|
||
webhook_enabled: false | ||
webhook_url: 'https://outlook.office.com/webhook/your_webhook_url' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,23 +15,13 @@ posthooks_autoremove: false | |
mail_enabled: false | ||
mail_status_error: | ||
msg: No status available | ||
|
||
mail_success_subject: Patching of {{ inventory_hostname }} succeded | ||
mail_success_message: | | ||
{{ inventory_hostname }} was successfully patched! | ||
This is the status: | ||
{{ win_update | default(mail_status_error) | to_nice_json }} | ||
mail_failure_subject: Patching of {{ inventory_hostname }} failed | ||
mail_failure_message: | | ||
{% if posthooks_rollback == true %} | ||
{% set mail_msg = "As a result, the VM was reverted to the snapshot." %} | ||
mail_subject: | | ||
{% if update_successful | default(true) == false %} | ||
Patching of {{ inventory_hostname }} failed | ||
{% else %} | ||
{% set mail_msg = "The VM was not changed, but it is strongly advised to roll back to the last Snapshot" %} | ||
Patching of {{ inventory_hostname }} succeded | ||
{% endif %} | ||
{{ inventory_hostname }} failed to install updates. {{ mail_msg }} | ||
This is the status of Windows Update: | ||
{{ win_update | default(mail_status_error) | to_nice_json }} | ||
mail_message: "{{ lookup('template', 'mail_message.j2') }}" | ||
|
||
mail: | ||
host: mail.local | ||
|
@@ -41,3 +31,10 @@ mail: | |
password: {} | ||
from: "[email protected] (Ansible No-Reply)" | ||
to: User <[email protected]> | ||
|
||
|
||
webhook_enabled: false | ||
webhook_status_error: | ||
msg: No status available | ||
webhook_url: 'https://outlook.office.com/webhook/your_webhook_url' | ||
message: "{{ lookup('template', 'webhook_message.j2') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% if update_successful | default(true) == false %} | ||
{% if posthooks_rollback == true %} | ||
{{ inventory_hostname }} failed to install updates. As a result, the VM was reverted to the snapshot. | ||
{% else %} | ||
{{ inventory_hostname }} failed to install updates but the VM was not rolled back, please make sure all Services still work as expected and roll back if needed. | ||
{% endif %} | ||
{% else %} | ||
{{ inventory_hostname }} was successfully patched! Please make sure all Services still work as expected. | ||
{% endif %} | ||
This is the log of the Windows Update module: | ||
{{ win_update | default(mail_status_error) | to_nice_json }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{% if update_successful | default(true) == false %} | ||
{% if posthooks_rollback == true %} | ||
{% set header_msg = "was reverted to the Snapshot" %} | ||
{% else %} | ||
{% set header_msg = "failed to patch" %} | ||
{% endif %} | ||
{% else %} | ||
{% set header_msg = "was sucessfully patched" %} | ||
{% endif %} | ||
{ | ||
"type": "message", | ||
"attachments": [ | ||
{ | ||
"contentType": "application/vnd.microsoft.card.adaptive", | ||
"contentUrl": null, | ||
"content": { | ||
"type": "AdaptiveCard", | ||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json", | ||
"version": "1.2", | ||
"body": [ | ||
{ | ||
"type": "TextBlock", | ||
"weight": "Bolder", | ||
"size": "Medium", | ||
"style": "heading", | ||
"wrap": true, | ||
"text": "({{ inventory_hostname }}) System {{ header_msg }}" | ||
}, | ||
{ | ||
"text": "{{ '%Y-%m-%d %H:%M:%S' | strftime }}", | ||
"type": "TextBlock", | ||
"spacing": "Small", | ||
"size": "Small" | ||
}, | ||
{ | ||
"text": "Ansible installed {{ win_update.installed_update_count }} Updates.", | ||
"type": "TextBlock" | ||
}, | ||
{ | ||
"type": "FactSet", | ||
"facts": [ | ||
{ | ||
"title": "Updates Found", | ||
"value": "{{ win_update.found_update_count }}" | ||
}, | ||
{ | ||
"title": "Updates filtered", | ||
"value": "{{ win_update.filtered_updates | to_nice_json | replace('"','\\"') }}" | ||
}, | ||
{ | ||
"title": "Updates Installed", | ||
"value": "{{ win_update.installed_update_count }}" | ||
}, | ||
{ | ||
"title": "Updates Failed", | ||
"value": "{{ win_update.failed_update_count }}" | ||
}, | ||
{ | ||
"title": "Full Status", | ||
"value": "{{ win_update | to_nice_json | replace('"','\\"') }}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |