arubaoss_config_bkup Tries to use api when ssh is needed
Closed this issue · 13 comments
I am attempting to backup the config of aruba switches (2530 YA.15.20) and it spews out the following:
"Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>", "status": -1, "url": "http://None:80/rest/v6.0/login-sessions"
It tries to use the api, even when network_cli is set as the connection type. I have tried setting provider: transport: network_cli though, I couldn't keep it without there being further errors. I just need to use ssh, and I would like the file to be stored on the ansible server.
- hosts: aruba
collections:
- arubanetworks.aos_switch
vars:
ansible_connection: network_cli
tasks:
- name: backup configuration files
arubaoss_config_bkup:
file_name: test1
config_type: CT_RUNNING_CONFIG
Also, the show config example on the galaxy page does work. That config being:
- hosts: all
collections:
- arubanetworks.aos_switch
vars:
ansible_connection: network_cli
tasks:
- name: Execute show run on the switch
arubaoss_command:
commands: ['show run']
I am attempting to backup the config of aruba switches (2530 YA.15.20) and it spews out the following:
"Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>", "status": -1, "url": "http://None:80/rest/v6.0/login-sessions"
It tries to use the api, even when network_cli is set as the connection type. I have tried setting provider: transport: network_cli though, I couldn't keep it without there being further errors. I just need to use ssh, and I would like the file to be stored on the ansible server.
- hosts: aruba collections: - arubanetworks.aos_switch vars: ansible_connection: network_cli tasks: - name: backup configuration files arubaoss_config_bkup: file_name: test1 config_type: CT_RUNNING_CONFIG
Try setting the ansible_connection set that to local arubanetworks.aos_switch.arubaoss - the arubaoss_command example works because that's using SSH to connect to the switch - in all other modules they use REST API which is why you need to set it to arubanetworks.aos_switch.arubaoss - this part of the README explains a bit further: https://github.com/aruba/aos-switch-ansible-collection#sshcli-modules
I set ansible_connect to arubanetworks.aos_switch.arubaoss leaving my that portion of my hosts file as follows:
[aruba]
x.x.x.x ansible_user=netadmin ansible_connection=arubanetworks.aos_switch.arubaoss ansible_network_os=arubanetworks.aos_switch.arubaoss
I still receive the following error:
urlopen error [Errno -3] Temporary failure in name resolution>", "status": -1, "url": "http://None:80/rest/v6.0/login-sessions"
you;j need to define the ansible_host variable - you can set ansible_host: x.x.x.x
or even ansible_host: "{{inventory_hostname}}"
since you're setting the hostname as the IP address
I set ansible_host=x.x.x.x (The switch) in the hosts file, and I received the following:
the connection plugin 'arubanetworks.aos_switch.arubaoss' was not found
Changing it back to network_cli, I am still receiving the earlier error of temp error in name resolution
Current host.yml looks like this:
aruba:
hosts:
itsw:
ansible_host: x.x.x.x
ansible_user: netadmin
ansible_connection: network_cli
ansible_network_os: arubanetworks.aos_switch.arubaoss
and the config for the backup is this:
- hosts: aruba
collections:
- arubanetworks.aos_switch
vars:
ansible_host: x.x.x.x
# ansible_connection: network_cli
tasks:
- name: backup configuration files
arubaoss_config_bkup:
file_name: test1
config_type: CT_RUNNING_CONFIG
Thank you for your quick replies
@nstein5 I'm sorry I realized I did the wrong copy/paste - the variable ansible_connection
should be set to local - so it would be ansible_connection: local
and then please verify you have your environment variables set https://github.com/aruba/aos-switch-ansible-collection#setting-environment-variables
I have the environment variables set in ansible.cfg, setting ansible_connection to local spit out the following:
"argument 'api_version' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to str: 'None' is not a string and conversion is not allowed
Ok, I have gotten a bit further with it. For some reason it still wants to use the api, though it is clearly defined to use network_cli.
- hosts: aruba
collections:
- arubanetworks.aos_switch
vars:
ansible_connection: network_cli
ignore_errors: True
tasks:
- name: backup configuration files
arubaoss_config_bkup:
provider:
api_version: "v5.0"
file_name: test1
config_type: CT_RUNNING_CONFIG
I get the following error when run:
Request failed: <urlopen error [Errno 111] Connection refused>", "status": -1, "url": "http://x.x.x.x:80/rest/v6.0/login-sessions
arubaoss_config_bkup use API...
you need to use arubaoss_command with for example copy run tftp... if you wan to backup config
what the configuraton on the switch? for management (show web-management...)
Ok, I have gotten a bit further with it. For some reason it still wants to use the api, though it is clearly defined to use network_cli.
- hosts: aruba collections: - arubanetworks.aos_switch vars: ansible_connection: network_cli ignore_errors: True tasks: - name: backup configuration files arubaoss_config_bkup: provider: api_version: "v5.0" file_name: test1 config_type: CT_RUNNING_CONFIG
I get the following error when run:
Request failed: <urlopen error [Errno 111] Connection refused>", "status": -1, "url": "http://x.x.x.x:80/rest/v6.0/login-sessions
You still need to use ansible_connection: local
- when you provide the provider api version that way does the playbook work with ansible_connection: local
? I believe I found the bug that's causing the "argument 'api_version' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to str: 'None' is not a string and conversion is not allowed
error - I'll be updating this issue once that fix is pushed
@nstein5 I just released a version with a fix regarding this issue - please install the latest version of the collection with the following command and verify the issue is no longer seen:
ansible-galaxy collection install arubanetworks.aos_switch -f
The error of "argument 'api_version' is of type <class 'NoneType'> found in 'provider'. and we were unable to convert to str: 'None' is not a string and conversion is not allowed
is no longer seen even when api_version is undefined. It seems like I'll have to either enable the api or set up commands to use a sftp server in order to back up the config. Thank you for your help.