ansible-junos-stdlib icon indicating copy to clipboard operation
ansible-junos-stdlib copied to clipboard

JuniperJunosModule' object has no attribute '_pyez_conn'

Open achhabr1 opened this issue 4 years ago • 13 comments

Issue Type

  • Bug Report

Module Name

facts

juniper.device collection and Python libraries version (python3-venv) [ac043s@sdnautosr12 juniper]$ pip list Package Version


ansible 4.2.0 ansible-core 2.11.2 bcrypt 3.2.0 cffi 1.14.5 colorama 0.4.4 configparser 5.0.2 cryptography 3.4.7 future 0.18.2 icdiff 1.9.1 Jinja2 3.0.1 jsnapy 1.3.6 junos-eznc 2.6.1 jxmlease 1.0.3 lxml 4.6.3 MarkupSafe 2.0.1 ncclient 0.6.9 netaddr 0.8.0 netmiko 3.4.0 ntc-templates 2.1.0 packaging 21.0 paramiko 2.7.2 pip 21.1.3 pycparser 2.20 PyNaCl 1.4.0 pyparsing 2.4.7 pyserial 3.5 PyYAML 5.4.1 resolvelib 0.5.4 scp 0.13.5 setuptools 41.6.0 six 1.16.0 tenacity 7.0.0 textfsm 1.1.2 transitions 0.8.8 xmltodict 0.12.0 yamlordereddictloader 0.4.0 (python3-venv) [ac043s@sdnautosr12 juniper]$

OS / Environment Porter 3

Summary Connection not happening new ansible 4.2.0

(python3-venv) [ac043s@sdnautosr12 juniper]$ python Python 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information.

Playbook `---

  • name: Install Junos OS hosts: porter3 connection: juniper.device.pyez gather_facts: no collections:

    • juniper.device

    vars: OS_version: "21.1R1-S1.1" OS_package: "jinstall-host-nfx-3-x86-64-21.1R1-S1.1-secure-signed.tgz" pkg_dir: "{{ lookup('env', 'HOME') }}/images" log_dir: "{{ lookup('env', 'HOME') }}/log" netconf_port: 830 wait_time: 3600 ansible_python_interpreter: "{{ lookup('env', 'HOME') }}/python3-venv/bin/python"

    tasks:

    • name: Checking NETCONF connectivity wait_for: host: "{{ inventory_hostname }}" port: "{{ netconf_port }}" timeout: 5

    • name: Get device facts facts: `

Verbose output of the Error

TASK [Get device facts] *************************************************************************************************************************************************************************************** task path: /home/ac043s/software_sdnautos02/ansible_development/juniper/porter3upgrade.yml:25 redirecting (type: connection) ansible.builtin.netconf to ansible.netcommon.netconf Loading collection ansible.netcommon from /home/ac043s/python3-venv/lib64/python3.8/site-packages/ansible_collections/ansible/netcommon redirecting (type: netconf) ansible.builtin.junos to junipernetworks.junos.junos Loading collection junipernetworks.junos from /home/ac043s/python3-venv/lib64/python3.8/site-packages/ansible_collections/junipernetworks/junos attempting to start connection using connection plugin ansible.netcommon.netconf Found ansible-connection at path /home/ac043s/python3-venv/bin/ansible-connection found existing local domain socket, using it! local domain socket path is /home/ac043s/.ansible/pc/5ecf442b60 ESTABLISH LOCAL CONNECTION FOR USER: ac043s EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363"&& mkdir "echo /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870" && echo ansible-tmp-1625602138.1041296-29252-272465699950870="echo /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870" ) && sleep 0' Using module file /home/ac043s/.ansible/collections/ansible_collections/juniper/device/plugins/modules/facts.py PUT /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/tmpggveq12s TO /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py EXEC /bin/sh -c 'chmod u+x /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/ /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py && sleep 0' EXEC /bin/sh -c '/home/ac043s/python3-venv/bin/python /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py && sleep 0' EXEC /bin/sh -c 'rm -f -r /home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/ > /dev/null 2>&1 && sleep 0' The full traceback is: Traceback (most recent call last): File "/home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py", line 100, in _ansiballz_main() File "/home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py", line 92, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py", line 40, 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 "/usr/lib64/python3.8/runpy.py", line 207, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/lib64/python3.8/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 369, in File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 311, in main File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 611, in init File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 686, in get_connection File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 722, in fail_json File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1164, in close_configuration AttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn' fatal: [ptr74-jdm]: FAILED! => { "changed": false, "module_stderr": "Traceback (most recent call last):\n File "/home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py", line 100, in \n _ansiballz_main()\n File "/home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py", line 92, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/ac043s/.ansible/tmp/ansible-local-29214wabu3363/ansible-tmp-1625602138.1041296-29252-272465699950870/AnsiballZ_facts.py", line 40, 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 "/usr/lib64/python3.8/runpy.py", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.8/runpy.py", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 369, in \n File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 311, in main\n File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 611, in init\n File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 686, in get_connection\n File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 722, in fail_json\n File "/tmp/ansible_facts_payload_0easwoi1/ansible_facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1164, in close_configuration\nAttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }

PLAY RECAP **************************************************************************************************************************************************************************************************** ptr74-jdm : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
`

achhabr1 avatar Jul 06 '21 20:07 achhabr1

I am seeing the same issue. Interesting to note, when I sniff the network connection I can see ansible connecting to the router and appears to get the data from the device. I see this on a couple different systems/version (linux and mac) both showing the same problem.

vagrant@ansibletesting1:~/git/ansible$ python3 --version
Python 3.6.9
vagrant@ansibletesting1:~/git/ansible$ ansible --version
ansible 2.10.8

# /home/vagrant/.ansible/collections/ansible_collections
Collection                     Version
------------------------------ -------
juniper.device                 1.0.0  

vagrant@ansibletesting1:~/git/ansible$ pip3 list | grep junos
junos-eznc             2.6.2

@mer:~/git/collections/device_modeling/plugins/modules python3 --version
Python 3.8.2
@mer:~/git/collections/device_modeling/plugins/modules ansible --version
ansible 2.10.8

# /Users/xxx/.ansible/collections/ansible_collections
Collection                          Version
----------------------------------- -------

juniper.device                      1.0.0  

pip3 list | grep junos
junos-eznc             2.6.2


root@ansibletesting1:/home/vagrant# tcpdump -n -i enp0s3 host 100.80.16.8
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes
17:03:04.274521 IP 10.0.2.15.54008 > 100.80.16.8.22: Flags [S], seq 3730346112, win 64240, options [mss 1460,sackOK,TS val 2252966711 ecr 0,nop,wscale 7], length 0
17:03:05.365282 IP 10.0.2.15.54008 > 100.80.16.8.22: Flags [S], seq 3730346112, win 64240, options [mss 1460,sackOK,TS val 2252967801 ecr 0,nop,wscale 7], length 0
17:03:05.546334 IP 100.80.16.8.22 > 10.0.2.15.54008: Flags [S.], seq 919744001, ack 3730346113, win 65535, options [mss 1460], length 0
17:03:05.546363 IP 10.0.2.15.54008 > 100.80.16.8.22: Flags [.], ack 1, win 64240, length 0
17:03:05.546994 IP 10.0.2.15.54008 > 100.80.16.8.22: Flags [P.], seq 1:25, ack 1, win 64240, length 24

<snip>

17:03:06.664985 IP 100.80.16.8.22 > 10.0.2.15.54008: Flags [P.], seq 24502:24630, ack 3865, win 65535, length 128
17:03:06.664996 IP 10.0.2.15.54008 > 100.80.16.8.22: Flags [.], ack 24630, win 62780, length 0
17:03:06.665911 IP 10.0.2.15.54008 > 100.80.16.8.22: Flags [R.], seq 3865, ack 24630, win 62780, length 0

    "module_stderr": "Traceback (most recent call last):\n  File \"/home/vagrant/.ansible/tmp/ansible-local-1487a2214lx9/ansible-tmp-1628787783.871074-1508-172897054125040/AnsiballZ_command.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/vagrant/.ansible/tmp/ansible-local-1487a2214lx9/ansible-tmp-1628787783.871074-1508-172897054125040/AnsiballZ_command.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/vagrant/.ansible/tmp/ansible-local-1487a2214lx9/ansible-tmp-1628787783.871074-1508-172897054125040/AnsiballZ_command.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.command', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_command_payload_gx0ai5ra/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/modules/command.py\", line 493, in <module>\n  File \"/tmp/ansible_command_payload_gx0ai5ra/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/modules/command.py\", line 329, in main\n  File \"/tmp/ansible_command_payload_gx0ai5ra/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 611, in __init__\n  File \"/tmp/ansible_command_payload_gx0ai5ra/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 686, in get_connection\n  File \"/tmp/ansible_command_payload_gx0ai5ra/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 722, in fail_json\n  File \"/tmp/ansible_command_payload_gx0ai5ra/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1164, in close_configuration\nAttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

One more note... on this system (ubuntu20)... I do not see ansible make the network connection like I do with the other two versions. Getting different behaviors with the module here.


vagrant@ubuntu-focal:~/git/ansible$ ansible --version
ansible 2.10.12
  config file = /home/vagrant/git/ansible/ansible.cfg
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]

vagrant@ubuntu-focal:~/git/ansible$ python3 --version
Python 3.8.10

vagrant@ubuntu-focal:~/git/ansible$ pip3 list | grep junos
junos-eznc             2.6.2

# /home/vagrant/.ansible/collections/ansible_collections
Collection     Version
-------------- -------
juniper.device 1.0.0  

TASK [get junos bgp neighbor data] ***********************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn'
fatal: [edge10.nso5]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/vagrant/.ansible/tmp/ansible-local-1979xme3e4ha/ansible-tmp-1628789803.916283-2002-231830975632864/AnsiballZ_command.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/vagrant/.ansible/tmp/ansible-local-1979xme3e4ha/ansible-tmp-1628789803.916283-2002-231830975632864/AnsiballZ_command.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/vagrant/.ansible/tmp/ansible-local-1979xme3e4ha/ansible-tmp-1628789803.916283-2002-231830975632864/AnsiballZ_command.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.command', init_globals=None, run_name='__main__', alter_sys=True)\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_command_payload_wayxvssd/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/modules/command.py\", line 493, in <module>\n  File \"/tmp/ansible_command_payload_wayxvssd/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/modules/command.py\", line 298, in main\n  File \"/tmp/ansible_command_payload_wayxvssd/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 590, in __init__\n  File \"/tmp/ansible_command_payload_wayxvssd/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 722, in fail_json\n  File \"/tmp/ansible_command_payload_wayxvssd/ansible_command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1164, in close_configuration\nAttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}


vagrant@ubuntu-focal:~/git/ansible$ sudo tcpdump -n -i enp0s3 host 100.80.16.8
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel


cwiech avatar Aug 12 '21 17:08 cwiech

Hi, can you check with this code merge - https://github.com/Juniper/ansible-junos-stdlib/pull/564/files It should fix it.

rahkumar651991 avatar Sep 16 '21 17:09 rahkumar651991

The new release of ansible should have this fixed. Closing this issue due to inactivity

rahkumar651991 avatar Oct 06 '21 06:10 rahkumar651991

Doesn't seem fixed. I'm running juniper.device -> 1.0.1 line 1172, in close_configuration\nAttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn'

webtroter avatar Oct 14 '21 20:10 webtroter

Same here:

/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1172, in close_configuration
AttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn'

Any workaround for this?

rklomp avatar Dec 28 '21 09:12 rklomp

Same problem here

OrionTheGiant avatar Oct 18 '22 13:10 OrionTheGiant

This problem is hitting me today! I'm encountering this as I try to upgrade from the old junos_config Ansible built-in module to use the new juniper.device collection.

ryeleo avatar Oct 26 '22 12:10 ryeleo

@rahkumar651991 we need this issue reopened.

webtroter avatar Oct 26 '22 17:10 webtroter

Hi is there any update with this? Have the same issue.

smeego78 avatar Dec 22 '22 03:12 smeego78

I am having the same issue with the juniper.device.software module. I am running ansible core 2.12.10 I get the error "AttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn' "

abailey8 avatar Jan 18 '23 13:01 abailey8

I am having the same issue with the juniper.device.software module. I am running ansible core 2.12.10 I get the error "AttributeError: 'JuniperJunosModule' object has no attribute '_pyez_conn' "

@abailey8 @smeego78 can you confirm you are using either connection: local or connection: juniper.device.pyez? Attempting to use ansible.netcommon.netconf will generate this error. See this table.

jrokeach avatar Jan 18 '23 14:01 jrokeach

@jrokeach I can confirm I'm using connection:local. I even tried to define it within the play:

- name: Upgrade software on ACX710
  connection: local
  juniper.device.software:
    package: "{{ local_file_dir }}/{{ acx710_file }}"
    validate: false
    checksum_timeout: 300
    cleanfs_timeout: 300
    install_timeout: 1800
    logfile: "{{ log_dir }}/{{ inventory_hostname }}.log"
  when: "'ACX71' in inventory_hostname"
  register: upgrade_response
  notify:
    - Wait_for_reboot

Yet it still does not work.

For what its worth, I used this play yesterday and successfully upgraded an ACX710. Today I was working on some other Ansible items that led me to install LibSSH (pip install ansible-pylibssh). However, that process failed so I removed the library (pip uninstall ansible-pylibssh), and now my script does not work. Could be completely unrelated, but that's all I remember changing.

mactizzle avatar Jan 27 '23 19:01 mactizzle

Is there any update on this issue - I started to migrate from the older Juniper.junos role to the juniper.device collection (1.0.2) and I have hit this issue when using juniper.device.command.

UPDATE: It turns out I had ansible_connection: netconf buried in a group_var that was being pulled in - as soon as I removed this it now works.

cmason3 avatar Apr 19 '23 09:04 cmason3

Hi @achhabr1

I have verified the software installation with connection: local and connection: juniper.device.pyez, both looks to be working fine with following versions .

Please re-validated the playbook with following version and update.

ansible --version
ansible [core 2.16.6]
  config file = /root/ansible_release_v216_test/ansible-junos-stdlib/tests/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible_release_v216_test/venv/lib/python3.10/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/ansible_release_v216_test/venv/bin/ansible
  python version = 3.10.8 (main, Dec  2 2022, 10:56:46) [GCC 7.5.0] (/root/ansible_release_v216_test/venv/bin/python)
  jinja version = 3.1.4
  libyaml = True

# /root/.ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
ansible.netcommon                        4.1.0  
ansible.utils                            2.8.0  
juniper.device                           1.0.4  


---
- name: Test juniper.device.software module
  hosts: all
  collections:
    - juniper.device
  gather_facts: no
  vars:
    wait_time: 3600
    pkg_dir: /var/tmp/
    OS_version: 24.2
    OS_package: junos-install-acx-arm-64-24..2.tgz 
    log_dir: /var/log/

  tasks:
    - name: Checking NETCONF connectivity
      wait_for: host={{ ansible_ssh_host }} port=830 timeout=5
    - name: Install Junos OS package
      software:
        reboot: False 
        no_copy: True 
        all_re: True 
        version: "{{ OS_version }}"
        package: "{{ pkg_dir }}/{{ OS_package }}"
        logfile: "{{ log_dir }}/software.log"
      register: test1
      notify:
        - wait_reboot

    - name: Print response
      debug:
        var: test1

    - name: Check TEST - 1
      assert:
        that:
          - test1.failed == false

  handlers:
    - name: wait_reboot
      wait_for: host={{ ansible_ssh_host }} port=830 timeout={{ wait_time }}
      when: not test1.check_mode


 ansible-playbook pb.juniper_junos_software.yml 

PLAY [Test juniper.device.software module] ********************************************************************************************************************************

TASK [Checking NETCONF connectivity] **************************************************************************************************************************************
ok: [local_connection_testcases]

TASK [Install Junos OS package] *******************************************************************************************************************************************
changed: [local_connection_testcases]

TASK [Print response] *****************************************************************************************************************************************************
ok: [local_connection_testcases] => {
    "test1": {
        "changed": true,
        "check_mode": false,
        "failed": false,
        "msg": "Package /var/tmp/junos-install-acx-arm-64-24.2.tgz successfully installed. Response from device is: \nVerified junos-install-acx-arm-64-24.2I-20240330.0.1659 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified auto-snapshot signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified deebe signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified dsa signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified fips-mode signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jail-runtime signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jdocs signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jinsight signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jpfe-acx-arm signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jsd-jet-1 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jsdn signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-daemons-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-daemons signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-dp-crypto-support-mtx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-l2-rsi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs-compat32-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs-compat32 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-modules-acx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-modules signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-net-mtx-prd signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-net-prd signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-openconfig signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-platform signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-probe signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-aggregated signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-controller-external signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-lsys signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-mpls-oam-advanced signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-mpls-oam-basic signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-scripts signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-rpd-telemetry-application signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-runtime-acx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-runtime signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified na-telemetry signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified oam-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-boot-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-boot-junos-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-compat32 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-crypto signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-forward-compat-11 signed by PackageDevelopmentECP256_2023 method ECDSA256+SHA256\nVerified os-kernel-prd signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-libs-compat32 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-libs signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-modules-net signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-package signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-runtime signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-zoneinfo signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified py-base signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified py-extensions signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified sflow-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nNOTICE: 'pending' set will be activated at next reboot...\n"
    }
}

TASK [Check TEST - 1] *****************************************************************************************************************************************************
ok: [local_connection_testcases] => {
    "changed": false,
    "msg": "All assertions passed"
}

RUNNING HANDLER [wait_reboot] *********************************************************************************************************************************************
ok: [local_connection_testcases]

PLAY RECAP ****************************************************************************************************************************************************************
local_connection_testcases : ok=5    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

 

Thanks Chidanand

chidanandpujar avatar May 08 '24 04:05 chidanandpujar

Pass logs and information provided. So, closing the ticket.

If you have any issues with the latest Juniper Ansible collection, please don't hesitate to open a ticket.

dineshbaburam91 avatar May 13 '24 07:05 dineshbaburam91