Developer

 View Only
last person joined: 2 days ago 

Expand all | Collapse all

\nansible.module_utils.connection.ConnectionError: Method not found

This thread has been viewed 44 times
  • 1.  \nansible.module_utils.connection.ConnectionError: Method not found

    Posted Nov 01, 2021 11:38 AM

    Hi All,

    I keep on having this error when I try to run the sample playbook I am testing on my switch. I am pretty new using Ansible for Aruba (though I understand at least how Ansible works).


    fatal: [aoscx_1]: FAILED! => {

        "ansible_facts": {

            "discovered_interpreter_python": "/usr/bin/python"

        },

        "changed": false,

        "module_stderr": "Traceback (most recent call last):\n  File \"/home/administrator/.ansible/tmp/ansible-local-1512yoz5g5cy/ansible-tmp-1635749575.7712095-1524-155447344171476/AnsiballZ_aoscx_vlan.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/administrator/.ansible/tmp/ansible-local-1512yoz5g5cy/ansible-tmp-1635749575.7712095-1524-155447344171476/AnsiballZ_aoscx_vlan.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/administrator/.ansible/tmp/ansible-local-1512yoz5g5cy/ansible-tmp-1635749575.7712095-1524-155447344171476/AnsiballZ_aoscx_vlan.py\", line 41, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_vlan.py\", line 217, in <module>\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_vlan.py\", line 163, in main\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx.py\", line 428, in __init__\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx.py\", line 449, in get_switch_platform\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx.py\", line 343, in get\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx.py\", line 208, in get\n  File \"/tmp/ansible_aoscx_vlan_payload_etgvPH/ansible_aoscx_vlan_payload.zip/ansible/module_utils/connection.py\", line 195, in __rpc__\nansible.module_utils.connection.ConnectionError: Method not found\n",

        "module_stdout": "",

        "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",

        "rc": 1

    }

    ~    


    My Inventory

    all:

      hosts:

        aoscx_1:

          ansible_host: 10.10.10.70

          ansible_user: admin

          ansible_password: aruba123

          ansible_network_os: arubanetworks.aoscx.aoscx

          ansible_connection: arubanetworks.aoscx.aoscx  # REST API via pyaoscx connection method

          ansible_aoscx_validate_certs: False

          ansible_aoscx_use_proxy: False

          ansible_acx_no_proxy: True

                                   

    My playbook

    - hosts: all

      collections:

        - arubanetworks.aoscx

      gather_facts: false   

      tasks:

        - name: Create VLAN 214 with description and name

          aoscx_vlan:

            vlan_id: 214

            name: Aruba Test

            description: This is VLAN 214


    I followed the instruction on how to setup the aruba modules from this website, Getting Started with Ansible and AOS-CX

    but for some reason, I'm getting this error message. My ansible version is 2.11 (core),  python 3.6.x, CentOS7. Hope someone can point me what am I missing. 

    Many thanks!

    Melchor





    ------------------------------
    Melchor M.
    ------------------------------


  • 2.  RE: \nansible.module_utils.connection.ConnectionError: Method not found

    Posted Nov 01, 2021 08:23 PM
    Hello!

    Although you may have python 3 installed it appears your Ansible is using your python2 based on this output:
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/administrator/.ansible/tmp/ansible-local-1512yoz5g5cy/ansible-tmp-1635749575.7712095-1524-155447344171476/AnsiballZ_aoscx_vlan.py\", line 41, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File


    Please ensure you have `pyaoscx` installed via python 3 and you should be able to set the python interpreter to whichever path python 3 is installed in your system. Here are some guides to help you:
    https://developer.arubanetworks.com/aruba-aoscx/docs/getting-started-with-ansible-and-aos-cx

    Here's an example of doing it in the playbook:
    - hosts: all
      collections:
        - arubanetworks.aoscx
      vars:
        ansible_python_interpreter: /usr/bin/python3    
      gather_facts: False
      tasks:
        - name: Create VLAN 300 with description and name
          aoscx_vlan:
            vlan_id: 300
            name: UPLINK_VLAN
            description: This is VLAN 300
    ​


    ------------------------------
    Tiffany Chiapuzio-Wong
    ------------------------------



  • 3.  RE: \nansible.module_utils.connection.ConnectionError: Method not found

    Posted Nov 02, 2021 01:50 AM
    Hi Tiffany,

    Thanks for the reply. I set it to user python3 but still have the same result which is weird.  The pyaoscx is also installed. I run again the setup as per guide but I've got the same output. Should I just recreate the whole  control node?

    fatal: [aoscx_1]: FAILED! => {

        "changed": false,

        "module_stderr": "Traceback (most recent call last):\n  File \"/home/administrator/.ansible/tmp/ansible-local-4354aa28ovw6/ansible-tmp-1635831784.6012146-4366-268829809200697/AnsiballZ_aoscx_vlan.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/administrator/.ansible/tmp/ansible-local-4354aa28ovw6/ansible-tmp-1635831784.6012146-4366-268829809200697/AnsiballZ_aoscx_vlan.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/administrator/.ansible/tmp/ansible-local-4354aa28ovw6/ansible-tmp-1635831784.6012146-4366-268829809200697/AnsiballZ_aoscx_vlan.py\", line 41, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_aoscx_vlan_payload_e3nzovkq/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_vlan.py\", line 217, in <module>\n  File \"/tmp/ansible_aoscx_vlan_payload_e3nzovkq/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_vlan.py\", line 110, in main\n  File \"/tmp/ansible_aoscx_vlan_payload_e3nzovkq/ansible_aoscx_vlan_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py\", line 39, in __init__\n  File \"/tmp/ansible_aoscx_vlan_payload_e3nzovkq/ansible_aoscx_vlan_payload.zip/ansible/module_utils/connection.py\", line 195, in __rpc__\nansible.module_utils.connection.ConnectionError: Method not found\n",

        "module_stdout": "",

        "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",

        "rc": 1

    }

    Regards.

    Melchor


    ***** Update ******

    I created a new control node running on Ubuntu instead (though OS shouldn't be an issue at all)  and did a fresh install and seems to work but what I notice is that when I run the same sample playbook (VLAN creation), it keeps on applying the same changes which is not a normal behaviour. I might open a new thread about this I guess.



    ------------------------------
    Melchor M.
    ------------------------------



  • 4.  RE: \nansible.module_utils.connection.ConnectionError: Method not found

    MVP GURU
    Posted Nov 02, 2021 02:53 AM
    Hi Melchor,

    I get the same error and if i remove pyaoscx (pip3 uninstall pyaoscx and use
    ansible_connection: httpapi

    on my inventory

    it is working...

    ------------------------------
    PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...

    PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)

    PowerArubaCL: Powershell Module to use Aruba Central

    PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..

    ACEP / ACMX #107 / ACDX #1281
    ------------------------------



  • 5.  RE: \nansible.module_utils.connection.ConnectionError: Method not found

    Posted Nov 02, 2021 10:52 AM
    Are you using a virtual environment?

    Can you try executing this command?
    python3 -m pip install -r https://raw.githubusercontent.com/aruba/aoscx-ansible-collection/master/requirements.txt

    ------------------------------
    Tiffany Chiapuzio-Wong
    ------------------------------



  • 6.  RE: \nansible.module_utils.connection.ConnectionError: Method not found

    Posted Nov 02, 2021 08:36 PM
    Hi Tiffany,

    I tried that too. I guess my control node are in a total mess now so I decided to spin up a new VM instead and did a fresh install and it seems to work fine. I did try @alagoutte's suggestion to remove pyaoscx and that error message was solve but it leads to another issue that is why I setup a new control node for this purpose. 


    Regards.
    Melchor

    ------------------------------
    Melchor M.
    ------------------------------