looking for optimizations

Hey all, I am currently on the older 1.7 (looking to upgrade shortly). I have a question in regards to optimization of tasks.
I have a role where I collect some output from other task actions and im trying to use them in the mail module.
Unfortunately if I try to format subject: to how I want the output to look, not all the data is represented correctly in the body of the mail.

I spent some time looking around yesterday and I know that there is a possibility of using a template, but I got myself going with the following.

  • name: Distributing files
    synchronize: src=“{{streams_path}}/” dest=“{{prod_config}}/” rsync_opts=“–exclude=scripts/”
    register: sync_out

  • debug: var=sync_out

`

  • set_fact:
    email1: “The following files have been distributed to the following DCS servers: \n\n”

  • set_fact:
    email2: “{{play_hosts}}”

  • set_fact:
    email3: “\n\n”

  • set_fact:
    email4: “{{sync_out.msg | regex_replace('.* ')}}”
    run_once: true
    “{{sync_out.msg | regex_replace('.* ')}}”
    `

  • name: email
    local_action:
    mail
    subject=“**DCS Streams distribution”
    body=“{{email1}}{{email2}}{{email3}}{{email4}}”
    from="test@foo.com"
    to=“{{mailto}}”
    run_once: true

As mentioned, this gets me what I need to see in the body, but it seem excessive to me? was trying to combine everything into a multiline var but the vars “{{play_hosts}}” and “{{sync_out.msg | regex_replace('.* ')}}” were not being printed correctly as they are lists.

Thanks in advance for any comments…