Logging to readable format

Hi. I have a very basic cisco IOS playbook i’m working on and when I log the output to a file I cannot read the format. I read a few threads that mention enabling a callback option in the ansible.cfg but that does not seem to work. Does anyone know how I can accomplish logging to a readable text?

Hi. I have a very basic cisco IOS playbook i'm working on and when I log the output to a file I cannot read the format.
I read a few threads that mention enabling a callback option in the ansible.cfg but that does not seem to work. Does
anyone know how I can accomplish logging to a readable text?

Ansible stringifies the list object output1.stdout_lines, but you want to print each element of this list to line
in the file.

Using "{{ output1.stdout_lines | join('\n') }}" should do the trick.

Regards
          Racke

Hi Stefan,

Thanks for the reply. Unfortunately though it doesn’t look like that worked. I replaced the below line with the entry you provided but it’s still printing in a bad format

copy: content=“{{ output1.stdout_lines | join(‘\n’) }}”

Any other ideas?

Anyone have any thoughts on this?

I was able to resolve this finding the below thread. In my case I had to alter the config slightly to the below. This was to merge the text together no space and eliminate “_lines”

  • name: print result
    debug:
    var: output1.stdout_lines

  • name: copy output to file

copy: content=“{{output1.stdout|join(“\n”)}}” dest=/home/userfolder/ansible/cisco/logs/{{ inventory_hostname }}.txt

https://groups.google.com/forum/#!topic/ansible-project/4cJ7ho8uiAA