The Ansible user manual gives the following example to add repository:
- name: Add specified repository into sources list
ansible.builtin.apt_repository:
repo: deb http://archive.canonical.com/ubuntu focal partner
state: present
However, this adds the repo entry in /etc/apt/sources.list.d/archive_canonical_com_ubuntu.list
rather than updating the default /etc/apt/sources.list
file. As a result, Ubuntu does not show this repository in Software & Updates(see "Canonical Partners" checkbox below).
The user manual also indicates that filename:
"Sets the name of the source list file in sources.list.d." However, this appears to only add entries in /etc/apt/sources.list.d/
rather than the /etc/apt/sources.list
file.
Is it possible to use ansible.builtin.apt_repository
to add repo entries to /etc/apt/sources.list
(i.e., rather than using template or lineinfile)?