Purpose of my Code is to filter a specific Routing instance name from Configuration.
My search is for a Routing Instance which is in configuration-> Routing -Instances->Instance -> name -> MY RI and all the lines which has MY RI I am okay with Filter and passing kwargs but I am facing issue.
Code:
---
- name: Get RI
hosts: junos Host
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: send rpc with args
juniper_junos_rpc:
host: "{{ inventory_hostname }}"
user: "user"
passwd: "pssword!"
rpc: get-config
logfile: 'rpc.log'
format: xml
dest: "{{ inventory_hostname }}.xml"
kwargs:
filter_xml: configuration/routing-instances/instance/name = CSP-RI-L2-cc6abb1d-63ab-483f-b4ce-f4b978c877cc
**ERROR**
error:fatal: [sit-entce.tlab.equinix.com]: FAILED! => {
"changed": false,
"module_stderr": "/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141: FutureWarning: CTR mode needs counter parameter, not IV\n self._cipher = factory.new(key, *args, **kwargs)\nTraceback (most recent call last):\n File \"/tmp/ansible_T0LCbD/ansible_module_juniper_junos_rpc.py\", line 622, in <module>\n main()\n File \"/tmp/ansible_T0LCbD/ansible_module_juniper_junos_rpc.py\", line 518, in main\n options=attr, **kwarg)\nTypeError: get_config() got multiple values for keyword argument 'filter_xml'\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
Any suggestions. Multiple RI would be there and I have to search one RI and print it or store all the lines which has that RI name
Say a device got below configuration
# show | compare | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/18.1I0/junos">
<configuration>
<routing-instances operation="create">
<instance>
<name>pqr</name>
<interface>
<name>ge-0/0/2.0</name>
</interface>
</instance>
<instance>
<name>xyz</name>
<interface>
<name>ge-0/0/1.0</name>
</interface>
</instance>
</routing-instances>
</configuration>
Now if you want to filter a very specific instance, you can use filter option. filter can be used as
filter_xml: <routing-instances><instance><name>pqr</name></instance></routing-instances>