Juniper / ansible-junos-stdlib

Junos modules for Ansible
Apache License 2.0
307 stars 158 forks source link

Diff File Output does not work for NFX JDM Device #504

Closed mattwalter-cadenzallc closed 4 years ago

mattwalter-cadenzallc commented 4 years ago

Issue Type

Module Name

juniper_junos_config

Juniper.Junos role and Python libraries version

ansible 2.9.7
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]

ansible==2.9.7
asn1crypto==0.24.0
bcrypt==3.1.7
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
ciscoconfparse==1.5.4
colorama==0.4.3
cryptography==2.9.2
dnspython==1.16.0
entrypoints==0.3
future==0.18.2
idna==2.9
Jinja2==2.11.2
jmespath==0.9.5
junos-eznc==2.2.1
jxmlease==1.0.1
keyring==17.1.1
keyrings.alt==3.1.1
lxml==4.5.0
MarkupSafe==1.1.1
mypy-extensions==0.4.3
napalm==2.5.0
ncclient==0.6.7
netaddr==0.7.19
netmiko==3.1.0
nornir==2.4.0
ntc-templates==1.4.1
numpy==1.18.3
nxapi-plumbing==0.5.2
pandas==1.0.3
paramiko==2.7.1
passlib==1.7.2
pycparser==2.20
pycrypto==2.6.1
pyeapi==0.8.3
PyGObject==3.30.4
pyIOSXR==0.53
PyNaCl==1.3.0
pynetbox==4.3.1
pyserial==3.4
python-dateutil==2.8.1
pytz==2019.3
pyxdg==0.25
PyYAML==5.3.1
requests==2.23.0
ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
scp==0.13.2
SecretStorage==2.3.1
selectors2==2.0.1
six==1.14.0
terminal==0.4.0
textfsm==1.1.0
timezonefinder==4.2.0
typing-extensions==3.7.4.2
urllib3==1.25.9

Role: Juniper.junos
        description: Network build automation of Junos devices.
        active: True
        commit: 06895d681726a705f296fcbd8e0632955cce2e7e
        commit_message: Merge pull request #481 from isometry/fix-ignore-warning

Fix ignore_warning with non-boolean arguments
        commit_url: https://api.github.com/repos/Juniper/ansible-junos-stdlib/git/commits/06895d681726a705f296fcbd8e0632955cce2e7e
        company: Juniper Networks, Inc.
        created: 2019-12-16T08:33:12.656681Z
        dependencies: []
        download_count: 95625
        forks_count: 142
        galaxy_info:
                author: Juniper
                company: Juniper Networks, Inc.
                galaxy_tags: ['networking', 'junos', 'juniper']
                license: Apache 2.0
                min_ansible_version: 2.4
                platforms: [{'name': 'junos', 'versions': ['all']}]
                role_name: junos
        github_branch: master
        github_repo: ansible-junos-stdlib
        github_user: Juniper
        id: 45350
        imported: 2020-04-02T10:46:11.182527-04:00
        install_date: Mon Apr 27 15:47:59 2020
        installed_version: 2.3.1
        is_valid: True
        issue_tracker_url: https://github.com/Juniper/ansible-junos-stdlib/issues
        license: Apache 2.0
        min_ansible_version: 2.4
        modified: 2020-04-02T14:46:11.199139Z
        open_issues_count: 67
        path: ('/root/.ansible/roles', '/usr/share/ansible/roles', '/etc/ansible/roles')
        role_type: ANS
        stargazers_count: 237
        travis_status_url:

OS / Environment

NFX250 JDM (Model: nfx250_s2_10_t) 18.4R3.3

Summary

When setting diff: True we expect to see a file generated that shows the changes of the candidate config vs the committed. The file output instead shows Unable to parse diff from response!. The same playbook/task run on other devices returns expected results.

Other than not generating the diff file contents, juniper_junos_config works for the NFX JDM devices.

Steps to reproduce


    - name: Audit config template.
      juniper_junos_config:
        load: 'replace'
        diff: True
        retrieve: candidate
        dest_dir: output
        src: rendered/{{ inventory_hostname }}.conf
      register: task_response
      check_mode: yes

cat output/xxxxxxxxxxxxxxxxxxxxx.diff
Unable to parse diff from response!

Expected results

