
Ubuntu 24.04 is the first release where package sources for Ubuntu are stored in a `.sources` file called `/etc/apt/sources.list.d/ubuntu.sources`, instead of the traditional `sources.list`. This means that we have lost the ability to override the system's default repositories. Previously, we could use the `apt_disable_sources_list` setting to disable default repositories and provide our own using `apt_repositories`. However, this is no longer possible. Now, each element of `apt_repositories` contains a field called `name`, which specifies the name of the repository file (without the `.sources` suffix). The default value of this field is `kayobe` and it may be omitted. The user can override the default by providing a different name, such as `ubuntu`, and new repository data. This way, the default file, `/etc/apt/source.list.d/ubuntu.sources`, will be overwritten by the provided repository configuration. Closes-Bug: #2107280 Change-Id: Ieaa1f56de7579ff5f989b207e29de29e148086be Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
36 lines
913 B
YAML
36 lines
913 B
YAML
---
|
|
- name: Ensure the Apt sources.list.d directory exists
|
|
file:
|
|
path: "/etc/apt/sources.list.d"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
become: true
|
|
|
|
# NOTE(mgoddard): Use the modern deb822 repository format rather than the old
|
|
# format used by the apt_repository module.
|
|
- name: Configure apt repositories
|
|
template:
|
|
src: "kayobe.sources.j2"
|
|
dest: "/etc/apt/sources.list.d/{{ reponame }}.sources"
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
become: true
|
|
loop: "{{ apt_repositories }}"
|
|
vars:
|
|
reponame: "{{ item.name | default('kayobe') }}"
|
|
notify:
|
|
- Update apt cache
|
|
|
|
- name: Disable repositories in /etc/apt/sources.list
|
|
replace:
|
|
# Make a backup, in case we end up with a broken configuration.
|
|
backup: true
|
|
path: /etc/apt/sources.list
|
|
regexp: '^(deb.*)'
|
|
replace: '# \1'
|
|
when: apt_disable_sources_list | bool
|
|
become: true
|