Juniper / ansible-junos-stdlib

Junos modules for Ansible
Apache License 2.0
303 stars 157 forks source link

AttributeError: 'Connection' object has no attribute 'nonetype' (ansible-core >=2.12.9) #606

Closed ntwrknrd closed 4 months ago

ntwrknrd commented 1 year ago

Issue Type

Module Name

juniper.device.config

juniper.device collection and Python libraries version

containeruser@acm-qalab-nre01:/data$ ansible --version
ansible [core 2.12.9]
  config file = /data/ansible.cfg
  configured module search path = ['/home/containeruser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible
  ansible collection location = /home/containeruser/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/containeruser/.pyenv/versions/3.9.16/bin/ansible
  python version = 3.9.16 (main, Dec 14 2022, 17:40:20) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True
containeruser@acm-qalab-nre01:/data$ pip freeze
ansible==5.10.0
ansible-core==2.12.9
bcrypt==4.0.1
cffi==1.15.1
colorama==0.4.6
configparser==5.3.0
cryptography==38.0.4
future==0.18.2
icdiff==2.0.5
Jinja2==3.1.2
jsnapy==1.3.6
junos-eznc==2.6.0
jxmlease==1.0.1
lxml==4.9.1
MarkupSafe==2.1.1
ncclient==0.6.9
netaddr==0.8.0
packaging==22.0
paramiko==2.12.0
pycparser==2.21
PyNaCl==1.5.0
pyparsing==3.0.9
pyserial==3.5
PyYAML==6.0
resolvelib==0.5.4
scp==0.14.4
six==1.16.0
transitions==0.9.0
xmltodict==0.13.0
yamlordereddictloader==0.4.0

OS / Environment

Juniper MX960 running JUNOS 20.4R3-S3.4

Summary

  1. Bug occurs regardless of Python versions tested (3.7, 3.8, 3.9, 3.10)
  2. Bug occurs upon installation of ansible-core version 2.12.9 or greater
  3. Bug only occurs while using 'juniper.device.pyez' connection type. 'local' connection type works as expected.

Steps to reproduce

- name: backup, configure, rollback
  hosts: acm-lab-core1.custcbb.local
  collections:
    - juniper.device
  connection: juniper.device.pyez
  gather_facts: no
  tasks:
    - juniper.device.config:
        check: false
        commit: false
        dest: "backup/{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}_{{ inventory_hostname_short }}.config"
        diff: false
        retrieve: "committed"

Expected results

For the juniper.device.config task to execute successfully and report an "ok" status

Actual results

Successfully built ansible-core
Installing collected packages: ansible-core
  Attempting uninstall: ansible-core
    Found existing installation: ansible-core 2.12.8
    Uninstalling ansible-core-2.12.8:
      Successfully uninstalled ansible-core-2.12.8
Successfully installed ansible-core-2.12.9
containeruser@acm-qalab-nre01:/data$ ansible-playbook -e "@creds.json" pb.load-config.yaml 

PLAY [backup, configure, rollback] *********************************************

TASK [juniper.device.config] ***************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [acm-lab-core1.custcbb.local]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}

Fully verbose (-vvvv) output for the final task:

TASK [juniper.device.config] ***************************************************
task path: /data/pb.load-config.yaml:9
Loading collection ansible.netcommon from /home/containeruser/.ansible/collections/ansible_collections/ansible/netcommon
The full traceback is:
Traceback (most recent call last):
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 262, in __getattr__
    return self.__dict__[name]
KeyError: '_nonetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 985, in _set_plugin_options
    plugin = getattr(self._connection, '_%s' % plugin_type)
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 270, in __getattr__
    raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'Connection' object has no attribute '_nonetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 262, in __getattr__
    return self.__dict__[name]
KeyError: 'nonetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 159, in run
    res = self._execute()
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 550, in _execute
    plugin_vars = self._set_connection_options(cvars, templar)
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 1067, in _set_connection_options
    varnames.extend(self._set_plugin_options(plugin_type, variables, templar, task_keys))
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 988, in _set_plugin_options
    plugin = getattr(self._connection, plugin_type)
  File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 270, in __getattr__
    raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [acm-lab-core1.custcbb.local]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
