Hello!

I have tried various ways to get my output to email in a readable format, 
with newlines, but ansible strips them off everytime.  Its just a few shell 
commands i am testing.  I've tried a for loop, with items, replace, etc.  
My email output is all on one-line like so:

"- ' 12:23:27 up 64 days, 1:36, 2 users, load average: 0.21, 0.08, 0.02' - 
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT - 'dbsxxx pts/0 ho-it-dbsxxx-dt 
Tue08 19:39m 0.16s 0.30s sshd: dbsxxxx [priv]' - root pts/1 
ho-lx-ansible01. 12:23 0.00s 0.10s 0.00s /usr/bin/w - Filesystem Size Used 
Avail Use% Mounted on - devtmpfs 11G 0 11G 0% /dev - tmpfs 11G 0 11G 0% 
/dev/shm - tmpfs 11G 1.1G 9.1G 11% /run - tmpfs 11G 0 11G 0% /sys/fs/cgroup 
- /dev/mapper/rootvg-root 46G 28G 19G 61% / - /dev/mapper/rootvg-home 10G 
33M 10G 1% /home - /dev/sda1 1.1G 383M 656M 37% /boot - 
/dev/mapper/satvg-satlv01 503G 408G 96G 82% /var/satellite - 
/dev/mapper/oravg-oralv01 142G 41G 102G 29% /opt/oracle - tmpfs 2.1G 0 2.1G 
0% /run/user/0 - tmpfs 2.1G 0 2.1G 0% /run/user/1922732921 "

 my yaml code is:

- name: DF + UPTIME PLAYBOOK
  hosts: "*"
  gather_facts: false

  tasks:
    - shell: |
        /usr/bin/w
        /usr/bin/df -h
      register: dfu

    - debug: var=dfu.stdout_lines

    - name: mail result
      community.general.mail:
        sender: r...@ho-lx-ansible.xxxxxx.com
        host: internal-smtp.xxxxxx.com
        subtype: html
        to: 'dbsm...@xxxxxx.com'
        subject: test
        body: <h3> "{{ dfu.stdout_lines | to_nice_yaml(indent=4) }}" </h3>
...

How do I tell ansible to output in a email format like the way I see it 
from the debug output on my screen?

ok: [ho-lx-sys-olm01] =>
  dfu.stdout_lines:
  - ' 12:23:27 up 64 days,  1:36,  2 users,  load average: 0.21, 0.08, 0.02'
  - USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
  - 'dbsmith  pts/0    ho-it-dbxxx-dt Tue08   19:39m  0.16s  0.30s sshd: 
dbsxxx [priv]'
  - root     pts/1    ho-lx-ansible01. 12:23    0.00s  0.10s  0.00s 
/usr/bin/w
  - Filesystem                 Size  Used Avail Use% Mounted on
  - devtmpfs                    11G     0   11G   0% /dev
  - tmpfs                       11G     0   11G   0% /dev/shm
  - tmpfs                       11G  1.1G  9.1G  11% /run
  - tmpfs                       11G     0   11G   0% /sys/fs/cgroup
  - /dev/mapper/rootvg-root     46G   28G   19G  61% /
  - /dev/mapper/rootvg-home     10G   33M   10G   1% /home
  - /dev/sda1                  1.1G  383M  656M  37% /boot
  - /dev/mapper/satvg-satlv01  503G  408G   96G  82% /var/satellite
  - /dev/mapper/oravg-oralv01  142G   41G  102G  29% /opt/oracle
  - tmpfs                      2.1G     0  2.1G   0% /run/user/0
  - tmpfs                      2.1G     0  2.1G   0% /run/user/1922732921

thank you!

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8da10a36-2935-4c78-84f0-aea20a4c3bb3n%40googlegroups.com.

Reply via email to