I am trying to send a mail via ansible yaml that looks similar as below. The requirement is to send this email a week ahead of the patching. I can schedule it in cron, but I need to send an email 1 week prior and put the actual date of the reboot into the message text.
I changed the email ID. I am looking for the date format in the body.
---
- name: sample mail
mail:
to:
- Recipients
- Pruds <[email protected]>
subject: Ansible-test-mail for server {{ ansible_hostname }}
body: ' Hello Team,
The server {{ ansible_hostname }} will be patched and rebooted on `expr $`date '+%d'` + 7`, `date '+%b'`,`date '+%Y'`. Please be noted.
Regards,
Unix Admins via Ansible
{{ ansible_hostname }}'