Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ Manage packages and up(date|grade)s in Debian-like systems.
* `apt_ubuntu_security_mirror`: [default: `https://security.ubuntu.com/ubuntu`]: The security-mirror to use
* `apt_src_enable`: [default: `true`]: Whether to enable source code repositories
* `apt_backports_enable`: [default: `true`]: Whether to enable the `backports` repository
* `apt_ubuntu_distribution_release`: [default: `{{ ansible_distribution_release }}`]: The distribution release to use. Make sure this value corresponds with the `apt_ubuntu_distribution_major_version` value. For example: `noble`
* `apt_ubuntu_distribution_major_version`: [default: `{{ ansible_distribution_major_version }}`]: The distribution major version to use. Make sure this value corresponds with the `apt_ubuntu_distribution_release` value. For example: `24`
* `apt_ubuntu_restricted_enable`: [default: `true`]: Whether to enable the `restricted` repository
* `apt_ubuntu_universe_enable`: [default: `true`]: Whether to enable the `universe` repository
* `apt_ubuntu_multiverse_enable`: [default: `true`]: Whether to enable the `multiverse` repository
* `apt_ubuntu_backports_enable`: [default: `true`]: Whether to enable the `backports` repository [deprecated in favour of `apt_backports_enable`]
* `apt_ubuntu_partner_enable`: [default: `false`]: Whether to enable the `partner` repository
* `apt_ubuntu_extras_enable`: [default: `false`]: Whether to enable the `extras` repository (only applies to < 16.04)
* `apt_debian_distribution_release`: [default: `{{ ansible_distribution_release }}`]: The distribution release to use. Make sure this value corresponds with the `apt_debian_distribution_major_version` value. For example: `bookworm`
* `apt_debian_distribution_major_version`: [default: `{{ ansible_distribution_major_version }}`]: The distribution major version to use. Make sure this value corresponds with the `apt_debian_distribution_release` value. For example: `12`
* `apt_debian_mirror`: [default: `https://deb.debian.org/debian/`]: The mirror to use
* `apt_debian_security_mirror`: [default: `https://security.debian.org/`]: The security-mirror to use
* `apt_debian_contrib_nonfree_enable`: [default: `false`]: Whether to enable the `contrib` `non-free` `non-free-firmware` repository
Expand Down
8 changes: 6 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ apt_src_enable: true
apt_backports_enable: true

# Ubuntu specific
apt_ubuntu_distribution_release: "{{ ansible_distribution_release }}"
apt_ubuntu_distribution_major_version: "{{ ansible_distribution_major_version }}"
apt_ubuntu_mirror: mirror://mirrors.ubuntu.com/mirrors.txt
apt_ubuntu_security_mirror: http://security.ubuntu.com/ubuntu
apt_ubuntu_restricted_enable: true
Expand All @@ -15,12 +17,14 @@ apt_ubuntu_backports_enable: true
apt_ubuntu_partner_enable: false
apt_ubuntu_extras_enable: false
# Debian specific
apt_debian_distribution_release: "{{ ansible_distribution_release }}"
apt_debian_distribution_major_version: "{{ ansible_distribution_major_version }}"
apt_debian_mirror: https://deb.debian.org/debian/
apt_debian_security_mirror: "{{ (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('10', '<=')) | ternary('https://security.debian.org/', 'https://security.debian.org/debian-security') }}"
apt_debian_security_mirror: "{{ (ansible_distribution == 'Debian' and apt_debian_distribution_major_version is version('10', '<=')) | ternary('https://security.debian.org/', 'https://security.debian.org/debian-security') }}"
apt_debian_contrib_nonfree_enable: false

apt_dependencies:
- "{{ (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('8', '<')) | ternary('python-apt', 'python3-apt') }}"
- "{{ (ansible_distribution == 'Debian' and apt_debian_distribution_major_version is version('8', '<')) | ternary('python-apt', 'python3-apt') }}"
- aptitude

apt_update: true
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# tasks file
---
- name: manage sources.list

Check warning on line 3 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
when: apt_manage_sources_list | bool
tags:
- configuration
- apt
- apt-configuration
block:
- name: install dependencies (pre)

Check warning on line 10 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.apt:
name: "{{ apt_dependencies_pre }}"
state: "{{ apt_install_state | default('latest') }}"
update_cache: true
cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}"

- name: update configuration file - /etc/apt/sources.list

Check warning on line 17 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: "{{ apt_sources_list_file.lstrip('/') }}.{{ ansible_distribution }}.j2"
dest: "{{ apt_sources_list_file }}"
Expand All @@ -23,7 +23,7 @@
mode: '0644'
register: _update_config_1

- name: update configuration file - /etc/apt/sources.list.d/ubuntu.sources

