Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

'argument ''api_version'' is of type <class ''NoneType''> found in ''provider''. #77

Closed
ewbree opened this issue Jul 12, 2023 · 9 comments

Comments

@ewbree
Copy link

ewbree commented Jul 12, 2023

Whenever I try to run the example playbooks (or any other for that fact) I receive the following error:

FAILED! => changed=false 
  msg: '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'

Host in hostfile:

network-devices:
  hosts:
    switch-01:
      ansible_host: <IP>
      ansible_user: admin
      ansible_password: <PASSWORD>
      ansible_connection: local
      ansible_network_os: arubanetworks.aos_switch.arubaoss

The playbook, to test function:

- hosts: switch-01
  collections:
    - arubanetworks.aos_switch
  tasks:
    - name: Create VLAN 300
      arubaoss_vlan:
        vlan_id: 300
        name: "vlan300"
        config: "create"
        command: config_vlan

- hosts: switch-01
  collections:
    - arubanetworks.aos_switch
  vars:
    ansible_connection: network_cli
  tasks:
    - name: Execute show run on the switch
      arubaoss_command:
        commands: ['show run']

For both tasks above, I get thrown the exact same error.

Command to run the playbook:

ansible-playbook ./playbooks/network-devices/test3.yaml -i hosts.yaml

Ansible version:

ansible [core 2.15.1]
  config file = /home/ewbree/.ansible.cfg
  configured module search path = ['/home/ewbree/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ewbree/venv-ansible/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ewbree/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ewbree/venv-ansible/bin/ansible
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] (/home/ewbree/venv-ansible/bin/python3)
  jinja version = 3.1.2
  libyaml = True

The ansible.cfg contains the needed settings.

@tchiapuziowong
Copy link
Member

Can you share which versions of the ansible.netcommon and arubanetworks.aos_switch collection you have?

@alagoutte
Copy link
Contributor

do you have try to add api_version to task ?

       tasks:
         - name: Create VLAN 300
           arubanetworks.aos_switch.arubaoss_vlan:
             vlan_id: 300
             name: "vlan300"
             config: "create"
             command: config_vlan
             api_version: v6.0

What the switch model/firmware and configuration ?

@ewbree
Copy link
Author

ewbree commented Jul 13, 2023

Can you share which versions of the ansible.netcommon and arubanetworks.aos_switch collection you have?

ansible.netcommon: 5.1.2
arubanetworks.aos_switch: 1.6.0


do you have try to add api_version to task ?

       tasks:
         - name: Create VLAN 300
           arubanetworks.aos_switch.arubaoss_vlan:
             vlan_id: 300
             name: "vlan300"
             config: "create"
             command: config_vlan
             api_version: v6.0

What the switch model/firmware and configuration ?

Adding api_version: v6.0 results in exactly the same error message. Even copying the task you send to the letter did not result in a different outcome.

The versions I run are YA.16.11.0008 and WC.16.11.0008 on all switches I intend to use.
Models 2530-##G(-PoE+)'s and 2930F's

Yes, I probably need to update firmware anyway although it should be supported according to documentation.

tchiapuziowong added a commit that referenced this issue Aug 1, 2023
- fix the logic to determine API version
@tchiapuziowong
Copy link
Member

@ewbree 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

@ewbree
Copy link
Author

ewbree commented Aug 8, 2023

@ewbree 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

@tchiapuziowong
I did not have the time to look into this as of yet. I will see if I can next week. Otherwise at its earliest the week of the 18th of August.

Thanks for the update. :)

@ewbree
Copy link
Author

ewbree commented Aug 21, 2023

It works when I use the command:

ANSIBLE_NETWORK_GROUP_MODULES=arubaoss ansible-playbook -i hosts.yaml ./playbooks/network-devices/test.yaml

VLAN 300 is created indeed.

However, when I use the command:

ansible-playbook -i hosts.yaml ./playbooks/network-devices/test.yaml

I get the response:

TASK [Create VLAN 300] *********************************************************************************************
fatal: [switch1]: FAILED! => changed=false 
  ansible_facts:
    discovered_interpreter_python: /usr/bin/python3
  msg: 'Request failed: <urlopen error [Errno -2] Name or service not known>'
  status: -1
  url: http://None:80/rest/v6.0/#-sessions

The host file is as follows:

all:
  hosts:
    switch1:
      ansible_host: 10.32.255.51
      ansible_user: admin
      ansible_password: <<PASSWORD>>
      ansible_connection: local
      ansible_network_os: arubanetworks.aos_switch.arubaoss

@tchiapuziowong
Copy link
Member

@ewbree you need to set the proper environment variables to use the collection - either by providing it in the command line (which you did in the first execution) or by creating an ansible.cfg file and including the network module that way - please read the instructions in this collection's README here: https://github.com/aruba/aos-switch-ansible-collection#setting-environment-variables

@ewbree
Copy link
Author

ewbree commented Aug 21, 2023

@ewbree you need to set the proper environment variables to use the collection - either by providing it in the command line (which you did in the first execution) or by creating an ansible.cfg file and including the network module that way - please read the instructions in this collection's README here: https://github.com/aruba/aos-switch-ansible-collection#setting-environment-variables

Ah yes. I forgot... I will try it tomorrow morning.
Starting problems after three weeks of vacation...

@ewbree
Copy link
Author

ewbree commented Aug 22, 2023

Everything seems to be working fine now. :)

@ewbree ewbree closed this as completed Aug 22, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants