zester
GuidesModules

pkg.purged

Ensures a package is removed along with its configuration files. On Debian this runs apt-get purge; on the RedHat family it runs dnf/yum remove (rpm has no separate purge concept). The purge is performed by shelling out to the package manager CLI, independent of what the package provider's Remove does.

Source: pkg/state/modules/pkg_purged.go


Parameters

ParameterTypeRequiredDefaultDescription
namestringNoState IDName of the package to purge.

All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.


Check Behavior

  • Installation status is checked via the package provider when available, otherwise by probing dpkg -s <pkg> (Debian) or rpm -q <pkg> (RedHat).
  • Installed → changes needed; not installed → no changes.
  • On an unknown package system without a package provider, Check errors.

Apply Behavior

OS familyCommand
Debian/Ubuntuapt-get purge -y <pkg>
RedHat (dnf/yum)<mgr> remove -y <pkg>
UnknownFalls back to the package provider's Remove; errors if no provider is available.

The OS family is detected from the os.family fact, falling back to the active package provider name.


Revert Behavior

Reinstalls the package — via the package provider when available, otherwise <mgr> install -y <pkg>. Purged configuration files are not restored.


Examples

Direct Execution

zester 'web-01' pkg.purged apache2

State File

apache2:
  pkg.purged: []

Purge before installing a replacement:

remove-old-webserver:
  pkg.purged:
    - name: apache2

nginx:
  pkg.installed:
    - require:
      - "pkg.purged:remove-old-webserver"

Divergences from Salt

  • On the RedHat family, purge is identical to remove (as in Salt — rpm does not track config purging separately).
  • Salt's pkgs (multi-package) parameter is not supported; use the generic names attribute to expand one state per package.

On this page