fortinet-ansible-dev / ansible-galaxy-fortios-collection

GNU General Public License v3.0
85 stars 49 forks source link

upgrade.system.firmware from fortiguard #160

Closed Terper closed 2 years ago

Terper commented 2 years ago

Hello,

I am trying to use fortios_monitor's upgrade.system.firmware selector with the fortiguard source. I can't seem to figure out what it wants as the filename.

---
- name: Upgrade firmware
  hosts: all
  connection: httpapi
  collections:
  - fortinet.fortios
  vars:
    vdom: "root"
    ansible_httpapi_use_ssl: yes
    ansible_httpapi_validate_certs: no
    ansible_httpapi_port: 443

  tasks:

  - name: Upgrade system firmware
    fortios_monitor:
      vdom: "{{ vdom }}"
      access_token: "{{ fortios_access_token }}"
      selector: "upgrade.system.firmware"
      params:
        source: "fortiguard"
        filename: "?"
JieX19 commented 2 years ago

Hi @Terper The filename is a sequentail number indicating the build version. I saw the filename when upgrading the firmware manuelly on GUI and it's captured in the network traffic, the number is something like '07000000FIMG0012000003'. But it does not show on my device.

Here's another to upgrade the firmware:

tasks:
- name: Update Firmware
  fortios_monitor:
      vdom: "{{ vdom }}"
      selector: 'upgrade.system.firmware'
      params:
        source: "upload"
        filename: "FGT_VM64-v6-build1828-FORTINET.out"
        file_content: "{{ lookup( 'file', './FGT_VM64-v6-build1828-FORTINET.out') | string | b64encode }}"

Please note there would be a timeout error after the execution, because the device will restart when finishing the upgrading task. Please double check your device after upgrading the firmware. We are trying to find a good way to address it.

Let me know if you have any questions.

Terper commented 2 years ago

Thanks for the reply @JieX19.

I'll try to find the filename trough trial and error, thanks for the lead.