Ansible // juniper_junos_config retrieve fails when format is 'set'

299 views
Skip to first unread message

Alex Ignatov

unread,
Mar 2, 2018, 11:48:23 AM3/2/18
to Junos Python EZ
Hello,

Came across an issue, that configuration retrieval fails once I specify format as 'set'... 'conf' and 'xml' options work fine, but with 'set' the task fails with an error: 

{"changed": false, "failed": true, "msg": "Unexpected XML tag returned. Configuration is: <configuration changed-seconds=\"1520007992\" changed-localtime=\"2018..... and the rest of the configuration with xml tags in one line.


Playbook:
---
- name: Testing Juniper config module
  hosts: juniper
  roles:
    - Juniper.junos
  connection: local
  gather_facts: no

  tasks:
  - name: Retrieving configuration
    juniper_junos_config:
      retrieve: 'committed'
      format: 'set'
      diff: false
      check: false
      commit: false
      dest_dir: /home/ansible
      user: "{{ user }}"
      passwd: "{{ passwd }}"
      port: "{{ port }}"
    register: response

  - name: Print the result
    debug: var=response

Switch model:
user@EX4200-1> show version 
fpc0:
--------------------------------------------------------------------------
Hostname: EX4200-1
Model: ex4200-24t
JUNOS Base OS boot [12.3R6.6]
JUNOS Base OS Software Suite [12.3R6.6]
JUNOS Kernel Software Suite [12.3R6.6]
JUNOS Crypto Software Suite [12.3R6.6]
JUNOS Online Documentation [12.3R6.6]
JUNOS Enterprise Software Suite [12.3R6.6]
JUNOS Packet Forwarding Engine Enterprise Software Suite [12.3R6.6]
JUNOS Routing Software Suite [12.3R6.6]
JUNOS Web Management [12.3R6.6]
JUNOS FIPS mode utilities [12.3R6.6]

{master:0}

How to troubleshoot what exactly makes it fail?

Thanks,

Alex

Message has been deleted

Alex Ignatov

unread,
Mar 2, 2018, 12:08:19 PM3/2/18
to Junos Python EZ
Noticed that it should be fixed in the latest release, but...

Updating to release 2.0.2 did not solve the issue... the same error..

[ansible@server ~]$ ansible-galaxy list
- Juniper.junos, 2.0.2

Stacy W. Smith

unread,
Mar 2, 2018, 12:18:52 PM3/2/18
to Alex Ignatov, Junos Python EZ
On Mar 2, 2018, at 10:08 AM, Alex Ignatov <alex.o....@gmail.com> wrote:

Noticed that it should be fixed in the latest release, but...

Updating to release 2.0.2 did not solve the issue... the same error..

[ansible@server ~]$ ansible-galaxy list
- Juniper.junos, 2.0.2


The underlying issue is that the version of Junos you are running doesn’t support the required functionality. Please specifically see this comment:

However, there is a workaround to get the configuration in set format using the “juniper_junos_command” module rather than the “juniper_junos_config” module. Please specifically see this comment for an example workaround:

There was, however, an issue when using the workaround described above in conjunction with the “dest_dir” option. The “fix" in 2.0.2 simply allows the “dest_dir” option to be used in conjunction with the “juniper_junos_command” module when the command is “show configuration | display set”.

—Stacy

Reply all
Reply to author
Forward
0 new messages