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

**URL:** <https://forum.ansible.com/t/cisco-command-to-clean-the-switch-request-platform-software-package-clean-switch-all/35301>\
**Category:** Ansible Project\
**Created:** [June 7, 2021, 8:41pm UTC](https://forum.ansible.com/t/cisco-command-to-clean-the-switch-request-platform-software-package-clean-switch-all/35301 "2021-06-07T20:41:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suneel\_Hegde](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Suneel\_Hegde](https://forum.ansible.com/u/Suneel_Hegde)\
**Post date:** [June 7, 2021, 8:41pm UTC](https://forum.ansible.com/t/cisco-command-to-clean-the-switch-request-platform-software-package-clean-switch-all/35301/1 "2021-06-07T20:41:03Z")

</div>

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

```auto
- 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

```

```auto
also tried like this 

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

```

```auto
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

---

<div class="post-metadata">

**Author:** ![Suneel\_Hegde](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Suneel\_Hegde](https://forum.ansible.com/u/Suneel_Hegde)\
**Post date:** [June 8, 2021, 5:13am UTC](https://forum.ansible.com/t/cisco-command-to-clean-the-switch-request-platform-software-package-clean-switch-all/35301/2 "2021-06-08T05:13:46Z")

</div>

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
