# Create a playbook for pre-patching notification email

**URL:** <https://forum.ansible.com/t/create-a-playbook-for-pre-patching-notification-email/36738>\
**Category:** Ansible Project\
**Created:** [June 15, 2022, 3:27am UTC](https://forum.ansible.com/t/create-a-playbook-for-pre-patching-notification-email/36738 "2022-06-15T03:27:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anirban\_Das](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@Anirban\_Das](https://forum.ansible.com/u/Anirban_Das)\
**Post date:** [June 15, 2022, 3:27am UTC](https://forum.ansible.com/t/create-a-playbook-for-pre-patching-notification-email/36738/1 "2022-06-15T03:27:15Z")

</div>

Hi Team,

I need a help to create a playbook for pre-patching notification email. I have given sample set of info which should be in subject line. Also, to,cc would be changeable according to App Name.

Can anyone pls guide how to set up all those things

Subject Line: CHG No - {{ Asset Name }} {{ App Name }} {{Environment }} OS patching on Linux Servers - {{ month }} 2022

Body:

Hi All,  
We are planning to perform the patching on {{App name }} {{ Environment }} Linux Servers in the below mentioned window. This is just a head’s up mail. We will send the notification mail one day prior to patching.

**Scheduled window:** (10th June 2022 to 10th June 2022 ).

Regards,

Ani

---

<div class="post-metadata">

**Author:** ![skratbag](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/skratbag/32/4836_2.png) [@skratbag](https://forum.ansible.com/u/skratbag)\
**Post date:** [June 15, 2022, 3:31am UTC](https://forum.ansible.com/t/create-a-playbook-for-pre-patching-notification-email/36738/2 "2022-06-15T03:31:43Z")

</div>

I have used [https://docs.ansible.com/ansible/latest/collections/community/general/mail\_module.html](https://docs.ansible.com/ansible/latest/collections/community/general/mail_module.html) which is part of the community collection. It works well. I use it for mailing at the end of provisioning runs and also for patching mails.

Regards  
David

---

<div class="post-metadata">

**Author:** ![hugonz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hugonz/32/503_2.png) [@hugonz](https://forum.ansible.com/u/hugonz)\
**Post date:** [June 15, 2022, 6:02am UTC](https://forum.ansible.com/t/create-a-playbook-for-pre-patching-notification-email/36738/3 "2022-06-15T06:02:35Z")

</div>

> I need a help to create a playbook for pre-patching notification email. I have given sample set of info which should be in subject line. Also, to,cc would be changeable according to App Name.
> 
> Can anyone pls guide how to set up all those things

Take a look at [https://docs.ansible.com/ansible/latest/collections/community/general/mail\_module.html](https://docs.ansible.com/ansible/latest/collections/community/general/mail_module.html) community.general.mail. It’s 2022, so you shouldn’t just try email from localhost, but get a proper mail server and authenticate. There’s resources out there on how to integrate a gmail server.

As far as templating goes, either bring in a template with “{{ lookup(‘template’, ‘mytemplate.yml’ }}” or simple inline templating will do for the body and subject.
