Incorrect Output from junos ansible command module

35 views
Skip to first unread message

AK

unread,
Oct 16, 2020, 7:40:38 PM10/16/20
to Ansible Project

Hi Folks, I am trying to display output for junos command “show configuration | compare rollback 1” through ansible however every time I store the data, I see the whole config output. Any ideas? 

Is there another way to get the previously commited data using rollbacks? I am using the new role "junipernetworks.junos.junos" so im not find a way to come up with a way for this. Previous role junos_config had a way but modules have now changed.

Playbook
---
- name: Playbook to check last commit
  hosts: net-junos
  connection: netconf
  gather_facts: no
  roles:
    - junipernetworks.junos

  tasks:
    - name: Check last commit config
      junipernetworks.junos.junos_command:
        commands: "show configuration | compare rollback 1"
      register: result

    - name: Display Output
      debug:
        var: result.stdout_lines

Output

[junos]$ ansible-playbook -i inventory/lab/hosts.ini 19_show_compare_rollback.yml

PLAY [Playbook to configure IP Fabric] *****************************************************************

TASK [Check last commit config] ************************************************************************
ok: [fw-1]

TASK [Display Output] **********************************************************************************
ok: [fw-1] => {
    "result.stdout_lines": [
        [
            "## Last changed: 2020-10-15 16:12:14 UTC",
            "version 20190606.224121_builder.r1033375;",
            "system {",
            "    host-name net-junos;",
            "    root-authentication {",
            "        encrypted-password \"redacted";",
            "    }",
            "    login {",

......... (redacted)

            "routing-instances {",
            "    test {",
            "        instance-type virtual-router;",
            "        routing-options {",
            "            graceful-restart;",
            "        }",
            "        interface reth2.10;",
            "        interface reth2.20;",
            "    }",
            "}"
        ]
    ]
}

PLAY RECAP *********************************************************************************************
net-junos                       : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Arvind Konar

unread,
Oct 16, 2020, 8:18:39 PM10/16/20
to ansible...@googlegroups.com
Figured it out. Connection to be used is network_cli and not netconf for this module.


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/0NgL1JgfUS0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ead6dced-03d7-4d21-82dd-70916d5b6017n%40googlegroups.com.


--

Arvind Konar

Network Engineer

Plenty of Fish

ako...@plentyoffish.com
www.plentyoffish.com
twitter
linkedin
instagram


STRICTLY PERSONAL AND CONFIDENTIAL. This email and any files transmitted with it may contain confidential and proprietary material for the sole use of the intended recipient. Any review or distribution by others is strictly prohibited. If you are not the intended recipient please contact the sender and delete all copies.


Reply all
Reply to author
Forward
0 new messages