Developer

 View Only
last person joined: yesterday 

Expand all | Collapse all

Aruba upgrade firmware via Ansible

This thread has been viewed 31 times
  • 1.  Aruba upgrade firmware via Ansible

    Posted Jul 22, 2020 07:14 AM

    Hello,

    To speed up updating our 100+ aruba switches we are currently building a playbook to automate this process.
    I do have some experience with Ansible, that aint no problem.

    In the past i used tftp to update aruba switches via the cli and uploaded the image with tftp. This ansible playbook works fine until it starts the task "Check if Upload Complete". It fails duo max retries.

    I think the switch cant download the firmware swi file and i cant find a way to achieve this. The task "upgrade firmware via api" should download the firmware from a http server. I do have an http server and indexing files is allowed. Is the information below correct?

    switch ip: 172.31.254.185
    webserver ip: 172.31.251.102
    .swi file is uploaded root/images/xxx.swi

    - hosts: all  
      tasks:
      - name: Upgrade Firmware
        include: aruba_task_lists/aos_switch/firmware_upgrade_api_v3.yml
        vars:
          ip: "172.31.254.185"
          boot_image: "primary"
          host_ip: "172.31.254.102"
          path_to_swi: "images/WC_16_09_0010.swi"
          #swi_url: "WC_16_09_0010.swi"
          state: "upgrade" 


    Is there some sort of documentation regarding http://{{ ip }}/rest/v2/file-transfer? My guess is that the necessary steps to upgrade / reboot the switch ar included in the url options included in the playbook: body: {"url":"{{ final_url }}","file_type":"FTT_FIRMWARE","action":"FTA_DOWNLOAD","boot_image": "{{ boot_i }}", "force_firmware_install": true }



  • 2.  RE: Aruba upgrade firmware via Ansible

    Posted Jul 27, 2020 08:42 AM

    Hello jangenent,

     

    1. You need to connect at least with REST v4.

    2. the value "boot_image" must be "BI_PRIMARY_IMAGE"

     

    View REST API Schema for your version here:

    https://asp.arubanetworks.com/downloads/software/RmlsZTpmZWViYmM5Mi04ZTRiLTExZWEtODc4Mi0wZjQ1ZDY1ZjJhOGU%3D

     

     



  • 3.  RE: Aruba upgrade firmware via Ansible
    Best Answer

    Posted Jul 30, 2020 12:50 PM

    Hi @jangenent !

     

    I would recommend using our Ansible modules for AOS-Switch! If you're running Ansible version 2.9+  you can use our AOS-Switch collection: https://galaxy.ansible.com/arubanetworks/aos_switch

     

    For transferring images to the switch using REST API, the only server type that's supported is HTTP/HTTPS. The task list you're calling creates a HTTP server on the localhost (Ansible machine) and uses that to transfer the image to the switch. If you're planning on hosting that image on a TFTP server, you may want to use a SSH command to transfer the image.

     

    If you use that collection, and decide to use REST API / a HTTPs server to host the image, you can use the `arubaoss_file_transfer` module with the `arubaoss_reboot`. Your playbook would look like the following:  

     

    - hosts: all
      collections:
        - arubanetworks.aos_switch
      tasks:
        - name: image upload
          arubaoss_file_transfer:
            file_url: "http://172.31.254.185/images/WC_16_09_0010.swi"
            file_type: "FTT_FIRMWARE"
            boot_image: "BI_SECONDARY_IMAGE"
            action: "FTA_UPLOAD"
    
        - name: reboot device to new image
          arubaoss_reboot:
            boot_image: BI_SECONDARY_IMAGE
            is_wait: False

     

     

    If you want to use SSH in conjunction with a TFTP server to host your image, this is what your playbook would look like:  

    - hosts: all
      collections:
        - arubanetworks.aos_switch
      vars:
        ansible_connection: network_cli
      tasks:
        - name: image upload
          arubaoss_command:
            commands: ["copy tftp flash 172.31.254.185 WC_16_09_0010.swi secondary"]
    
    - hosts: all
      collections:
        - arubanetworks.aos_switch
      tasks:
        - name: reboot device to new image
          arubaoss_reboot:
            boot_image: BI_SECONDARY_IMAGE
            is_wait: False

     



  • 4.  RE: Aruba upgrade firmware via Ansible

    Posted Oct 07, 2020 05:53 AM

    Solution in this post did not work for me, below did.

    I was getting error saying that FTA_UPLOAD is not valid action for FTT_FIMWARE

     

    My working playbook

    ---
    - hosts: switch1
    vars:
    ansible_connection: local
    ansible_user: xxxxxxxxxxxxxxx
    ansible_password: xxxxxxxxxxxxx
    ansible_network_os: arubanetworks.aos_switch.arubaoss
    swi_url: http://SERVER_IP_HOSTING_IMAGE/firmware/YA_16_10_0010.swi
    tasks:
    - name: image upload
    arubaoss_file_transfer:
    #file_url: "http://{{ ansible_host }}/images/YA_16_10_0010.swi"
    file_url: "http://SERVER_IP_HOSTING_IMAGE/firmware/YA_16_10_0010.swi"
    file_type: "FTT_FIRMWARE"
    boot_image: "BI_SECONDARY_IMAGE"
    action: "FTA_DOWNLOAD"