I saw no reference in your playbook to the collection that you are using.
I've not looked further than this to see if there are any other issues, but in the first instance, see if you get further once adding the collection to your playbook. If you still get issues, provide an update, and I'll find some time to look more deeply.
Original Message:
Sent: 04-08-2024 10:53
From: AMRISH PATEL
Subject: Ansible playbook error: ModuleNotFoundError: No module named 'jnpr'
Thanks for looking into this Andy!
Playbook:
student@DESKTOP-VF2VLG4:~$ more Interface_desc_update.yml
- name: Load and commit Junos configurations
hosts: core
connection: local
gather_facts: no
tasks:
- name: Verify NETCONF connectivity
wait_for:
host: "{{ inventory_hostname }}"
port: 32006
timeout: 5
- name: Load and commit the configurations
juniper.device.config:
load: "override"
timeout: 20
src: "configuration/vmx02/vmx02_cfg.txt"
comment: "Load the interface description configuration on the vlab devices"
student@DESKTOP-VF2VLG4:~$
Thanks
Amrish Patel
------------------------------
AMRISH PATEL
Original Message:
Sent: 04-08-2024 04:15
From: asharp
Subject: Ansible playbook error: ModuleNotFoundError: No module named 'jnpr'
Please share your playbook. Thanks.
------------------------------
Andy Sharp
Original Message:
Sent: 04-05-2024 14:11
From: AMRISH PATEL
Subject: Ansible playbook error: ModuleNotFoundError: No module named 'jnpr'
Hello,
My environment details:
Windows11-wsl2: Ubuntu 20.04, Virtual environment: python3.8-full, within virtual env: Installed Ansible, Junos-pyez, Jxmlease, xmltodict.
I am able to NETCONF to lab device from Juniper vlab but getting error message for second task for making configuration changes.
(myansible) student@DESKTOP-VF2VLG4:~$ ansible-playbook -i configuration/hosts Interface_desc_update.yml
PLAY [Load and commit Junos configurations] ****************************************************************************************************************
TASK [Verify NETCONF connectivity] *************************************************************************************************************************
ok: [66.129.234.215]
TASK [Load and commit the configurations] ******************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'jnpr'
fatal: [66.129.234.215]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/student/.ansible/tmp/ansible-tmp-1712339458.1710489-1769-257087027421743/AnsiballZ_config.py\", line 107, in <module>\n _ansiballz_main()\n File \"/home/student/.ansible/tmp/ansible-tmp-1712339458.1710489-1769-257087027421743/AnsiballZ_config.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/student/.ansible/tmp/ansible-tmp-1712339458.1710489-1769-257087027421743/AnsiballZ_config.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.config', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.config', _modlib_path=modlib_path),\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_juniper.device.config_payload_vpwou34_/ansible_juniper.device.config_payload.zip/ansible_collections/juniper/device/plugins/modules/config.py\", line 828, in <module>\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/tmp/ansible_juniper.device.config_payload_vpwou34_/ansible_juniper.device.config_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 *************************************************************************************************************************************************
66.129.234.215 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
(myansible) student@DESKTOP-VF2VLG4:~$ python3
Python 3.8.10 (default, Nov 22 2023, 10:22:35)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jnpr.junos
>>> jnpr.junos.__version__
'2.7.0'
>>>
Thank you in advance for sparing time to look into this.
Thanks
Amrish
------------------------------
AMRISH PATEL
------------------------------