Need help from the output: Below line from the output need to be printed line by line without \n..plz help..code and actual output pasted with this post
"msg": "19:19:11.445 UTC Thu Jul 07 2022\n1657235951 \n1657235051 \n19:04:11 EDT Thu Jul 07 2022\n2022 Jul 07 19:04:11\n"
---
- name: Cisco NXOS
hosts: all
connection: network_cli
gather_facts: false
vars:
- cmdlist1: sh clock
- ansible_python_interpreter: /usr/bin/python3
- ansible_network_os: nxos
- cmdlist2: sh logging | include 2/3
tasks:
- name: Execute command
nxos_command:
commands: "{{ cmdlist1 }}"
register: output
- set_fact:
arr: "{{ output.stdout_lines[0][1] }}"
- debug:
msg: |
{{ arr | trim }}
{{ t1 }}
{{ t2 }}
{{ t3 }}
{{ t4 }}
# msg: "{{ msg.split('\n') }}"
vars:
t1: "{{ (arr|to_datetime('%H:%M:%S.%f %Z %a %b %d %Y')).strftime('%s') }}"
t2: "{{ t1|int - 15 * 60 }}"
t3: "{{ '%H:%M:%S %Z %a %b %d %Y'|strftime(t2) }}"
t4: "{{ '%Y %b %d %H:%M:%S' | strftime(t2) }}"
================
OUTPUT
[LABPC@lab-jump-host dow]$ ansible-playbook interfaceflappingdup.yml -i inventory1.txt --limit nxos --verbose
Using /etc/ansible/ansible.cfg as config file
PLAY [Cisco NXOS] ******************************************************************************************************************************************************************************************
TASK [Execute command] *************************************************************************************************************************************************************************************
ok: [nxos] => {"changed": false, "stdout": ["Time source is NTP\n19:19:11.445 UTC Thu Jul 07 2022"], "stdout_lines": [["Time source is NTP", "19:19:11.445 UTC Thu Jul 07 2022"]]}
TASK [set_fact] ********************************************************************************************************************************************************************************************
ok: [nxos] => {"ansible_facts": {"arr": "19:19:11.445 UTC Thu Jul 07 2022"}, "changed": false}
TASK [debug] ***********************************************************************************************************************************************************************************************
ok: [nxos] => {
"msg": "19:19:11.445 UTC Thu Jul 07 2022\n1657235951 \n1657235051 \n19:04:11 EDT Thu Jul 07 2022\n2022 Jul 07 19:04:11\n"
}
PLAY RECAP *************************************************************************************************************************************************************************************************
nxos : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0