slefol commented 1 year ago

I encounter the same bug with napalm.napalm.get_facts and juniper.device.table modules. Like netwrknerd, the bug occurs upon installation of ansible-core version 2.12.9 or greater and while using 'juniper.device.pyez' connection type ('local' connection type works as expected).

joaovp commented 1 year ago

Tried with ansible 6.5.0 and ansible-core 2.13.5 to hit the same issue.

Although the workaround of setting "connection: local" can work, in case the device has "netconf ssh rate-limit" the lack of juniper.device.pyez is a big limitation as per documentation.

connection: local Execute the modules locally on the Ansible control node but establish a separate connection to a host for each task in the play that performs operations on the host.
chidanandpujar commented 1 year ago

Hi ,

          Issue looks to be related to ansible python package version and works fine with ansible==5.4.0 / ansible-core-2.12.3 as of now .
~/ansible_galaxy_v101/ansible-junos-stdlib/tests# pip freeze
ansible==5.4.0
ansible-core==2.12.3
bcrypt==4.0.1
cffi==1.15.1
colorama==0.4.6
configparser==5.3.0
cryptography==39.0.0
future==0.18.3
icdiff==1.9.1
Jinja2==3.0.2
jsnapy==1.3.7
junos-eznc==2.6.6
jxmlease==1.0.3
lxml==4.9.2
MarkupSafe==2.1.2
ncclient==0.6.13
netaddr==0.8.0
packaging==23.0
paramiko==3.0.0
pycparser==2.21
pyez==0.1.1
PyNaCl==1.5.0
pyparsing==3.0.9
pyserial==3.5
PyYAML==6.0
resolvelib==0.5.4
scp==0.14.5
six==1.16.0
transitions==0.9.0
xmltodict==0.13.0
yamlordereddictloader==0.4.0

~/ansible_galaxy_v101/ansible-junos-stdlib/tests# cat persistent_conn.yml
---
- name: 'Test pyez connection'
  hosts: test 
  connection: juniper.device.pyez  

  gather_facts: no
  collections:
    - juniper.device

# The example here uses inventory file for user-authentication.
# the command to be used will look something like below
# ansible-playbook persistent_conn.yml -i inventory

  tasks:
    # Command module executed
    - name: show version with command
      command:
        commands:
          - "show version"
      register: junos_result

    - name: "Print the response"
      debug:
        var: junos_result 

    # Facts module executed
    - name: "Get facts"
      facts:
      register: response

    # Config module executed
    - name: SET JUNOS CONFIG
      config:
        load: "set"
        format: "set"
        lines: 'set system login message "This is login message"'
        comment: "comment"
        ignore_warning: "True"
        config_mode: private
      register: junos_response

# close connection
:~/ansible_galaxy_v101/ansible-junos-stdlib/tests# ansible-playbook persistent_conn.yml

PLAY [Test pyez connection] ***********************************************************************************************************************************************

TASK [show version with command] ******************************************************************************************************************************************
ok: [test]

TASK [Print the response] *************************************************************************************************************************************************
ok: [test] => {
    "junos_result": {
        "changed": false,
        "command": "show version",
        "failed": false,
        "format": "text",
        "msg": "The command executed successfully.",
        "stdout": "\nHostname: evoeventtestd\nModel: mx960\nJunos: 20.2R3-S3.6\nJUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]\nJUNOS libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS na telemetry [20.2R3-S3.6]\nJUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS RPD Telemetry Application [20.2R3-S3.6]\nRedis [20211110.173530_builder_junos_202_r3_s3]\nJUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Openconfig [20.2R3-S3.6]\nJUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]\nJUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]\nJUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]\n",
        "stdout_lines": [
            "",
            "Hostname: evoeventtestd",
            "Model: mx960",
            "Junos: 20.2R3-S3.6",
            "JUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS na telemetry [20.2R3-S3.6]",
            "JUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS RPD Telemetry Application [20.2R3-S3.6]",
            "Redis [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Openconfig [20.2R3-S3.6]",
            "JUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]",
           "JUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]",
            "JUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]"
        ]
    }
}

