Automation

 View Only
last person joined: 6 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Ansible error when attempting to Connect to Junos Device using juniper.device.pyez

    Posted 09-28-2022 06:04
    Hi dear community,

    While attempting to connect to SRX devices using Pyez with Ansible i get the following error  :

    'Connection' object has no attribute 'nonetype'

    Here is my playbook :

    ---
    - name: Get Device Information
      hosts: router_juniper
      connection: juniper.device.pyez
      gather_facts: no
    
      vars:
        user: "{{ ansible_netconf_username }}"
        passwd: "{{ ansible_netconf_password }}"
    
      vars_files:
        - /Users/jeremierouzet/jeysible/vars/juniper.yml
    
      tasks:
        - name: Retrieve facts from devices running Junos OS
          juniper.device.facts:
            savedir: "{{ playbook_dir }}"
    
        - name: Get hardware inventory
          juniper.device.command:
            commands: "show chassis hardware"
            dest_dir: "{{ playbook_dir }}"​


    I have installed all the requested modules thanks to this page :

    Ansible for Junos OS Server Requirements

    Juniper remove preview
    Ansible for Junos OS Server Requirements
    Juniper Networks supports using Ansible to manage devices running Junos OS and provides Ansible modules that you can use to perform operational and configuration tasks on the devices. The Juniper Networks modules are distributed through the following Ansible collections and roles that are hosted on the Ansible Galaxy website:
    View this on Juniper >


    Here are some of the outputs when i run the playbook :

    Loading collection ansible.netcommon from /Users/jeremierouzet/.ansible/collections/ansible_collections/ansible/netcommon
    The full traceback is:
    Traceback (most recent call last):
      File "/opt/homebrew/lib/python3.10/site-packages/ansible/plugins/connection/__init__.py", line 293, in __getattr__
        return self.__dict__[name]
    KeyError: '_nonetype'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/opt/homebrew/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 1009, in _set_plugin_options
        plugin = getattr(self._connection, '_%s' % plugin_type)
      File "/opt/homebrew/lib/python3.10/site-packages/ansible/plugins/connection/__init__.py", line 301, 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 "/opt/homebrew/lib/python3.10/site-packages/ansible/plugins/connection/__init__.py", line 293, in __getattr__
        return self.__dict__[name]
    KeyError: 'nonetype'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/opt/homebrew/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 158, in run
        res = self._execute()
      File "/opt/homebrew/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 574, in _execute
        plugin_vars = self._set_connection_options(cvars, templar)
      File "/opt/homebrew/lib/python3.10/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 "/opt/homebrew/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 1012, in _set_plugin_options
        plugin = getattr(self._connection, plugin_type)
      File "/opt/homebrew/lib/python3.10/site-packages/ansible/plugins/connection/__init__.py", line 301, in __getattr__
        raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
    AttributeError: 'Connection' object has no attribute 'nonetype'
    fatal: [jeyniper01]: FAILED! => {
        "msg": "Unexpected failure during module execution.",
        "stdout": ""
    }


    Can you please advise ?

    Thank you in advance for your kind help !

    Jeremie

    ------------------------------
    Jeremie Rouzet
    ------------------------------


  • 2.  RE: Ansible error when attempting to Connect to Junos Device using juniper.device.pyez

    Posted 10-14-2022 20:06
    Hi Jeremie,

    Are you using a dedicated python virtual environment? I had the same error when I was using one and it worked once I started using the default python environment where I then installed the pyez library with pip.

    -Mike

    ------------------------------
    MICHAEL GARIPPO
    ------------------------------



  • 3.  RE: Ansible error when attempting to Connect to Junos Device using juniper.device.pyez

    Posted 11-15-2023 06:05

    I ran into something similar using a virtual environment. 

    AttributeError: 'Connection' object has no attribute 'nonetype'<u5:p></u5:p>

    I followed the workaround in this Ansible issue on GitHub: https://github.com/ansible/ansible/issues/79371



    ------------------------------
    Jessica Garrison
    ------------------------------