I’m working on Ubuntu 22.04 where apt-key is deprecated, with ansible ansible [core 2.13.4]
After adding “ppa:ondrej/php” via “apt_repository” module and then execute “apt update” it throw the following error:
W: http://ppa.launchpad.net/ondrej/php/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
When adding the repo on the server via “add-apt-repository -y ppa:ondrej/php” it adds the correct repo and no error occurs
Yes, you’re right, but the deprecation warning is the problem. And this only occurs when the repo is added via Ansible, if it is added via a simple “add-apt-repository” command then this warning does not come.
The real problem is that ansible breaks off with an error message when you “apt update”, because this deprecation warning comes up
The better place to report this is in the ansible apt module’s git repo as an issue so it can be addressed. The apt-key module itself says to refer to the Debian wiki where they recommend managing key files directly in the trusted.gpg.d directory.
The apt-key command has been deprecated and suggests to ‘manage keyring files in trusted.gpg.d instead’. See the Debian wiki for details. This module is kept for backwards compatiblity for systems that still use apt-key as the main way to manage apt repository keys.