TASK [Get facts] **********************************************************************************************************************************************************
ok: [test]

TASK [SET JUNOS CONFIG] ***************************************************************************************************************************************************
ok: [test]

PLAY RECAP ****************************************************************************************************************************************************************
test                       : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

~/ansible_galaxy_v101/ansible-junos-stdlib/tests# cat persistent_conn.yml
---
- name: 'Test pyez connection'
 hosts: test 
  connection: local 

  gather_facts: no
  collections:
    - juniper.device

# The example here uses inventory file for user-authentication.
# the command to be used will look something like below
# ansible-playbook persistent_conn.yml -i inventory

  tasks:
    # Command module executed
    - name: show version with command
      command:
        commands:
          - "show version"
      register: junos_result

    - name: "Print the response"
      debug:
        var: junos_result 

    # Facts module executed
    - name: "Get facts"
      facts:
      register: response

    # Config module executed
    - name: SET JUNOS CONFIG
      config:
        load: "set"
        format: "set"
        lines: 'set system login message "This is login message"'
        comment: "comment"
        ignore_warning: "True"
        config_mode: private
      register: junos_response

# close connection
:~/ansible_galaxy_v101/ansible-junos-stdlib/tests# ansible-playbook persistent_conn.yml

PLAY [Test pyez connection] ***********************************************************************************************************************************************

TASK [show version with command] ******************************************************************************************************************************************
ok: [test]

TASK [Print the response] *************************************************************************************************************************************************
ok: [test] => {
    "junos_result": {
        "changed": false,
        "command": "show version",
        "failed": false,
        "format": "text",
        "msg": "The command executed successfully.",
        "stdout": "\nHostname: evoeventtestd\nModel: mx960\nJunos: 20.2R3-S3.6\nJUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]\nJUNOS libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS na telemetry [20.2R3-S3.6]\nJUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS RPD Telemetry Application [20.2R3-S3.6]\nRedis [20211110.173530_builder_junos_202_r3_s3]\nJUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Openconfig [20.2R3-S3.6]\nJUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]\nJUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]\nJUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]\n",
        "stdout_lines": [
            "",
            "Hostname: evoeventtestd",
            "Model: mx960",
            "Junos: 20.2R3-S3.6",
            "JUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS na telemetry [20.2R3-S3.6]",
            "JUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS RPD Telemetry Application [20.2R3-S3.6]",
            "Redis [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Openconfig [20.2R3-S3.6]",
            "JUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]",
            "JUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]"
        ]
    }
}

TASK [Get facts] **********************************************************************************************************************************************************
ok: [test]

TASK [SET JUNOS CONFIG] ***************************************************************************************************************************************************
ok: [test]

PLAY RECAP ****************************************************************************************************************************************************************
test                       : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Thanks Chidanand

slefol commented 1 year ago

the solution given on the page https://github.com/ansible/ansible/issues/79371 works ! (ansible-core version 2.14.3)

slefol commented 1 year ago

version 2.15.0 does not solve the problem for me ! (with ansible_connection: juniper.device.pyez and with napalm.napalm.get_facts and juniper.device.table modules)

This version works if I use this configuration : ansible_connection: ansible.netcommon.netconf ansible_network_os: junipernetworks.junos.junos

and the juniper_junos_table module instead of the juniper.device.table module

chidanandpujar commented 1 year ago

@slefol Thanks for sharing the info. Tested the fix mentioned in the https://github.com/ansible/ansible/issues/79371 and it works fine .

    # deals with networking sub_plugins (network_cli/httpapi/netconf)
    sub = getattr(self._connection, '_sub_plugin', None)
    if sub and sub.get('type') != 'external':
ansible_galaxy_release_v102_final_test3/ansible-junos-stdlib/tests# ansible-playbook persistent_conn.yml 

PLAY [Explicit host argument] *********************************************************************************************************************************************

TASK [show version with command] ******************************************************************************************************************************************
ok: [test]

TASK [Test RPC] ***********************************************************************************************************************************************************
ok: [test]

PLAY RECAP ****************************************************************************************************************************************************************
test                       : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

cat persistent_conn.yml 
---
- name: 'Explicit host argument'
  hosts: test 
#  connection: local
  connection: juniper.device.pyez

  gather_facts: no
  collections:
    - juniper.device

# The example here uses inventory file for user-authentication.
# the command to be used will look something like below
# ansible-playbook persistent_conn.yml -i inventory

  tasks:
    # Command module executed
    - name: show version with command
      command:
        commands:
          - "show version"
      register: junos_result

    # Rpc module executed
    - name: "Test RPC"
      rpc:
        rpcs:
          - "get-config"
          - "get-software-information"

# close connection

Thanks & Regards Chidanand

slefol commented 1 year ago

@Chidanand yes sorry it works ! I thought this fix was integrated in version 2.15.0

ntwrknrd commented 1 year ago

@slefol

and the juniper_junos_table module instead of the juniper.device.table module

Is this still the case? There is no known working configuration of ansible.netcommon.netconf + juniper.device.table ?

slefol commented 1 year ago

juniper_junos_table module + ansible_connection: ansible.netcommon.netconf works without or with fix juniper.device.table module + ansible_connection: juniper.device.pyez only works with fix

neonman63 commented 1 year ago

Hello, same issue for zabbix.zabbix.zabbix_host

ntwrknrd commented 1 year ago

Hi ,

          Issue looks to be related to ansible python package version and works fine with ansible==5.4.0 / ansible-core-2.12.3 as of now .
~/ansible_galaxy_v101/ansible-junos-stdlib/tests# pip freeze
ansible==5.4.0
ansible-core==2.12.3
bcrypt==4.0.1
cffi==1.15.1
colorama==0.4.6
configparser==5.3.0
cryptography==39.0.0
future==0.18.3
icdiff==1.9.1
Jinja2==3.0.2
jsnapy==1.3.7
junos-eznc==2.6.6
jxmlease==1.0.3
lxml==4.9.2
MarkupSafe==2.1.2
ncclient==0.6.13
netaddr==0.8.0
packaging==23.0
paramiko==3.0.0
pycparser==2.21
pyez==0.1.1
PyNaCl==1.5.0
pyparsing==3.0.9
pyserial==3.5
PyYAML==6.0
resolvelib==0.5.4
scp==0.14.5
six==1.16.0
transitions==0.9.0
xmltodict==0.13.0
yamlordereddictloader==0.4.0

~/ansible_galaxy_v101/ansible-junos-stdlib/tests# cat persistent_conn.yml
---
- name: 'Test pyez connection'
  hosts: test 
  connection: juniper.device.pyez  

  gather_facts: no
  collections:
    - juniper.device

# The example here uses inventory file for user-authentication.
# the command to be used will look something like below
# ansible-playbook persistent_conn.yml -i inventory

  tasks:
    # Command module executed
    - name: show version with command
      command:
        commands:
          - "show version"
      register: junos_result

    - name: "Print the response"
      debug:
        var: junos_result 

    # Facts module executed
    - name: "Get facts"
      facts:
      register: response

    # Config module executed
    - name: SET JUNOS CONFIG
      config:
        load: "set"
        format: "set"
        lines: 'set system login message "This is login message"'
        comment: "comment"
        ignore_warning: "True"
        config_mode: private
      register: junos_response

# close connection
:~/ansible_galaxy_v101/ansible-junos-stdlib/tests# ansible-playbook persistent_conn.yml

PLAY [Test pyez connection] ***********************************************************************************************************************************************

TASK [show version with command] ******************************************************************************************************************************************
ok: [test]

TASK [Print the response] *************************************************************************************************************************************************
ok: [test] => {
    "junos_result": {
        "changed": false,
        "command": "show version",
        "failed": false,
        "format": "text",
        "msg": "The command executed successfully.",
        "stdout": "\nHostname: evoeventtestd\nModel: mx960\nJunos: 20.2R3-S3.6\nJUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]\nJUNOS libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS na telemetry [20.2R3-S3.6]\nJUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS RPD Telemetry Application [20.2R3-S3.6]\nRedis [20211110.173530_builder_junos_202_r3_s3]\nJUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Openconfig [20.2R3-S3.6]\nJUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]\nJUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]\nJUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]\n",
        "stdout_lines": [
            "",
            "Hostname: evoeventtestd",
            "Model: mx960",
            "Junos: 20.2R3-S3.6",
            "JUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS na telemetry [20.2R3-S3.6]",
            "JUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS RPD Telemetry Application [20.2R3-S3.6]",
            "Redis [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Openconfig [20.2R3-S3.6]",
            "JUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]",
           "JUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]",
            "JUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]"
        ]
    }
}

TASK [Get facts] **********************************************************************************************************************************************************
ok: [test]

TASK [SET JUNOS CONFIG] ***************************************************************************************************************************************************
ok: [test]

PLAY RECAP ****************************************************************************************************************************************************************
test                       : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

~/ansible_galaxy_v101/ansible-junos-stdlib/tests# cat persistent_conn.yml
---
- name: 'Test pyez connection'
 hosts: test 
  connection: local 

  gather_facts: no
  collections:
    - juniper.device

# The example here uses inventory file for user-authentication.
# the command to be used will look something like below
# ansible-playbook persistent_conn.yml -i inventory

  tasks:
    # Command module executed
    - name: show version with command
      command:
        commands:
          - "show version"
      register: junos_result

    - name: "Print the response"
      debug:
        var: junos_result 

    # Facts module executed
    - name: "Get facts"
      facts:
      register: response

    # Config module executed
    - name: SET JUNOS CONFIG
      config:
        load: "set"
        format: "set"
        lines: 'set system login message "This is login message"'
        comment: "comment"
        ignore_warning: "True"
        config_mode: private
      register: junos_response

# close connection
:~/ansible_galaxy_v101/ansible-junos-stdlib/tests# ansible-playbook persistent_conn.yml

PLAY [Test pyez connection] ***********************************************************************************************************************************************

TASK [show version with command] ******************************************************************************************************************************************
ok: [test]

TASK [Print the response] *************************************************************************************************************************************************
ok: [test] => {
    "junos_result": {
        "changed": false,
        "command": "show version",
        "failed": false,
        "format": "text",
        "msg": "The command executed successfully.",
        "stdout": "\nHostname: evoeventtestd\nModel: mx960\nJunos: 20.2R3-S3.6\nJUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]\nJUNOS libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS py base [20211110.173530_builder_junos_202_r3_s3]\nJUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]\nJUNOS na telemetry [20.2R3-S3.6]\nJUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]\nJUNOS RPD Telemetry Application [20.2R3-S3.6]\nRedis [20211110.173530_builder_junos_202_r3_s3]\nJUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Openconfig [20.2R3-S3.6]\nJUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]\nJUNOS daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]\nJUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]\nJUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]\nJUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]\nJUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]\nJUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]\nJUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]\nJUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]\n",
        "stdout_lines": [
            "",
            "Hostname: evoeventtestd",
            "Model: mx960",
            "Junos: 20.2R3-S3.6",
            "JUNOS OS Kernel 64-bit  [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS libs [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS runtime [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS time zone information [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS network stack and utilities [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS libs compat32 [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS 32-bit compatibility [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS sflow mx [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py extensions [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base2 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS py base [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS OS vmguest [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS crypto [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS OS boot-ve files [20210722.b0da34e0_builder_stable_11-204ab]",
            "JUNOS na telemetry [20.2R3-S3.6]",
            "JUNOS Security Intelligence [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs compat32 [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx runtime [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS RPD Telemetry Application [20.2R3-S3.6]",
            "Redis [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS common platform support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Openconfig [20.2R3-S3.6]",
            "JUNOS mtx network modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx modules [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx libs [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SQL Sync Daemon [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mtx Data Plane Crypto Support [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS mx daemons [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS appidd-mx application-identification daemon [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Linux Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Simulation Package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services URL Filter package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TLB Service PIC package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Telemetry [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services TCP-LOG [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SSL [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services SOFTWIRE [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Stateful Firewall [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RTCOM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services RPM [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services PCEF package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services NAT [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Mobile Subscriber Service Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services MobileNext Software package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Logging Report Framework package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services LL-PDF Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Jflow Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Deep Packet Inspection package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IPSec [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services IDS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS IDP Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services HTTP Content Management package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Crypto [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Captive Portal and Content Delivery Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services COS [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS AppId Services [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services Application Level Gateways [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Services AACL Container package [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS SDN Software Suite [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Extension Toolkit [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux9) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (wrlinux) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MXSPC3) [20.2R3-S3.6]",
            "JUNOS Packet Forwarding Engine Support (MX/EX92XX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (M/T Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (aft) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Packet Forwarding Engine Support (MX Common) [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS J-Insight [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jfirmware [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS Online Documentation [20211110.173530_builder_junos_202_r3_s3]",
            "JUNOS jail runtime [20210722.b0da34e0_builder_stable_11-204ab]"
        ]
    }
}

TASK [Get facts] **********************************************************************************************************************************************************
ok: [test]

TASK [SET JUNOS CONFIG] ***************************************************************************************************************************************************
ok: [test]

PLAY RECAP ****************************************************************************************************************************************************************
test                       : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Thanks Chidanand

Unfortunately this pip freeze is out of date. It worked on pip 21 but no longer does on pip 23:

(py3.9-junos) [chris.jones@tower-web-dev03 ~]$ pip install -r requirements.txt
Collecting ansible==5.4.0 (from -r requirements.txt (line 1))
  Downloading ansible-5.4.0.tar.gz (38.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.3/38.3 MB 35.7 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting ansible-core==2.12.3 (from -r requirements.txt (line 2))
  Downloading ansible-core-2.12.3.tar.gz (7.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.8/7.8 MB 63.8 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting bcrypt==4.0.1 (from -r requirements.txt (line 3))
  Downloading bcrypt-4.0.1-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (593 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 593.5/593.5 kB 42.6 MB/s eta 0:00:00
Collecting cffi==1.15.1 (from -r requirements.txt (line 4))
  Downloading cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.2/441.2 kB 35.9 MB/s eta 0:00:00
Collecting colorama==0.4.6 (from -r requirements.txt (line 5))
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting configparser==5.3.0 (from -r requirements.txt (line 6))
  Downloading configparser-5.3.0-py3-none-any.whl (19 kB)
Collecting cryptography==39.0.0 (from -r requirements.txt (line 7))
  Downloading cryptography-39.0.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 47.2 MB/s eta 0:00:00
Collecting future==0.18.3 (from -r requirements.txt (line 8))
  Downloading future-0.18.3.tar.gz (840 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 840.9/840.9 kB 52.2 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting icdiff==1.9.1 (from -r requirements.txt (line 9))
  Downloading icdiff-1.9.1.tar.gz (9.1 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting Jinja2==3.0.2 (from -r requirements.txt (line 10))
  Downloading Jinja2-3.0.2-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.8/133.8 kB 19.5 MB/s eta 0:00:00
Collecting jsnapy==1.3.7 (from -r requirements.txt (line 11))
  Downloading jsnapy-1.3.7-py2.py3-none-any.whl (50 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.1/50.1 kB 9.8 MB/s eta 0:00:00
Collecting junos-eznc==2.6.6 (from -r requirements.txt (line 12))
  Downloading junos_eznc-2.6.6-py2.py3-none-any.whl (197 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 197.4/197.4 kB 23.5 MB/s eta 0:00:00
Collecting jxmlease==1.0.3 (from -r requirements.txt (line 13))
  Downloading jxmlease-1.0.3-py2.py3-none-any.whl (37 kB)
Collecting lxml==4.9.2 (from -r requirements.txt (line 14))
  Downloading lxml-4.9.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (7.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.1/7.1 MB 33.4 MB/s eta 0:00:00
Collecting MarkupSafe==2.1.2 (from -r requirements.txt (line 15))
  Downloading MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting ncclient==0.6.13 (from -r requirements.txt (line 16))
  Downloading ncclient-0.6.13.tar.gz (105 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 105.7/105.7 kB 16.6 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting netaddr==0.8.0 (from -r requirements.txt (line 17))
  Downloading netaddr-0.8.0-py2.py3-none-any.whl (1.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 30.5 MB/s eta 0:00:00
Collecting packaging==23.0 (from -r requirements.txt (line 18))
  Downloading packaging-23.0-py3-none-any.whl (42 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.7/42.7 kB 7.3 MB/s eta 0:00:00
Collecting paramiko==3.0.0 (from -r requirements.txt (line 19))
  Downloading paramiko-3.0.0-py3-none-any.whl (210 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 210.8/210.8 kB 27.8 MB/s eta 0:00:00
Collecting pycparser==2.21 (from -r requirements.txt (line 20))
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 20.4 MB/s eta 0:00:00
Collecting pyez==0.1.1 (from -r requirements.txt (line 21))
  Downloading pyez-0.1.1.tar.gz (3.3 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting PyNaCl==1.5.0 (from -r requirements.txt (line 22))
  Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 29.6 MB/s eta 0:00:00
Collecting pyparsing==3.0.9 (from -r requirements.txt (line 23))
  Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 15.6 MB/s eta 0:00:00
Collecting pyserial==3.5 (from -r requirements.txt (line 24))
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.6/90.6 kB 14.7 MB/s eta 0:00:00
Collecting PyYAML==6.0 (from -r requirements.txt (line 25))
  Downloading PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (661 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 661.8/661.8 kB 24.3 MB/s eta 0:00:00
Collecting resolvelib==0.5.4 (from -r requirements.txt (line 26))
  Downloading resolvelib-0.5.4-py2.py3-none-any.whl (12 kB)
Collecting scp==0.14.5 (from -r requirements.txt (line 27))
  Downloading scp-0.14.5-py2.py3-none-any.whl (8.7 kB)
Collecting six==1.16.0 (from -r requirements.txt (line 28))
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting transitions==0.9.0 (from -r requirements.txt (line 29))
  Downloading transitions-0.9.0-py2.py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.7/97.7 kB 17.8 MB/s eta 0:00:00
Collecting xmltodict==0.13.0 (from -r requirements.txt (line 30))
  Downloading xmltodict-0.13.0-py2.py3-none-any.whl (10.0 kB)
Collecting yamlordereddictloader==0.4.0 (from -r requirements.txt (line 31))
  Downloading yamlordereddictloader-0.4.0.tar.gz (3.3 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: setuptools>0.6 in /opt/my-envs/py3.9-junos/lib/python3.9/site-packages (from ncclient==0.6.13->-r requirements.txt (line 16)) (58.1.0)
Building wheels for collected packages: ansible, ansible-core, future, icdiff, ncclient, pyez, yamlordereddictloader
  Building wheel for ansible (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for ansible (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [478570 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib
      creating build/lib/ansible_collections
      copying ansible_collections/ansible_release.py -> build/lib/ansible_collections
      running egg_info
      writing ansible.egg-info/PKG-INFO
      writing dependency_links to ansible.egg-info/dependency_links.txt
      writing requirements to ansible.egg-info/requires.txt
      writing top-level names to ansible.egg-info/top_level.txt
      reading manifest file 'ansible.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching 'README'
      adding license file 'COPYING'
      writing manifest file 'ansible.egg-info/SOURCES.txt'
      /tmp/pip-build-env-bo8pt1wn/overlay/lib/python3.9/site-packages/setuptools/command/build_py.py:204: _Warning: Package 'ansible_collections.amazon.aws' is absent from the `packages` configuration.
      !!
... goes on for endless list of absent packages.
ntwrknrd commented 5 months ago

Any update here? I recently tested in a rhel9 execution environment:

[nre@nre-podman ~]$ docker run -it --rm localhost/junos-dev /bin/bash
bash-5.1$ pip freeze
ansible==9.4.0
ansible-core==2.16.5
ansible-runner==2.3.6
bcrypt==4.1.2
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
colorama==0.4.6
configparser==6.0.1
cryptography==42.0.5
docutils==0.20.1
dumb-init==1.2.5
future==1.0.0
icdiff==1.9.1
idna==3.6
Jinja2==3.1.3
jsnapy==1.3.7
junos-eznc==2.7.0
jxmlease==1.0.3
lockfile==0.12.2
lxml==5.2.1
MarkupSafe==2.1.5
ncclient==0.6.15
netaddr==1.2.1
packaging==23.2
paramiko==3.4.0
pexpect==4.9.0
psutil==5.9.8
ptyprocess==0.7.0
pycparser==2.22
pyez==0.1.1
PyNaCl==1.5.0
pynetbox==7.3.3
pyparsing==3.1.2
pyserial==3.5
python-daemon==3.0.1
pytz==2024.1
PyYAML==6.0.1
requests==2.31.0
resolvelib==1.0.1
scp==0.14.5
six==1.16.0
transitions==0.9.0
urllib3==2.2.1
xmltodict==0.13.0
yamlordereddictloader==0.4.2

Running into same errors:

TASK [Initialize variables] ****************************************************
task path: /runner/project/playbooks/monitor-alarms.yml:9
Loading collection ansible.netcommon from /usr/local/lib/python3.11/site-packages/ansible_collections/ansible/netcommon
eyJ1dWlkIjogIjE3YjIzYzRjLWMwNTctNDVkYi1iOTE1LWI1YzM2NDU1Mzc1OCJ9e30=
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/connection/__init__.py", line 324, in __getattr__
    return self.__dict__[name]
           ~~~~~~~~~~~~~^^^^^^
KeyError: '_nonetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ansible/executor/task_executor.py", line 1009, in _set_plugin_options
    plugin = getattr(self._connection, '_%s' % plugin_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/connection/__init__.py", line 332, in __getattr__
    raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'Connection' object has no attribute '_nonetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/connection/__init__.py", line 324, in __getattr__
    return self.__dict__[name]
           ~~~~~~~~~~~~~^^^^^^
KeyError: 'nonetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ansible/executor/task_executor.py", line 165, in run
    res = self._execute()
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible/executor/task_executor.py", line 581, in _execute
    plugin_vars = self._set_connection_options(cvars, templar)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible/executor/task_executor.py", line 1091, in _set_connection_options
    varnames.extend(self._set_plugin_options(plugin_type, variables, templar, task_keys))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible/executor/task_executor.py", line 1012, in _set_plugin_options
    plugin = getattr(self._connection, plugin_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ansible/plugins/connection/__init__.py", line 332, in __getattr__
    raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [acm-lab-core1.custcbb.local]: FAILED! => {
    "msg": "Unexpected failure during module execution: 'Connection' object has no attribute 'nonetype'",
    "stdout": ""
}

PLAY RECAP *********************************************************************
acm-lab-core1.custcbb.local : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
slefol commented 5 months ago

Tested version 2.18.0.dev0 and it works fine. (see https://github.com/ansible/ansible/pull/82954)

dineshbaburam91 commented 4 months ago

A fix for the issue is now available in the Ansible 2.16.6 version. Please update the Ansible core module to ensure the issue is resolved.

PLAY [Test juniper.device.table PyEZ table/view module.] ******************************************************************************************************************

TASK [Retrieve LLDP Neighbor Information Using PyEZ-included Table] *******************************************************************************************************
ok: [pyez_connection_testcases]

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

TASK [Retrieve routes within 192.68.1/8] **********************************************************************************************************************************
ok: [pyez_connection_testcases]

TASK [check TEST 2] *******************************************************************************************************************************************************
ok: [pyez_connection_testcases] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Retrieve ethernet devices] ******************************************************************************************************************************************
ok: [pyez_connection_testcases]

TASK [check TEST 3] *******************************************************************************************************************************************************
ok: [pyez_connection_testcases] => {
    "changed": false,
    "msg": "All assertions passed"
}

PLAY RECAP ****************************************************************************************************************************************************************
pyez_connection_testcases  : ok=6    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
slefol commented 4 months ago

hi, Yes, I confirm that it works fine with ansible-core 2.16.6.