apt
apt module
Use the apt module to install, upgrade, or remove Debian packages using apt-get
. It also supports updating the package cache via 'update_cache'.
Examples
- name: Ensure curl is present
apt:
name: curl
state: present
- name: Install multiple packages
apt:
name: [curl, git]
- name: Update apt cache
apt:
update_cache: true
- name: Ensure package is absent
apt:
name: telnet
state: absent
Notes
- 'state: latest' will attempt to upgrade packages to the latest available version.
- You can also specify 'pkg' instead of 'name' (alias).
Module Capabilities
- Has Revert: false
- Provides Variables: None
Inputs
Parameter | Type | Description | Required | Default | Choices |
---|---|---|---|---|---|
name | any | Name of the package(s) to operate on. Can be a string or a list of strings. | false | ||
state | string | Desired package state. | false | present | present, absent, latest |
update_cache | bool | Run apt-get update before the operation. | false | false | true, false |
Outputs
Field | Type | Description |
---|---|---|
packages | [string] | Packages operated on |
state | string | Final state (installed, removed, updated) |
versions | [string] | Versions installed/removed (if applicable) |
Parameter aliases
- pkg → name