Skip to content

Fix apt-key deprecation warning#65

Merged
malor merged 3 commits intomasterfrom
ci
Jan 2, 2026
Merged

Fix apt-key deprecation warning#65
malor merged 3 commits intomasterfrom
ci

Conversation

@malor
Copy link
Member

@malor malor commented Dec 31, 2025

apt-key is deprecated and is going to be removed in the next Debian stable release. The suggested migration path is to use the so called DEB822 source format. Among other things, this new format allows to specify the package signing key. Conveniently, Ansible provides a module that supports DEB822-style source definitions.

Configured keys are fetched and stashed in /etc/apt/trusted.gpg.d, similarly to how this was handled with apt-key. The crucial difference is that the scope of each key is limited to a single source now.


This also includes minor changes to make the linter happy and fix the playbook execution on recent Ansible versions. See the inline comments and individual commits for details.

@malor malor force-pushed the ci branch 5 times, most recently from a0082a9 to 5c52153 Compare December 31, 2025 16:04
Apparantely, there were some changes in the recent Ansible releases
and strings are no longer allowed in boolean context. Instead, we need
to use an additional filter to verify that a string is non-empty.

See https://docs.ansible.com/projects/ansible/latest/porting_guides/porting_guide_12.html
for more details.
apt-key is deprecated and is going to be removed in the next Debian
stable release. The suggested migration path is to use the so called
DEB822 source format. Among other things, this new format allows to
specify the package signing key. Conveniently, Ansible provides a module
that supports DEB822-style source definitions.

Configured keys are fetched and stashed in /etc/apt/trusted.gpg.d,
similarly to how this was handled with apt-key. The crucial difference
is that the scope of each key is limited to a single source now.
* ansible-lint version we pin is incompatible with the new ansible-core
  version
* The new version is unhappy about variable names (that, apparentely,
  should use the role name prefix by convention) and requires using
  Python 3.13
uses: actions/setup-python@v4
with:
python-version: '3.12'
python-version: '3.13'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest ansible-lint version somehow requires 3.13 specifically and won't work otherwise.

hooks:
- id: ansible-lint
args: [-x, meta-no-info]
args: [-x, "meta-no-info,no-handler"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment below on why we need this now.

state: present
filename: caddy
with_items: "{{ caddy_apt_repo }}"
- name: Update apt cache if needed
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deb822_repository does not trigger apt cache update when a source is added or updated. The suggestion in the documentation is to update the cache based on the change status. ansible-lint points out that it's what handlers are for... but handlers are normally executed after all other actions of a play, which does not work for us. We could make it a handler and add another task to flush all pending handlers, but that feels a bit silly? We might as well just do it explicitly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference is what you do right now. At least that's what I'm doing in my other ansible playbooks. I feel like running 'flush_handlers' is a hack.

- id: trailing-whitespace

- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.22.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version no longer works with recent ansible-core.

file: restore.yml
with_items: "{{ postgres_users }}"
when: item.backup_restore is defined and item.backup_restore
when: item.backup_restore is defined and item.backup_restore | length > 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

positional_args:
- "{{ item.username }}"
register: existing_tables
register: postgres_existing_tables
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new lint warning: all variables must use the role prefix.

name: acl
name:
- acl
- python3-debian
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a dependency of the deb822_repository Ansible module.

@malor malor requested a review from ikalnytskyi December 31, 2025 16:54
state: present
filename: caddy
with_items: "{{ caddy_apt_repo }}"
- name: Update apt cache if needed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference is what you do right now. At least that's what I'm doing in my other ansible playbooks. I feel like running 'flush_handlers' is a hack.

@malor malor merged commit 4dbaca5 into master Jan 2, 2026
4 checks passed
@malor malor deleted the ci branch January 2, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants