Skip to content

junos_get_facts: On a dual RE, junos_get_facts module fails after a RE switchover #4

@mamathac

Description

@mamathac

Module: junos_get_facts
Host Model: mx480.

Steps to reproduce:

  1. On a dual RE router, run an ansible playbook which consists of below code.
  2. Verify that the playbook results for Get Junos Facts is fine.
  3. Now issue an RE switchover and wait for the device to restore master/backup RE.
  4. Run the playbook again after the switchover. Shows below error.

Playbook:

  • name: Junos OS version
    hosts: all
    connection: local
    gather_facts: no

    tasks:

    • include: task_check_nc
    • name: Get Junos Facts
      junos_get_facts:
      host={{ inventory_hostname }}
      register: junos

Playbook result when re0 is the master and re1 is backup:

regress@vm-nomadic-ubuntu:~/ansible_junos/mydir_ansible$ ansible-playbook pb/facts --limit andrina -v

PLAY [Junos OS version] *******************************************************

TASK: [checking NETCONF] ******************************************************
ok: [andrina] => {"changed": false, "elapsed": 0, "item": "", "path": null, "port": 830, "search_regex": null, "state": "started"}

TASK: [Get Junos Facts] *******************************************************
ok: [andrina] => {"changed": false, "facts": {"2RE": true, "HOME": "/var/home/regress", "RE0": {"last_reboot_reason": "Router rebooted after a normal shutdown.", "mastership_state": "master", "model": "RE-S-1800x4", "status": "OK", "up_time": "7 days, 23 minutes, 36 seconds"}, "RE1": {"last_reboot_reason": "Router rebooted after a normal shutdown.", "mastership_state": "backup", "model": "RE-S-1800x4", "status": "OK", "up_time": "7 days, 23 minutes, 50 seconds"}, "domain": "englab.juniper.net", "fqdn": "andrina.englab.juniper.net", "hostname": "andrina", "ifd_style": "CLASSIC", "master": "RE0", "model": "MX480", "personality": "MX", "serialnumber": "JN10FE440AFB", "switch_style": "BRIDGE_DOMAIN", "version": "12.1-20140402.0", "version_RE0": "12.1-20140402.0", "version_RE1": "12.1-20140402.0"}}

PLAY RECAP ********************************************************************
andrina : ok=2 changed=0 unreachable=0 failed=0


Playbook result when master is re1 and backup is re0:

regress@vm-nomadic-ubuntu:~/ansible_junos/mydir_ansible$ ansible-playbook pb/facts --limit andrina -v

PLAY [Junos OS version] *******************************************************

TASK: [checking NETCONF] ******************************************************
ok: [andrina] => {"changed": false, "elapsed": 0, "item": "", "path": null, "port": 830, "search_regex": null, "state": "started"}

TASK: [Get Junos Facts] *******************************************************
failed: [andrina] => {"failed": true, "parsed": false}
invalid output was: Traceback (most recent call last):
File "/home/regress/.ansible/tmp/ansible-tmp-1397213264.56-247484810680075/junos_get_facts", line 1305, in
main()
File "/home/regress/.ansible/tmp/ansible-tmp-1397213264.56-247484810680075/junos_get_facts", line 95, in main
dev.open()
File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 247, in open
self.facts_refresh()
File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 412, in facts_refresh
gather(self, self._facts)
File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/facts/chassis.py", line 28, in chassis
facts['model'] = x_ch.find('description').text
AttributeError: 'NoneType' object has no attribute 'find' >>>>ERROR

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/regress/facts.retry

andrina : ok=1 changed=0 unreachable=0 failed=1


Expected Result

Junos get facts should return the device information after the switchover without errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions