# containers.podman.podman_prune module – Allows to prune various podman objects

Note

This module is part of the containers.podman collection (version 1.16.2).

It is not included in `ansible-core`. To check whether it is installed, run `ansible-galaxy collection list`.

To install it, use: `ansible-galaxy collection install containers.podman`. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: `containers.podman.podman_prune`.

New in containers.podman 1.10.0

## Synopsis

- Allows to run `podman container prune`, `podman image prune`, `podman network prune`, `podman volume prune` and `podman system prune`

## Requirements

The below requirements are needed on the host that executes this module.

- Podman installed on host

## Parameters

Parameter | Comments
--- | ---

container

boolean

Whether to prune containers.

Choices:

- `false` ← (default)

- `true`

container_filters dictionary | A dictionary of filter values used for selecting containers to delete. For example, `until: 24h`. See the podman documentation for more information on possible filters.
executable string | Podman binary. Default: `"podman"`

image

boolean

Whether to prune images.

Choices:

- `false` ← (default)

- `true`

image_filters dictionary | A dictionary of filter values used for selecting images to delete. You can also use `dangling_only: false` to delete dangling and non-dangling images or `external: true` to delete images even when they are used by external containers. See the podman documentation for more information on possible filters.

network

boolean

Whether to prune networks.

Choices:

- `false` ← (default)

- `true`

network_filters dictionary | A dictionary of filter values used for selecting networks to delete. See the podman documentation for more information on possible filters.

system

boolean

Whether to prune unused pods, containers, image, networks and volume data

Choices:

- `false` ← (default)

- `true`

system_all

boolean

Whether to prune all unused images, not only dangling images.

Choices:

- `false` ← (default)

- `true`

system_volumes

boolean

Whether to prune volumes currently unused by any container.

Choices:

- `false` ← (default)

- `true`

volume

boolean

Whether to prune volumes.

Choices:

- `false` ← (default)

- `true`

volume_filters dictionary | A dictionary of filter values used for selecting volumes to delete. See the podman documentation for more information on possible filters.

## Examples

    - name: Prune containers older than 24h
      containers.podman.podman_prune:
          containers: true
          containers_filters:
              # only consider containers created more than 24 hours ago
              until: 24h

    - name: Prune everything
      containers.podman.podman_prune:
          system: true

    - name: Prune everything (including non-dangling images)
      containers.podman.podman_prune:
          system: true
          system_all: true
          system_volumes: true

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Description
--- | ---
containers list / elements=string | List of IDs of deleted containers. Returned: containers is `true` Sample: `[]`
images list / elements=string | List of IDs of deleted images. Returned: images is `true` Sample: `[]`
networks list / elements=string | List of IDs of deleted networks. Returned: networks is `true` Sample: `[]`
system list / elements=string | List of ID of deleted containers, volumes, images, network and total reclaimed space Returned: system is `true` Sample: `[]`
volumes list / elements=string | List of IDs of deleted volumes. Returned: volumes is `true` Sample: `[]`

### Authors

- Roberto Alfieri (@rebtoor)

### Collection links

- Issue Tracker
- Repository (Sources)