Developer Community

Reply
Highlighted
Occasional Contributor I

Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Heyhey,

 

I am doing my thesis and using Ansible to make a platform for an easier way to push confs to a group of switches. I am trying to upgrade/downgrade (basically just trying to get the playbook/task working) my 2530 test switch. I am using aruba-switch-ansible modules. Currently the playbook gives me an error at "Upgrade Firmware via API" saying that switch_session is undefined at /aruba-switch-ansible/aruba_task_lists/aos_switch/firmware_upgrade.yml starting from line 112. It's not mentioned that I should assigne the variable myself and that variable is not assigned anywhere known to my knowledge unless it should be automatically assigned by Ansible. I have no clue what the information inside the variable should be so I cannot assign it myself either.

 

TASK [Upgrade Firmware via API] ****************************************************************************************************************************************
task path: /home/user/ansible/test/aruba-switch-ansible/aruba_task_lists/aos_switch/firmware_upgrade.yml:112
fatal: [test_switch]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'switch_session' is undefined\n\nThe error appears to be in '/home/user/ansible/aruba-switch-ansible/aruba_task_lists/aos_switch/firmware_upgrade.yml': line 112, column 11, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n        - name: Upgrade Firmware via API\n          ^ here\n"
}

Can provide information as needed and asked! :)

 

Thanks in advance!

- Riku


Accepted Solutions
Highlighted
Occasional Contributor I

Re: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Okay, yesterday I didn't get to test this one, but today I just did and I got upgrade working with following task:

---
- name: Upgrade Firmware via SSH CLI
  arubaos_switch_ssh_cli:
    ip: "{{ ansible_host }}"
    user: "{{ ansible_user }}"
    password: "{{ ansible_password }}"
    path_to_swi: "firmware_files/YA_16_10_0001.swi"
    boot_image: "secondary"
    enable_sftp: True
    state: "upgrade"
  register: module_result

What are the real benefits when comparing firmware upgrading task done with SSH-CLI versus SSH-APIv3 style?

View solution in original post


All Replies
Highlighted

Re: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Hi Riku!

 

So that task list is not using the typical Aruba modules but actually the URI module and the workflow is assuming you've logged in like below:

 

# Login to ArubaOS switches
- name: Login
  include: aruba_task_lists/aos_switch/login_switch.yml

For an example of a full workflow checkout this playbook:

 

https://github.com/aruba/aruba-switch-ansible/blob/master/arubaoss_firmware_example.yml

 

You can also just directly call the login function from the playbook itself.

Highlighted
Occasional Contributor I

Re: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Hello T,

I actually tried to reply yesterday that I noticed that login task I needed to use and got my initial problem solved, but I couldn't reply before I had to bail off from office.

 

Anyway I am not sure if this is the right place to mention the next problem I have but let's give it a try.

 

I got the firmware_upgrade_api_v3 working as in it runs fine until Upgrade Firmware via API" and "Check if Upload Complete" parts. It makes and mentions the HTTP server and it's PID but nothing is getting uploaded to switch. I'm not sure where the problem lies. I've tried to look example from arubaoss_firmware_example.yml but nothing has helped.

 

I need to troubleshoot a bit more myself also and discover how everything works because I'm not familiar with some of the stuff. 

Highlighted
Occasional Contributor I

Re: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Okay, yesterday I didn't get to test this one, but today I just did and I got upgrade working with following task:

---
- name: Upgrade Firmware via SSH CLI
  arubaos_switch_ssh_cli:
    ip: "{{ ansible_host }}"
    user: "{{ ansible_user }}"
    password: "{{ ansible_password }}"
    path_to_swi: "firmware_files/YA_16_10_0001.swi"
    boot_image: "secondary"
    enable_sftp: True
    state: "upgrade"
  register: module_result

What are the real benefits when comparing firmware upgrading task done with SSH-CLI versus SSH-APIv3 style?

View solution in original post

Highlighted

Re: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Hi Riku!

 

Great to hear you've found a solution! In response to the benefits of using the SSH CLI and the REST API versions, with REST API you'll get validation that the upload is complete and successful with the REST API response code you get after executing the code. In addition since this this solution has been posted we've created a AOS-Switch module that should allow you to use the REST API to upload a file without using the URI module, check out arubaoss_file_transfer module:

- name: Upgrade Firmware
  arubaoss_file_transfer:
    file_url: "http://192.168.1.2/firmware_files/YA_16_10_0001.swi"
    file_type: "FTT_FIRMWARE"
    action: "FTA_DOWNLOAD"
    boot_image: BI_SECONDARY_IMAGE

 

For SSH CLI, the module just pushes the commands to the switch without validation, so you'll have to ensure the file uploaded successfully yourself using the CLI. It's an alternative option for those who also don't want to enable REST on their switches!

Highlighted
Occasional Contributor I

Re: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

Deleted

Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: