Skip to content

junos_get_config module fails when filter argument contains more than one level of configuration hierarchy #120

@stacywsmith

Description

@stacywsmith

Per the documentation, the filter argument to junos_get_config:

"Defines heirarchy of configuration to retrieve. If omitted the entire configuration is retrieved. Format is slash notation ex groups/routeinst/routing-instances/ISP-1"

However, the filter argument was not working correctly if it contained more than one level of configuration hierarchy (a string with one or more slashes) per this email report from Dan Houtz:

Hi,

I am running into an issue with the following play which makes use of junos_get_config and it's filter parameter:

$ cat mgmt-pfxlist-report.pb.yml

---
- name: MANAGEMENT Prefix List Report
  hosts: all
  connection: local
  gather_facts: no

  vars_prompt:
    - name: USERNAME
      prompt: User name
      private: no
    - name: DEVICE_PASSWORD
      prompt: Device password
      private: yes

  tasks:
    - name: Get MANAGEMENT prefix list
      junos_get_config:
        host={{ansible_host}}
        user={{USERNAME}}
        passwd={{DEVICE_PASSWORD}}
        logfile=/tmp/get_config.log
        filter="system/syslog"
        dest=/tmp/{{inventory_hostname}}
      when: switch_vendor == 'Juniper Networks'


If I use a simple one level filter such as "filter=groups" or "filter=system" everything works as expected. However if I try to defined a deeper path like "filter=system/syslog" in the configuration I run into problem, getting the following error message:

fatal: [aggrfq178-1.ord6]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to get config: RpcError(severity: error, bad_element: syslog, message: syntax error, expecting </configuration>)"}

In logs I see:

2016-03-05 20:39:46,747:CONFIG:204.93.204.238:connecting to host: root@192.168.1.1:830
2016-03-05 20:39:46,811:ncclient.transport.ssh:Connected (version 2.0, client OpenSSH_6.0)
2016-03-05 20:39:47,259:ncclient.transport.ssh:Authentication (password) successful!
2016-03-05 20:39:49,256:ncclient.transport.session:initialized: session-id=473 | server_capabilities=['http://xml.juniper.net/dmi/system/1.0', 'urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0', 'http://xml.juniper.net/netconf/junos/1.0', 'urn:ietf:params:xml:ns:netconf:capability:validate:1.0', 'urn:ietf:params:xml:ns:netconf:capability:candidate:1.0', 'urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file', 'urn:ietf:params:xml:ns:netconf:base:1.0']
2016-03-05 20:39:49,256:CONFIG:192.168.1.1:Getting config with filter=<configuration><system/><syslog/></configuration>
2016-03-05 20:39:49,256:CONFIG:192.168.1.1:Getting config with options={'format': 'text'}
2016-03-05 20:39:49,257:ncclient.operations.rpc:Requesting 'ExecuteRpc'
2016-03-05 20:39:49,372:CONFIG:192.168.1.1:Unable to get config: RpcError(severity: error, bad_element: syslog, message: syntax error, expecting </configuration>)
2016-03-05 20:39:49,373:ncclient.operations.rpc:Requesting 'CloseSession'

I believe I'm specifying the path correctly per the example at http://junos-ansible-modules.readthedocs.org/en/1.2.0/junos_get_config.html which shows an example of "groups/routeinst/routing-instances/ISP-1"

Any insight would be greatly appreciated!

-Dan

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