https://github.com/claranet/ansible-role-apt
Configure APT
https://github.com/claranet/ansible-role-apt
ansible apt claranet role
Last synced: 4 months ago
JSON representation
Configure APT
- Host: GitHub
- URL: https://github.com/claranet/ansible-role-apt
- Owner: claranet
- License: mpl-2.0
- Created: 2022-08-16T07:25:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-01T09:58:07.000Z (about 2 years ago)
- Last Synced: 2025-10-26T22:42:50.466Z (8 months ago)
- Topics: ansible, apt, claranet, role
- Language: Jinja
- Homepage:
- Size: 155 KB
- Stars: 1
- Watchers: 10
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Ansible role - apt
[](https://www.claranet.fr/)
[](LICENSE)
[](https://github.com/claranet/ansible-role-aot/releases)
[](https://github.com/claranet/ansible-role-apt/actions?query=workflow%3A%22Ansible+Molecule%22)
[](https://github.com/ansible/ansible)
[](https://galaxy.ansible.com/claranet/apt)
> :star: Star us on GitHub — it motivates us a lot!*
Install packages and add repositories on apt based distributions :
## :warning: Requirements
Ansible >= 2.10
## :zap: Installation
```bash
ansible-galaxy install claranet.apt
```
## :gear: Role variables
--------------
Variable | Default value | Description
----------------------------------------------|------------------------------------------------------------|--------------------------------------
apt_upgrade | **false** | Do an upgrade (no, yes, safe, full, dist)
apt_autoremove | **true** | Remove packages that are no longer needed for dependencies
apt_packages | **[]** | Packages list to install
apt_repositories | **[[]](molecule/ppa-package-install/converge.yml#L12)** | Repositories list to configure
apt_ppas | **[[]](molecule/ppa-package-install/converge.yml#L19)** | PPA repositories to add
apt_force | **false** | Force installs / removes
apt_install_recommends | **false** | Install recommended packages
apt_dpkg_options | **""** | Add dpkg options to apt command
apt_default_release | **""** | Set pin priorities (like apt -t)
apt_config_default | **[defaults/main.yml](defaults/main.yml#L16)** | Defaut config for apt, every new config will be merge with it
apt_config | **{}** | New config to set, it will be merge with apt_default_config
apt_config_additional_preformatted_config | **''** | Additional preformatted config
apt_config_listchanges_mail | **null** | List changes mail
apt_config_unattended_upgrades_package_state | **'auto'** | Unattended upgrades package state
apt_config_unattended_upgrades_timer_override | **null** | Unattended upgrades timer override
apt_config_listchanges_package_state | **'auto'** | List changes package state
## :arrows_counterclockwise: Dependencies
N/A
## :pencil2: Example Playbook
Install packages
```yaml
- name: bootstrap instance
hosts: all
tasks:
- include_role:
name: apt
vars:
apt_packages:
# latest packages
- name: tree
- name: python-pip
# specific package version
- name: vim=2:8.*
# deb file
- deb: "http://repo.zabbix.com/zabbix/6.1/{{ ansible_distribution | lower }}/pool/main/z/zabbix-release/zabbix-release_6.1-2+{{ ansible_distribution |lower }}{{ ansible_distribution_version }}_all.deb"ansible_distribution_release }}_all.deb
```
PPA package installation
```yaml
- name: ppa-package-install
hosts: all
become: true
roles:
- role: claranet.apt
vars:
apt_upgrade: true
apt_ppas:
# nginx ppa repo
- repo: ppa:nginx/stable
# not needed on ubuntu distribution
codename: trusty
apt_repositories:
- types: deb # can be string or list
urls: "https://deb.nodesource.com/node_18.x"
suites: "{{ ansible_distribution_release | lower }}"
components: "main"
key: https://deb.nodesource.com/gpgkey/nodesource.gpg.key # can be url or content of file
# key: "{{ lookup('url', 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key', split_lines=False) }}"
apt_packages:
- name: nginx
- name: nodejs
```
Do an upgrade
```yaml
- hosts: all
vars:
# could be safe | full | dist
apt_upgrade: true
roles:
- apt
```
## :closed_lock_with_key: [Hardening](HARDENING.md)
## :heart_eyes_cat: [Contributing](CONTRIBUTING.md)
## :copyright: [License](LICENSE)
[Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/)