Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.21
Documentation for other releases can be found by using the version selector in the top right of any doc page.apt
Manage packages with the apt package manager, which is used by Debian, Ubuntu and their variants.
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| executable | string | Path of the binary to use. [default: "apt-get"] |
||
| extra_args | string | Additional option to pass to executable. | ||
| install_recommends | boolean | If yes, force apt to install only recommended packages. [default: true] |
||
| install_suggests | boolean | If yes, install suggested packages as well as recommended packages. [default: false] |
||
| name | array | Name or list of names of the package(s) or file(s) to install, upgrade, or remove. | ||
| state | string | absent present latest builddep fixed |
Whether to install (present), remove (absent), update to latest (latest), install build dependencies (build-dep), or fix a broken installation (fixed). [default: "present"] |
|
| purge | boolean | Whether to purge packages or not. Only used when state: absent. [default: false] |
||
| update_cache | boolean | Whether to refresh the package lists. [default: false] |
||
| cache_valid_time | integer | Update the cache only if it is older than this many seconds. Only has effect when update_cache is true. [default: 0] |
||
| upgrade | boolean | Whether to upgrade the whole system. [default: false] |
||
| deb | string | Path to a .deb package to install. | ||
| default_release | string | Use this to pin a specific version of a package. | ||
| allow_downgrade | boolean | Corresponds to the --allow-downgrades option for apt. [default: false] |
||
| allow_unauthenticated | boolean | Corresponds to the --allow-change-held-packages option for apt. [default: false] |
Example
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 86400
- name: Install packages
apt:
name:
- curl
- gnupg
- lsb-release
state: present
- name: Install specific version
apt:
name: nginx=1.18.0-0ubuntu1
state: present
- name: Install from .deb file
apt:
deb: /tmp/package.deb
- name: Remove package
apt:
name: vim
state: absent
purge: yes