Skip to content
TrySitePrice

How to use Ansible to autoremove unwanted package dependency with apt

Best/Tutorial

You can use the apt module in Ansible to autoremove unwanted package dependencies with the autoremove option. Here’s how you can do this:

  1. Create a playbook file, for example autoremove.yml

  2. Add the following code to the playbook file:

    nn 
    ---
    - name: Autoremove Unwanted Package Dependencies
    n hosts: localhost
    n gather_facts: yes
    n tasks:
    n - name: Autoremove unwanted package dependencies
    n apt:
    n name: '*'
    n state: autoremove
  3. Run the playbook with the following command:

    nn 
    ansible-playbook autoremove.yml

This will remove any unwanted dependencies from the apt packages on your system.

Zolpidem/