Check warning on line 26 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: "{{ apt_ubuntu_sources_file.lstrip('/') }}.j2"
dest: "{{ apt_ubuntu_sources_file }}"
Expand All @@ -33,9 +33,9 @@
register: _update_config_2
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_major_version is version('24', '>=')
- apt_ubuntu_distribution_major_version is version('24', '>=')

- name: update configuration file - /etc/apt/apt.conf

Check warning on line 38 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: "{{ apt_apt_conf_file.lstrip('/') }}.j2"
dest: "{{ apt_apt_conf_file }}"
Expand All @@ -48,7 +48,7 @@
- apt
- apt-configuration

- name: remove configuration files - /etc/apt/apt.conf.d/*

Check warning on line 51 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.file:
path: "/etc/apt/apt.conf.d/{{ item }}"
state: absent
Expand All @@ -59,7 +59,7 @@
- apt
- apt-configuration

- name: ensure directory exists - /var/lib/apt/lists/

Check warning on line 62 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.file:
path: /var/lib/apt/lists/
state: directory
Expand All @@ -71,14 +71,14 @@
- apt
- apt-update

- name: update

Check warning on line 74 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
when: apt_update | bool
tags:
- configuration
- apt
- apt-update
block:
- name: update | on configuration change

Check warning on line 81 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.apt:
update_cache: true
when: false
Expand Down
22 changes: 11 additions & 11 deletions templates/etc/apt/sources.list.Debian.j2
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{{ ansible_managed | comment }}

deb {{ apt_debian_mirror }} {{ ansible_distribution_release }} main
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ ansible_distribution_release }} main
deb {{ apt_debian_mirror }} {{ apt_debian_distribution_release }} main
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ apt_debian_distribution_release }} main

deb {{ apt_debian_security_mirror }} {{ ansible_distribution_release }}{{ apt_debian_security_mirror_suffix }} main
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_security_mirror }} {{ ansible_distribution_release }}{{ apt_debian_security_mirror_suffix }} main
deb {{ apt_debian_security_mirror }} {{ apt_debian_distribution_release }}{{ apt_debian_security_mirror_suffix }} main
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_security_mirror }} {{ apt_debian_distribution_release }}{{ apt_debian_security_mirror_suffix }} main

# {{ ansible_distribution_release }}-updates, previously known as 'volatile'
deb {{ apt_debian_mirror }} {{ ansible_distribution_release }}-updates main
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ ansible_distribution_release }}-updates main
# {{ apt_debian_distribution_release }}-updates, previously known as 'volatile'
deb {{ apt_debian_mirror }} {{ apt_debian_distribution_release }}-updates main
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ apt_debian_distribution_release }}-updates main

# Contrib packages contain DFSG-compliant software,
# but have dependencies not in main (possibly packaged for Debian in non-free).
# Non-free contains software that does not comply with the DFSG.
{% if apt_debian_contrib_nonfree_enable | bool %}
deb {{ apt_debian_mirror }} {{ ansible_distribution_release }} contrib non-free{{ ansible_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ ansible_distribution_release }} contrib non-free{{ ansible_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
deb {{ apt_debian_mirror }} {{ apt_debian_distribution_release }} contrib non-free{{ apt_debian_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ apt_debian_distribution_release }} contrib non-free{{ apt_debian_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
{% endif %}

# # N.B. software from this repository may not have been tested as
# # extensively as that contained in the main release, although it includes
# # newer versions of some applications which may provide useful features.
{% if apt_backports_enable | bool %}
deb {{ apt_debian_mirror }} {{ ansible_distribution_release }}-backports main contrib non-free{{ ansible_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ ansible_distribution_release }}-backports main contrib non-free{{ ansible_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
deb {{ apt_debian_mirror }} {{ apt_debian_distribution_release }}-backports main contrib non-free{{ apt_debian_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_debian_mirror }} {{ apt_debian_distribution_release }}-backports main contrib non-free{{ apt_debian_distribution_major_version is version('12', '>=') | ternary(' non-free-firmware', '') }}
{% endif %}
52 changes: 26 additions & 26 deletions templates/etc/apt/sources.list.Ubuntu.j2
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{{ ansible_managed | comment }}

{% if (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version is version('24', '>=')) %}
{% if (ansible_distribution == 'Ubuntu' and apt_ubuntu_distribution_major_version is version('24', '>=')) %}
# Ubuntu sources have moved to {{ apt_ubuntu_sources_file }}
{% else %}
# See https://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }} main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }} main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }} main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }} main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}

# # Major bug fix updates produced after the final release of the
# # distribution.
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-updates main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-updates main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}

# # N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
# # team. Also, please note that software in universe WILL NOT receive any
# # review or updates from the Ubuntu security team.
{% if apt_ubuntu_universe_enable | bool %}
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }} universe
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }} universe
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates universe
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates universe
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }} universe
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }} universe
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-updates universe
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-updates universe
{% endif %}

# # N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
Expand All @@ -29,10 +29,10 @@ deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates universe
# # multiverse WILL NOT receive any review or updates from the Ubuntu
# # security team.
{% if apt_ubuntu_multiverse_enable | bool %}
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }} multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }} multiverse
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates multiverse
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }} multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }} multiverse
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-updates multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-updates multiverse
{% endif %}

# # N.B. software from this repository may not have been tested as
Expand All @@ -41,32 +41,32 @@ deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-updates multivers
# # Also, please note that software in backports WILL NOT receive any review
# # or updates from the Ubuntu security team.
{% if apt_backports_enable or apt_ubuntu_backports_enable | bool %}
deb {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-backports main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }} universe multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ ansible_distribution_release }}-backports main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }} universe multiverse
deb {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-backports main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }} universe multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_mirror }} {{ apt_ubuntu_distribution_release }}-backports main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }} universe multiverse
{% endif %}

deb {{ apt_ubuntu_security_mirror }} {{ ansible_distribution_release }}-security main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_security_mirror }} {{ ansible_distribution_release }}-security main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
deb {{ apt_ubuntu_security_mirror }} {{ apt_ubuntu_distribution_release }}-security main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_security_mirror }} {{ apt_ubuntu_distribution_release }}-security main {{ (apt_ubuntu_restricted_enable | bool) | ternary('restricted', '') }}
{% if apt_ubuntu_universe_enable | bool %}
deb {{ apt_ubuntu_security_mirror }} {{ ansible_distribution_release }}-security universe
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_security_mirror }} {{ ansible_distribution_release }}-security universe
deb {{ apt_ubuntu_security_mirror }} {{ apt_ubuntu_distribution_release }}-security universe
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_security_mirror }} {{ apt_ubuntu_distribution_release }}-security universe
{% endif %}
{% if apt_ubuntu_multiverse_enable | bool %}
deb {{ apt_ubuntu_security_mirror }} {{ ansible_distribution_release }}-security multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_security_mirror }} {{ ansible_distribution_release }}-security multiverse
deb {{ apt_ubuntu_security_mirror }} {{ apt_ubuntu_distribution_release }}-security multiverse
{{ '# ' if not apt_src_enable else '' }}deb-src {{ apt_ubuntu_security_mirror }} {{ apt_ubuntu_distribution_release }}-security multiverse
{% endif %}

# # This software is not part of Ubuntu, but is offered by Canonical and the
# # respective vendors as a service to Ubuntu users.
{% if apt_ubuntu_partner_enable | bool %}
deb http://archive.canonical.com/ubuntu {{ ansible_distribution_release }} partner
{{ '# ' if not apt_src_enable else '' }}deb-src http://archive.canonical.com/ubuntu {{ ansible_distribution_release }} partner
deb http://archive.canonical.com/ubuntu {{ apt_ubuntu_distribution_release }} partner
{{ '# ' if not apt_src_enable else '' }}deb-src http://archive.canonical.com/ubuntu {{ apt_ubuntu_distribution_release }} partner
{% endif %}

# # This software is not part of Ubuntu, but is offered by third-party
# # developers who want to ship their latest software.
{% if apt_ubuntu_extras_enable | bool and ansible_distribution_version is version('16.04', '<') %}
deb http://extras.ubuntu.com/ubuntu {{ ansible_distribution_release }} main
{{ '# ' if not apt_src_enable else '' }}deb-src http://extras.ubuntu.com/ubuntu {{ ansible_distribution_release }} main
{% if apt_ubuntu_extras_enable | bool and apt_ubuntu_distribution_major_version is version('16', '<') %}
deb http://extras.ubuntu.com/ubuntu {{ apt_ubuntu_distribution_release }} main
{{ '# ' if not apt_src_enable else '' }}deb-src http://extras.ubuntu.com/ubuntu {{ apt_ubuntu_distribution_release }} main
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apt_dependencies_pre:
apt_sources_list_file: /etc/apt/sources.list
apt_ubuntu_sources_file: /etc/apt/sources.list.d/ubuntu.sources
apt_apt_conf_file: /etc/apt/apt.conf
apt_debian_security_mirror_suffix: "{{ (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('10', '<=')) | ternary('/updates', '-security') }}"
apt_debian_security_mirror_suffix: "{{ (ansible_distribution == 'Debian' and apt_debian_distribution_major_version is version('10', '<=')) | ternary('/updates', '-security') }}"

apt_ubuntu_sources_components:
- main
Expand Down
Loading