Cisco command to clean the switch 'request platform software package clean switch all'

3,351 views
Skip to first unread message

Suneel Hegde

unread,
Jun 7, 2021, 4:41:26 PM6/7/21
to Ansible Project
I am trying to execute the command from ansible to clean the cisco switch after the upgrade,
everything worked and switch got upgrade. but this command is not working to clean the switch

test-switch#request platform software package clean switch all
This operation may take several minutes...
Running command on switch 1
Cleaning up unnecessary package files
No path specified, will use booted path flash:packages.conf
Cleaning flash:
  Scanning boot directory for packages ... done.
  Preparing packages list to delete ...
    cat3k_caa-guestshell.16.12.03a.SPA.pkg
      File is in use, will not delete.
    cat3k_caa-rpbase.16.12.03a.SPA.pkg
      File is in use, will not delete.
    cat3k_caa-rpcore.16.12.03a.SPA.pkg
      File is in use, will not delete.
    cat3k_caa-srdriver.16.12.03a.SPA.pkg
      File is in use, will not delete.
    cat3k_caa-webui.16.12.03a.SPA.pkg
      File is in use, will not delete.
    packages.conf
      File is in use, will not delete.
  done.
 
The following files will be deleted:
[switch 1]:
/flash/cat3k_caa-universalk9.16.12.03a.SPA.bin
Do you want to proceed? [y/n]

when I tried this using ansible its not working could any of you please help this is the way I am trying

- name: clean the switch
  ansible.netcommon.cli_command:
    command: request platform software package clean switch all
    prompt: Do you want to proceed? [y/n]
    answer: y
    newline: false

also tried like this 

  - name: clean the switch
cli_command:
    command: reload
    prompt:
    - Do you want to proceed? [y/n]
  answer
- y
Tried this also

      cli_command:
        command:
        - request platform software package clean switch all
        prompt:
        - Do you want to proceed? [y/n]
        answer:
        - y
        newline: false
      var:
        ansible_command_timeout: 300
non of the above worked :-(

Thank you
Suneel

Suneel Hegde

unread,
Jun 8, 2021, 1:14:08 AM6/8/21
to Ansible Project
Tried this as well it did not worked

- name: clean the switch
cisco.ios.ios_command:
commands:
- command: request platform software package clean switch all
prompt: Do you want to proceed? [y/n]
answer: yes
newline: false
Reply all
Reply to author
Forward
0 new messages