Maksim Malchuk 2ab88e6990 Use deb822 format for Apt repositories on Ubuntu and drop apt-key
Use the modern deb822 format [1] for Apt repositories on Ubuntu the
same way as in OpenStack Kolla projects, for example in Kayobe [2].
Also this change refactor usage of the deprecated [3] apt-key tool.

[1] https://manpages.ubuntu.com/manpages/jammy/en/man5/sources.list.5.html#deb822-style%20format
[2] I3f821937b0930a0ac9341178de7ae5123d82b957
[3] https://manpages.ubuntu.com/manpages/jammy/en/man8/apt-key.8.html#deprecation

Change-Id: Ic3dd0ce30a8436406a451276bbd94cb5f6f33f9d
Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
2024-04-18 03:10:01 +03:00

71 lines
1.6 KiB
YAML

---
- name: Install CA certificates and gnupg packages
apt:
name:
- ca-certificates
- gnupg
cache_valid_time: "{{ apt_cache_valid_time }}"
update_cache: true
state: present
become: True
- name: Ensure apt sources list directory exists
file:
path: /etc/apt/sources.list.d
state: directory
recurse: yes
become: True
- name: Ensure apt keyrings directory exists
file:
path: /etc/apt/keyrings
state: directory
recurse: yes
become: True
- name: Install docker apt gpg key
get_url:
url: "{{ docker_apt_url }}/{{ docker_apt_key_file }}"
dest: "/etc/apt/keyrings/docker.asc"
mode: "0644"
force: true
become: True
- name: Install docker apt pin
copy:
dest: "/etc/apt/preferences.d/docker"
content: |
Package: {{ docker_apt_package }}
Pin: version {{ docker_apt_package_pin }}
Pin-Priority: 1000
mode: "0644"
become: True
when: docker_apt_package_pin | length > 0
- name: Ensure old docker repository absent
file:
path: /etc/apt/sources.list.d/docker.list
state: absent
become: True
# TODO(mmalchuk): replace with ansible.builtin.deb822_repository module
# when all stable releases moves to the ansible-core >= 2.15
- name: Enable docker apt repository
copy:
dest: /etc/apt/sources.list.d/docker.sources
content: |
# Ansible managed
Types: deb
URIs: {{ docker_apt_url }}
Suites: {{ ansible_facts.distribution_release }}
Components: stable
Signed-by: /etc/apt/keyrings/docker.asc
mode: "0644"
become: True
- name: Update the apt cache
apt:
update_cache: true
become: True