[edit system login user xxxx authentication]
-     encrypted-password "xxxxxxx"; ## SECRET-DATA
+     encrypted-password "xxxxxxx"; ## SECRET-DATA
[edit system root-authentication]
-   encrypted-password "xxxxxxx"; ## SECRET-DATA
+   encrypted-password "xxxxxxx"; ## SECRET-DATA
[edit system]
-  time-zone xxxxxxx;
+  time-zone xxxxxxx;

Actual results

Unable to parse diff from response!
rahkumar651991 commented 4 years ago

Hi @mattwalter-cadenzallc

can you share the command ‘show version’ output?

jhlasnik commented 4 years ago

I'm seeing a similar issue now since the commit on 5/7, let me know if I should open a separate issue.

https://github.com/Juniper/ansible-junos-stdlib/commit/570d44925b0b0db47f5c4d47c6a1aa0251faad0f

ansible-playbook 2.8.8
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/my-envs/ansible2.8_py3/lib/python3.7/site-packages/ansible
  executable location = /opt/my-envs/ansible2.8_py3/bin/ansible-playbook
  python version = 3.7.4 (default, Feb 19 2020, 17:25:06) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
"module_stderr": "/var/lib/awx/.ansible/tmp/ansible-tmp-1592828642.9456952-110570275472584/AnsiballZ_juniper_junos_config.py:18: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Traceback (most recent call last):
  File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1592828642.9456952-110570275472584/AnsiballZ_juniper_junos_config.py\", line 114, in <module>
    _ansiballz_main()
  File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1592828642.9456952-110570275472584/AnsiballZ_juniper_junos_config.py\", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1592828642.9456952-110570275472584/AnsiballZ_juniper_junos_config.py\", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File \"/usr/local/lib/python3.7/imp.py\", line 234, in load_module
    return load_source(name, filename, file)
  File \"/usr/local/lib/python3.7/imp.py\", line 169, in load_source
    module = _exec(spec, sys.modules[name])
  File \"<frozen importlib._bootstrap>\", line 630, in _exec
  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module
  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed
  File \"/tmp/ansible_juniper_junos_config_payload_wu4e7872/__main__.py\", line 1148, in <module>
  File \"/tmp/ansible_juniper_junos_config_payload_wu4e7872/__main__.py\", line 1080, in main
  File \"/tmp/ansible_juniper_junos_config_payload_wu4e7872/ansible_juniper_junos_config_payload.zip/ansible/module_utils/juniper_junos_common.py\", line 1573, in diff_configuration
TypeError: diff() got an unexpected keyword argument 'ignore_warning'
",
rahkumar651991 commented 4 years ago

@jhlasnik It seems, your PyEz(junos-eznc) may not be in sync with your ansible roles. Upgrading PyEz should resolve this.

It is different from this issue. If the issue still pertains after upgrading PyEz you can open a separate issue for it. Do share the 'pip list' and 'ansible-galaxy list' output in that situation.

jhlasnik commented 4 years ago

@jhlasnik It seems, your PyEz(junos-eznc) may not be in sync with your ansible roles. Upgrading PyEz should resolve this.

It is different from this issue. If the issue still pertains after upgrading PyEz you can open a separate issue for it. Do share the 'pip list' and 'ansible-galaxy list' output in that situation.

Yeah, after digging through the code changes more I see that. This wasn't noted in the requirements file as requiring a certain version of junos-eznc.

mattwalter-cadenzallc commented 4 years ago

Show version output:

show version Hostname: xxxxxxxxxxxxxxxxxxxxxx Model: nfx250_s2_10_t JUNOS Host Software [4.1.27-rt30-WR8.0.0.25_ovp:3.0.3] JUNOS Host nfx-2 platform package [18.4R3.3] NFX-2 LTE package [18.4R3.3] JUNOS Host nfx-2 base package [18.4R3.3] JUNOS Host nfx-2 control-plane flex package [18.4R3.3] JUNOS Host nfx-2 data-plane package [18.4R3.3] JUNOS Host qfx-jdm package [18.4R3.3]

{master:0}

jhlasnik commented 4 years ago

Will take a look and confirm, thanks!

Looking at your junos-eznc version you may need to upgrade that. Going from 2.3.1 to 2.4.1 resolved my issue.

mattwalter-cadenzallc commented 4 years ago

Will take a look and confirm, thanks!

Looking at your junos-eznc version you may need to upgrade that. Going from 2.3.1 to 2.4.1 resolved my issue.

I actually also had the same issue you had with other devices recently. (napalm was holding junos-eznc to 2.2.1) 2.4.1 fixed that issue. The NFX JDM device is also now showing diff's as expected too now. Thanks!

Issue resolved.