Developer

last person joined: 7 days ago 

Expand all | Collapse all

Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

This thread has been viewed 6 times
  • 1.  Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

    Posted Oct 21, 2019 03:37 AM

    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

    The 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
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:


    - name: Upgrade Firmware via API
    ^ here
    " }

    Can provide information as needed and asked! :)

     

    Thanks in advance!

    - Riku



  • 2.  RE: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

    Posted Oct 21, 2019 06:53 PM

    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.



  • 3.  RE: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

    Posted Oct 22, 2019 01:33 AM

    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. 



  • 4.  RE: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API
    Best Answer

    Posted Oct 22, 2019 02:01 AM

    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?



  • 5.  RE: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

    Posted Oct 22, 2019 12:16 PM

    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!



  • 6.  RE: Upgrading/downgrading Aruba 2530 firmware using Ansible via REST API

    Posted Oct 30, 2019 04:07 AM

    Deleted