0

I am running a playbook to display output correctly and have set the yaml callback plugin in ansible.cfg

ansible-playbook -i inventory syslog_new.yml --check

      - name: Juniper SRX Compliance checks
        hosts: juniper
        gather_facts: false
        tasks:
         - name: Syslog server check
             junos_config:
                 src: /home/gefelas/ansible_junos/files/syslog_config.txt
             diff: true
             register: junos_output
         - debug:
             msg: Syslog server check - This check has failed with the following output({{ junos_output.diff.prepared }})
            when: junos_output.changed
         - debug:
             msg: Syslog server check - This check has passed with the following output({{ junos_output.diff.prepared }})
            when: not junos_output.changed

The result gives

     TASK [debug] ***********************************************************************************************************************************************
     ok: [172.16.203.121] => 
     msg: |-
     Syslog server check - This check has failed with the following  output([edit system syslog host 192.168.100.70]
      +     interactive-commands any;
          [edit system syslog host 192.168.100.70]
      +    facility-override local1;
      +    log-prefix firewall;
      +    source-address 172.16.203.121;
      +    explicit-priority;
        [ edit system syslog]
      +    file messages {
      +        any critical;
      +        authorization info;
      +    }
      +    file default-log-messages {
      +        structured-data;
      +    }
      +    file sessions {
      +        user info;
      +    }
      +    file interactive-commands {
      +        interactive-commands error;
      +    })

How can I turn it to something like this ?

How can I turn it to something like this ?

   TASK [debug] ***********************************************************************************************************************************************
    ok: [172.16.203.121] => 
    msg: |-
    Syslog server check - This check has failed with the following output

      set system syslog archive size 300000
      set system syslog archive files 3
      set system syslog archive world-readable
      set system syslog user * any emergency
      set system syslog host 192.168.100.70 any any
      set system syslog host 192.168.100.70 interactive-commands any
      set system syslog host 192.168.100.70 facility-override local1
      set system syslog host 192.168.100.70 log-prefix firewall
      set system syslog host 192.168.100.70 source-address "172.16.203.121"
      set system syslog host 192.168.100.70 explicit-priority
      set system syslog file messages any critical
      set system syslog file messages authorization info
      set system syslog file default-log-messages structured-data
      set system syslog file sessions user info
      set system syslog file interactive-commands interactive-commands error
tlo
  • 1,571
  • 1
  • 25
  • 38
user409817
  • 21
  • 6
  • 1
    It is unclear what you are asking, there's no question in this text. See [here](https://stackoverflow.com/help/minimal-reproducible-example) for how to ask a good question. – asm Jun 24 '20 at 12:46
  • @ asm . The question is how do I turn it into something readable – user409817 Jun 24 '20 at 13:25
  • 1
    Both the outputs shared looks completely different. You can have a look at this. https://stackoverflow.com/questions/50009505/ansible-stdout-formatting/50017860 – Shubham Vaishnav Jun 24 '20 at 15:22

0 Answers0