HI,
I would like to create a playbook that will send a list of available yum updates in the message body. How do I do that? my play book has two parts. first it collects a list of available packages and then 2nd it sends an email... I would like to include the results from first part in a readable format as message body in my email. Any help or guidance will be appreciated.
```
Here is my playbook.
---
- name: List and return yum update packages
hosts: all,!localhost
tasks:
- name: List available packages and register result to print with debug later
yum:
list: updates
register: result
- name: Print return information from the previous task
debug:
var: result
verbosity: 1
- name: send email
hosts: localhost
tasks:
- name: Sending an e-mail using SMTP server
mail:
host: smtp.domain.local
port: 587
username: "{{ mail_username }}"
password: "{{ mail_password }}"
from: "{{ email_address}}"
to: "{{ recipent }}"
subject: Patch-report
body: Available Patches as of {{ ansible_date_time.date }}
delegate_to: localhost
run_once: true
_______________________________
Thank you
Raza