I installed Ansible(2.2.1.0), the Juniper.junos(1.4.0) role from Ansible galaxy with junos-eznc (2.1.1). I tried to create a test playbook to obtain the version of my test switch as shown below.
---
- name: Get Device Facts
hosts: juniper
roles:
- Juniper.junos
connection: local
gather_facts: no
tasks:
- name: Checking NETCONF connectivity
wait_for: host={{ inventory_hostname }} port=830 timeout=5
- name: Get Facts
junos_get_facts:
host={{ inventory_hostname }}
savedir=/home/dratcliffe/ansible
register: junos
- name: Show Version
debug: msg="{{ junos.facts.version }}"
when I run the playback I get the following error.
[user@ansible ~]$ ansible-playbook test.yml
PLAY [Get Device Facts] ********************************************************
TASK [Checking NETCONF connectivity] *******************************************
ok: [X.X.X.X]
TASK [Get Facts] ***************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: RuntimeError: facts are read-only!
fatal: [X.X.X.X]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_SkXS6C/ansible_module_junos_get_facts.py\", line 235, in <module>\n main()\n File \"/tmp/ansible_SkXS6C/ansible_module_junos_get_facts.py\", line 176, in main\n dev.facts['has_2RE'] = dev.facts['2RE']\n File \"/usr/lib/python2.7/site-packages/jnpr/junos/factcache.py\", line 171, in __setitem__\n raise RuntimeError(\"facts are read-only!\")\nRuntimeError: facts are read-only!\n", "module_stdout": "", "msg": "MODULE FAILURE"}
to retry, use: --limit @/home/dratcliffe/test.retry
PLAY RECAP *********************************************************************
X.X.X.X : ok=1 changed=0 unreachable=0 failed=1
It seems when it gets the facts it tried to write something and I get an error saying it is read-only? Has anyone encountered this?