Automation

 View Only
last person joined: 3 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  ModuleNotFoundError: No module named 'jnpr'

    Posted 06-29-2024 08:58
    I'm running an ansible playbook leveraging the juniper.device module and receiving  ModuleNotFoundError: No module named 'jnpr' errors. It is a pretty basic configuration and I'm not sure what is wrong. No where in the config am I reference jnpr.  details below. Any help would be greatly appreciated. 

    Playbook 
    ---
    - name: Test
    hosts: rtrs_lab
    connection: local
    gather_facts: false
    collections:
    - juniper.device
    vars_prompt:
    - name: USERNAME
    prompt: User name
    private: false
    - name: DEVICE_PASSWORD
    prompt: Device password
    private: true
    tasks:
    - name: Get Junos device information
    juniper.device.facts:
    user: "{{ USERNAME }}"
    passwd: "{{ DEVICE_PASSWORD }}"
    register: junos_facts
    - name: Print Junos facts
    ansible.builtin.debug:
    msg: "{{ junos_facts }}"



    Errors

    The full traceback is:
    Traceback (most recent call last):
    File "/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.537224-48459-182894303365844/AnsiballZ_facts.py", line 107, in <module>
    _ansiballz_main()
    File "/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.537224-48459-182894303365844/AnsiballZ_facts.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
    File "/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.537224-48459-182894303365844/AnsiballZ_facts.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_pt7v54_2/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 191, in <module>
    File "<frozen zipimport>", line 259, in load_module
    File "/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_pt7v54_2/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 42, in <module>
    ModuleNotFoundError: No module named 'jnpr'
    fatal: [rtr2-lab.net]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n File \"/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.537224-48459-182894303365844/AnsiballZ_facts.py\", line 107, in <module>\n _ansiballz_main()\n File \"/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.537224-48459-182894303365844/AnsiballZ_facts.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.537224-48459-182894303365844/AnsiballZ_facts.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py\", line 210, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_pt7v54_2/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py\", line 191, in <module>\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_pt7v54_2/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 42, in <module>\nModuleNotFoundError: No module named 'jnpr'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
    }
    The full traceback is:
    Traceback (most recent call last):
    File "/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.535051-48458-26703350211007/AnsiballZ_facts.py", line 107, in <module>
    _ansiballz_main()
    File "/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.535051-48458-26703350211007/AnsiballZ_facts.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
    File "/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.535051-48458-26703350211007/AnsiballZ_facts.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
    File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_1r3pfiwi/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 191, in <module>
    File "<frozen zipimport>", line 259, in load_module
    File "/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_1r3pfiwi/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 42, in <module>
    ModuleNotFoundError: No module named 'jnpr'
    fatal: [rtr1-lab.net]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n File \"/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.535051-48458-26703350211007/AnsiballZ_facts.py\", line 107, in <module>\n _ansiballz_main()\n File \"/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.535051-48458-26703350211007/AnsiballZ_facts.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/leonardo.uribe/.ansible/tmp/ansible-tmp-1719618863.535051-48458-26703350211007/AnsiballZ_facts.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.facts', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.facts', _modlib_path=modlib_path),\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py\", line 210, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_1r3pfiwi/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py\", line 191, in <module>\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/var/folders/0y/b0gm81gx14n1y5gx0rjpxw1h0000gn/T/ansible_juniper.device.facts_payload_1r3pfiwi/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 42, in <module>\nModuleNotFoundError: No module named 'jnpr'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
    }

    PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
    rtr1-lab.net : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
    rtr2-lab.net : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

    thanks,
    Leo


    ------------------------------
    LEONARDO URIBE
    ------------------------------


  • 2.  RE: ModuleNotFoundError: No module named 'jnpr'

     
    Posted 06-29-2024 19:42

    For ansible collection juniper.device we will need to install junos-eznc version 2.6.0 or higher.

    pip install junos-eznc



    ------------------------------
    Andy Sharp
    ------------------------------