CiscoDevNet / ansible-dcnm

Apache License 2.0
47 stars 37 forks source link

dcnm_switch_bootflash #262

Closed dsx1123 closed 3 weeks ago

dsx1123 commented 1 year ago

Community Note

Description

new module to manage bootflash of switches

New or Affected modules(s):

DCNM version

Potential ansible task config

# Copy-paste your ansible playbook
- name: managing bootflash
  cisco.dcnm.dcnm_switch_bootflash:
    state: delete                                 # choose from deleted, query
    config:
      files:                                      # list of files to be deleted or filtered as query, when the state is deleted, it is mandatory, when the state is query, it is optional
        - nxos64-cs.10.3.2.F.bin
        - nxos64-cs.10.3.1.F.bin
      switches:                                   # list of switches, files per switch overridden the global file list, it is mandatory for both deleted and query
        - ip_address: 192.168.123.101
          files:
            - nxos64-cs.10.3.3.F.bin

References

Additional context Add any other context or screenshots about the feature request here.

allenrobel commented 3 months ago

Playbooks as implemented on branch dcnm_bootflash. Work in progress PR: https://github.com/CiscoDevNet/ansible-dcnm/pull/311

---
# Example deleted state.
# 1. On switch 192.168.1.1
#    Delete all text files from all flash devices on active supervisor.
# 2. On switch 192.168.1.2
#    Delete foo.txt from bootflash on active supervisor.
# 3. On switch 192.168.1.3
#    Delete all files, whose name implies creation during the month of
#    July 2024, from bootflash on active supervisor.
# NOTES:
#    - 192.168.1.1 uses the global targets specification.
#    - 192.168.1.2 and 192.168.1.3 override the global targets
#      specification with their own local targets specification.
- name: Example deleted state
  cisco.dcnm.dcnm_bootflash:
      state: deleted
      config:
        targets:
          - filepath: "*:/*.txt"
            supervisor: active
        switches:
          - ip_address: 192.168.1.1
          - ip_address: 192.168.1.2
            targets:
              - filepath: bootflash:/foo.txt
                supervisor: active
          - ip_address: 192.168.1.3
            targets:
              - filepath: bootflash:/202407??.*
                supervisor: active

# Example query state.
# 1. On switch 192.168.1.1
#    List all text files from all flash devices on active supervisor.
# 2. On switch 192.168.1.2
#    List foo.txt from bootflash on active supervisor.
# 3. On switch 192.168.1.3
#    List all files, whose name implies creation during the month of
#    July 2024, from bootflash on active supervisor.
# NOTES:
#    - 192.168.1.1 uses the global targets specification.
#    - 192.168.1.2 and 192.168.1.3 override the global targets
#      specification with their own local targets specification.
#    - If files do not exist, the module returns an empty list.
- name: Example query state
  cisco.dcnm.dcnm_bootflash:
      state: query
      config:
        targets:
          - filepath: "*:/*.txt"
            supervisor: active
        switches:
          - ip_address: 192.168.1.1
          - ip_address: 192.168.1.2
            targets:
              - filepath: bootflash:/foo.txt
                supervisor: active
          - ip_address: 192.168.1.3
            targets:
              - filepath: bootflash:/202407??.*
                supervisor: active