pyinfra icon indicating copy to clipboard operation
pyinfra copied to clipboard

Pr1/3 : add GPG key management operations and facts

Open maisim opened this issue 3 months ago • 3 comments

Add new gpg.key and gpg.dearmor operations to manage GPG keys and keyrings. These operations provide a modern alternative to apt-key for managing APT repository keys.

Features:

  • Install keys from URLs, local files, or keyservers
  • Remove keys by ID or entire keyring files
  • Convert ASCII armored keys to binary format
  • Manage keys in specific keyrings or across all APT keyrings

This is part 1/3 of modernizing APT key management.

  • [x] Pull request is based on the default branch (3.x at this time)
  • [x] Pull request includes tests for any new/updated operations/facts
  • [ ] Pull request includes documentation for any new/updated operations/facts
  • [x] Tests pass (see scripts/dev-test.sh)
  • [x] Type checking & code style passes (see scripts/dev-lint.sh)

maisim avatar Sep 24 '25 09:09 maisim

Hi @DonDebonair ! Can you take a look at this, please? It seems to work, but I'm not sure I'm always using gpg correctly. Also, I'm always hesitant to use facts or shell commands within operations. Let me know what you think. Thanks!

maisim avatar Sep 24 '25 14:09 maisim

Thanks for the PR @maisim . I would not be afraid to use facts inside operations. I actually consider it a best practice to use facts to check things in operations. So instead of doing checks inside the shell commands you yield, there are probably places where you can rely on facts instead. That makes the yielded commands simpler.

If you can change those already, I'll do a more full review this weekend.

Caveat btw: I'm by no means a GPG expert. A short while ago, I wanted to use pyinfra to install Docker on a Debian host. I just created the keyring directory and downloaded the key directly into that, never touching GPG 😅

DonDebonair avatar Sep 25 '25 17:09 DonDebonair

Left some more comments @maisim incl. some ideas on how to leverate facts.

DonDebonair avatar Oct 04 '25 12:10 DonDebonair