CiscoDevNet / ansible-dcnm

Apache License 2.0
45 stars 36 forks source link

dcnm_image_upgrade #260

Closed dsx1123 closed 6 months ago

dsx1123 commented 1 year ago

Community Note

Description

new module to trigger attach image policy to switches, stagging image and trigger upgrade

New or Affected modules(s):

DCNM version

Potential ansible task config

# Copy-paste your ansible playbook
- name: Staging/Upgrade deivces
  cisoc.dcnm.dcnm_image_upgrade:
    state: merged                                   # choose from merged(attach), deleted(detach), query
    config:
      policy: NR3F                                  # mandatory, policy name, switch need to be attached to the policy first
      validate: true                          
      stage: true                                   # optional, default is true, trigger stage image if the image is not stagged
      upgrade:
        nxos: true                                  # optional, default is true
        epld: true                                  # optional, default is false, epld and pakcages can't be true at same time if upgrade.nxos is false, if epld is true, nxos_option can only be disruptive
        packages: true                              # optional, default is false
        upgrade_option: disruptive                     # optional, default is disruptive, choose from distruptive, non_disruptive, force_non_disruptive
        epld_options:
          module: 1                                 # optional, defualt is ALL
          golden: true                              # optional, default is false 
      switches:                                     # mandatory, list of dict, config per switch override the global config
        - ip_address: 192.168.123.101
          policy: OR1F
          validate: true                          
          stage: true                                   # optional, default is true, trigger stage image if the image is not stagged
          stage: true                                   # optional, default is true, trigger stage image if the image is not stagged
          upgrade:
            nxos: true                                  # optional, default is true
            epld: true                                  # optional, default is false
            packages: true                              # optional, default is false
            option: disruptive                          # optional, default is disruptive, choose from distruptive, non_disruptive, force_non_disruptive
        - ip_address: 192.168.123.102

References

https://www.cisco.com/c/en/us/td/docs/dcn/ndfc/1212/configuration/fabric-controller/cisco-ndfc-fabric-controller-configuration-guide-1212/image-management.html Additional context Add any other context or screenshots about the feature request here.

allenrobel commented 1 year ago

Hi Shangxin, for the upgrade_option key, since there are other options for upgrade (bios_force) and since there may be more added on the NX-OS side in the future (e.g. scheduled upgrade), can we change the structure to make this a dictionary? Below is a proposal that consolidates both epld and nxos upgrade options into a single dictionary called options (and adds the reboot options that currently exist in the REST request body), with sections corresponding to the options in the REST request body.

EDIT: Adding package section within options

    -   name: stage/upgrade devices
        cisco.dcnm.dcnm_image_upgrade:
            state: merged
            config:
                validate: false
                stage: false
                upgrade:
                    nxos: false
                    epld: false
                options:
                    nxos:
                        mode: disruptive
                        bios_force: false
                    epld:
                        module: ALL
                        golden: false
                    reboot:
                        config_reload: false
                        write_erase: false
                    package:
                        install: false
                        uninstall: false
                switches:
                -   ip_address: 192.168.1.1
                    policy: NR1F
                    stage: true
                    validate: true
                    upgrade:
                        nxos: true
                        epld: false
                    options:
                        nxos:
                            mode: non_disruptive
                            bios_force: true
                        epld:
                            module: 1,2,4
                            golden: false
                        reboot:
                            config_reload: false
                            write_erase: false
                -   ip_address: 192.168.1.2
                    policy: NR2F
                    stage: true
                    validate: true
                    upgrade:
                        nxos: true
                        epld: true
                    options:
                        nxos:
                            mode: disruptive
                        epld:
                            module: 1,2,3
                            golden: true