I tried stuff like that before using a block or multiline approach for the body attribute:
https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines Maybe you can concatenate the lines of the command output in a previous step using '\n' as EoL and save it into a variable. Then you can use that variable as part of the body. El viernes, 28 de enero de 2022 a la(s) 20:59:14 UTC-3, [email protected] escribió: > 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 > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/07f6333a-81d4-4842-80f0-510369f9f88en%40googlegroups.com.
