Supports apt, dnf, yum, pacman, apk and zypper. Variables cover install, remove, upgrade, cache refresh and autoremove.
44 lines
1.2 KiB
Markdown
44 lines
1.2 KiB
Markdown
# 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.general` collection (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
|
|
|
|
```yaml
|
|
- 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
|