c94df9fefa400ef9f8e5f8a7307af5bcd02dce87
Supports apt, dnf, yum, pacman, apk and zypper. Variables cover install, remove, upgrade, cache refresh and autoremove.
ansible-role-packages
Manages Linux packages across distributions using the native package manager.
Supported package managers: apt, dnf, yum, pacman, apk, zypper.
Requirements
- Ansible >= 2.14
community.generalcollection (required for Arch, Alpine, openSUSE targets)
Role Variables
| Variable | Default | Description |
|---|---|---|
packages_install |
[] |
List of packages to install |
packages_remove |
[] |
List of packages to remove |
packages_state |
present |
State for installed packages: present or latest |
packages_upgrade |
false |
Upgrade all packages on the system |
packages_update_cache |
true |
Refresh the package cache before operations |
packages_cache_valid_time |
3600 |
Maximum cache age in seconds before forcing a refresh (apt only) |
packages_autoremove |
false |
Remove unused dependencies after operations (apt, dnf only) |
Example Playbook
- hosts: servers
roles:
- role: ansible-role-packages
vars:
packages_install:
- curl
- git
- vim
packages_remove:
- telnet
packages_update_cache: true
packages_upgrade: false
License
MIT
Description