Remove Salt states

Note

This page describes a “meta” practice, in terms of maintaining the repository as a whole.

We try to remove unneeded services and packages from this repository, because carrying old configurations forever into the future increases the maintenance burden of this repository. If you don’t know whether a package is still required, you can inspect the package.

The ./manage.py command has services and packages sub-commands to identify unusual services and packages, and an autoremove sub-command to list candidates for removal.

In some cases, we keep unused states if they are simple and haven’t needed changes. At time of writing, these include nodejs, react_apps, yarn and redis.

Inspect packages

Connect to the server and:

  • Show what files the package installs:

    dpkg -L PACKAGE
    
  • Show what packages the package depends on (after Depends: and Recommends:):

    apt show PACKAGE
    
  • Show what packages depends on this package:

    apt rdepends PACKAGE
    

For example, the above commands show that redis is a metapackage (installing only documentation) that depends on redis-server, and that python3-virtualenv provides library files whereas virtualenv provides a binary file (needed by Salt).

List manually installed packages

This StackOverflow answer works best., However, on Hetzner and Linode servers, the /var/log/installer directory is missing. The Ubuntu manifest can be used as an approximation, for example:

comm -23 <(apt-mark showmanual | sort -u) <(curl -sS https://releases.ubuntu.com/bionic/ubuntu-18.04.5-live-server-amd64.manifest | cut -f1 | cut -d: -f1 | sort -u)