Closed seunay0 closed 2 years ago
Do you receive this error with any other module? Also can you provide the python pyaoscx version and ansible aoscx collection version you're using?
here's my pyaoscx and aoscx versions: arubanetworks.aoscx 4.0.3
pyaoscx 2.2.1
No, i've not tried it with any other module
Execute the following commands to see the current versions you're using:
pip3 list
ansible-galaxy collection list
Since you're receiving a Login error - can you validate if the credentials you're including in your inventory are correct and you're able to successfully login? Here's a guide on our Developer Hub that describes how to get started and validate this information - https://developer.arubanetworks.com/aruba-aoscx/docs/getting-started-with-ansible-and-aos-cx
Alternatively you can using this cURL command to validate if the credentials you're providing are correct, replace IP, USER, PW with the values of your inventory, you should get a 200 Response - if not then you have the incorrect credentials: curl -i -k -X POST "https://**IP**/rest/v10.04/login?username=**USER**&password=**PW*" -H "accept: /*" -d ""
Example Output: (py3_env) ansible-control-machine$curl -i -k -X POST "https://10.6.7.16/rest/v10.04/login?username=admin&password=admin" -H "accept: /" -d "" HTTP/1.1 200 OK Server: nginx Date: Fri, 05 Aug 2022 16:02:37 GMT Content-Length: 0 Connection: keep-alive Set-Cookie: id=zcAsM8wA8Jgjft5l8qW3vw==; Path=/; HttpOnly; Secure Set-Cookie: user=eyJ1c2VyIjoiYWRtaW4iLCJsZXZlbCI6MTUsInR5cGUiOiJMT0NBTCIsIm1ldGhvZCI6IkxPQ0FMIn0=; Path=/; Secure X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Strict-Transport-Security: max-age=31536000; includeSubdomains; Content-Security-Policy: script-src 'self' 'unsafe-inline'; object-src 'none'; font-src *; media-src 'none'; form-action 'self';
here's my pyaoscx and aoscx versions:
arubanetworks.aoscx 4.0.3
pyaoscx 2.2.1
No, i've not tried it with any other module
Please upgrade to the most recent versions of the packages by using the following commands:
python3 -m pip install pyaoscx -U
ansible-galaxy collection install arubanetworks.aoscx --upgrade
Hi, i have upgraded both to the most recent versions.
pyaoscx 2.3.0
arubanetworks.aoscx 4.1.0
I am still getting a similar error, please see below
The full traceback is:
Traceback (most recent call last):
File "/home/.ansible/tmp/ansible-local-834701608i2b/ansible-tmp-1660243138.6353636-8370-107081048662631/AnsiballZ_aoscx_l2_interface.py", line 107, in <module>
_ansiballz_main()
File "/home/.ansible/tmp/ansible-local-834701608i2b/ansible-tmp-1660243138.6353636-8370-107081048662631/AnsiballZ_aoscx_l2_interface.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/.ansible/tmp/ansible-local-834701608i2b/ansible-tmp-16The full traceback is:
Traceback (most recent call last):
File "/home/.ansible/tmp/ansible-local-834701608i2b/ansible-tmp-1660243138.6353636-8370-107081048662631/AnsiballZ_aoscx_l2_interface.py", line 107, in <module>
_ansiballz_main()
File "/home/.ansible/tmp/ansible-local-834701608i2b/ansible-tmp-1660243138.6353636-8370-107081048662631/AnsiballZ_aoscx_l2_interface.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/.ansible/tmp/ansible-local-834701608i2b/ansible-tmp-1660243138.6353636-8370-107081048662631/AnsiballZ_aoscx_l2_interface.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_l2_interface', init_globals=dict(_module_fqn='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_l2_interface', _modlib_path=modlib_path),
File "/usr/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_l2_interface.py", line 703, in <module>
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_l2_interface.py", line 484, in main
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py", line 81, in get_pyaoscx_session
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py", line 47, in __init__
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
ansible.module_utils.connection.ConnectionError: LOGIN ERROR, FAIL: Login failed with status code 401: Login failed.60243138.6353636-8370-107081048662631/AnsiballZ_aoscx_l2_interface.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_l2_interface', init_globals=dict(_module_fqn='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_l2_interface', _modlib_path=modlib_path),
File "/usr/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_l2_interface.py", line 703, in <module>
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_l2_interface.py", line 484, in main
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py", line 81, in get_pyaoscx_session
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py", line 47, in __init__
File "/tmp/ansible_aoscx_l2_interface_payload_3x9u1a3r/ansible_aoscx_l2_interface_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
ansible.module_utils.connection.ConnectionError: LOGIN ERROR, FAIL: Login failed with status code 401: Login failed
```.
@seunay0 Did you validate the credentials in your inventory are accurate? Can you please verify you're able to successfully login with those credentials using this cURL command, replace IP, USER, PW with the values of your inventory, you should get a 200 Response - if not then you have the incorrect credentials: curl -i -k -X POST "https://IP/rest/v10.04/login?username=USER&password=PW" -H "accept: /" -d ""
Example Output: (py3_env) ansible-control-machine$curl -i -k -X POST "https://10.6.7.16/rest/v10.04/login?username=admin&password=admin" -H "accept: /" -d "" HTTP/1.1 200 OK Server: nginx Date: Fri, 05 Aug 2022 16:02:37 GMT Content-Length: 0 Connection: keep-alive Set-Cookie: id=zcAsM8wA8Jgjft5l8qW3vw==; Path=/; HttpOnly; Secure Set-Cookie: user=eyJ1c2VyIjoiYWRtaW4iLCJsZXZlbCI6MTUsInR5cGUiOiJMT0NBTCIsIm1ldGhvZCI6IkxPQ0FMIn0=; Path=/; Secure X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Strict-Transport-Security: max-age=31536000; includeSubdomains; Content-Security-Policy: script-src 'self' 'unsafe-inline'; object-src 'none'; font-src *; media-src 'none'; form-action 'self';
yes, the credentials are accurate. I tested other tasks in the playbook with the same credentials.
as requested, see the result of the curl command:
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 11 Aug 2022 19:41:44 GMT
Content-Length: 0
Connection: keep-alive
Set-Cookie: id=BbzYHH6WQqbkN3GjmKndLA==; Path=/; HttpOnly; Secure; SameSite=Lax
Set-Cookie: user=eyJ1c2VyIjoidGVzdCIsImxldmVsIjoxNSwidHlwZSI6IkxPQ0FMIiwibWV0aG9kIjoiTE9DQUwifQ==; Path=/; Secure; SameSite=Lax
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubdomains;
Content-Security-Policy: script-src 'self' 'unsafe-inline'; object-src 'none'; font-src *; media-src 'none'; form-action 'self';
@seunay0 Can you provide the switch model and firmware you're using?
@seunay0 if you don't use a variable with the module do you still receive the error or is it only when you use a variable?
switch model: Vendor: Aruba Product Name: R8N89A 6000 12G CL4 2SFP 139W Switch ArubaOS-CX Version: PL.10.10.0002
when i use another variable to pass the VLANs (in a list), I don't have any issues
i.e
#var file
allowed_vlan: [900, 999]
#playbook
- name: configure l2 trunk interfaces
aoscx_l2_interface:
interface: 1/1/{{trunk_port}}
vlan_mode: trunk
vlan_trunks: "{{allowed_vlan}}"
I wasn't able to reproduce this in my environment - this was the playbook I used:
- hosts: all
gather_facts: False
vars:
trunk_vlan_list: []
allowed_vlans:
- name: vlan-999
id: 999
- name: vlan-900
id: 900
trunk_port: 4
collections:
- arubanetworks.aoscx
tasks:
- name: Create VLANs
aoscx_vlan:
vlan_id: "{{item}}"
with_items: [999, 900]
- name: generate vlan list variable
set_fact:
trunk_vlan_list: "{{ trunk_vlan_list | default([]) + [item['id']] }}"
loop: "{{allowed_vlans}}"
- debug:
var: trunk_vlan_list
- name: configure l2 trunk interfaces
aoscx_l2_interface:
interface: 1/1/{{trunk_port}}
vlan_mode: trunk
vlan_trunks: "{{trunk_vlan_list}}"
I would recommend adding a debug statement to see what values your variables have at the time of execution.
I had commented out the debug statement initially cause it was not working even with the alternate variable I created. I just ran your code and it worked fine, and I did a comparison between your code and mine, it was the same with the exception that I had the task to create the VLANs commented out, and yours wasn't.
I ran the playbook again with that task uncommented, and it worked fine. (I suppose both tasks need to also run together, as I was testing out each task instead to identify any errors).
Thanks for your assistance.
Hi, we are trying to use a variable to pass the list of VLANs to be added to a trunk interface
but we're getting the following error:
The full traceback is: Traceback (most recent call last): File "/home/.ansible/tmp/ansible-local-1851wq30pj1z/ansible-tmp-1659648884.836821-1867-79808499410925/AnsiballZ_aoscx_l2_interface.py", line 107, in <module> _ansiballz_main() File "/home/.ansible/tmp/ansible-local-1851wq30pj1z/ansible-tmp-1659648884.836821-1867-79808499410925/AnsiballZ_aoscx_l2_interface.py", line 99, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/home/.ansible/tmp/ansible-local-1851wq30pj1z/ansible-tmp-1659648884.836821-1867-79808499410925/AnsiballZ_aoscx_l2_interface.py", line 47, in invoke_module runpy.run_module(mod_name='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_l2_interface', init_globals=dict(_module_fqn='ansible_collections.arubanetworks.aoscx.plugins.modules.aoscx_l2_interface', _modlib_path=modlib_path), File "/usr/lib/python3.8/runpy.py", line 207, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/tmp/ansible_aoscx_l2_interface_payload_r7kskduy/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_l2_interface.py", line 577, in <module> File "/tmp/ansible_aoscx_l2_interface_payload_r7kskduy/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_l2_interface.py", line 369, in main File "/tmp/ansible_aoscx_l2_interface_payload_r7kskduy/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py", line 81, in get_pyaoscx_session File "/tmp/ansible_aoscx_l2_interface_payload_r7kskduy/ansible_aoscx_l2_interface_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx_pyaoscx.py", line 47, in __init__ File "/tmp/ansible_aoscx_l2_interface_payload_r7kskduy/ansible_aoscx_l2_interface_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__ ansible.module_utils.connection.ConnectionError: LOGIN ERROR, FAIL: Login failed with status code 401: Login failed.
Version info: ansible [core 2.12.6] python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0] jinja version = 2.10.1 libyaml = True
Any assistance will be appreciated, thanks!