Ubuntu >= 22.04 Keyserver Repositories using Ansible
Ubuntu 22.04 and greater has deprecated the use of apt-key to install GPG keys to your system.
I'm big on provisioning my systems using Ansible, and while I found lots of documentation about how to use the get_url module instead of apt_key I could not find any documentation on using Ansible to provision systems that utilize Canonical's keyserver.ubuntu.com GPG key repository.
Here's an example playbook of how I accomplished it
---
- hosts: myserver
tasks:
- name: install gpg
ansible.builtin.apt:
name: gpg
- name: download GPG keyring
ansible.builtin.apt_key:
keyserver: keyserver.ubuntu.com
id: some-ubuntu-keyserver-id
keyring: /etc/apt/keyrings/mysoftware.gpg
- name: configure apt repository
ansible.builtin.apt_repository:
filename: mysoftware
repo: deb [signed-by=/etc/apt/keyrings/mysoftware.gpg] https://mysoftware.com/ubuntu jammy main