Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use keyring for apt repository; update dependency versions #713

Merged
merged 2 commits into from
Mar 24, 2024

Conversation

h-haaks
Copy link
Contributor

@h-haaks h-haaks commented Mar 21, 2024

Pull Request (PR) description

The usage of apt-key is deprecated. Switching to apt-keyring

@h-haaks h-haaks marked this pull request as draft March 21, 2024 23:47
@h-haaks h-haaks marked this pull request as ready for review March 22, 2024 00:01
'Debian' => "https://${repo_domain}/apt/debian",
'Ubuntu' => "https://${repo_domain}/apt/ubuntu",
default => undef
}
$_keyring_location = "https://www.mongodb.org/static/pgp/server-${version}.asc"
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied that from the mongodb docs...
https://www.mongodb.com/docs/v5.0/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition

Isn't it best to keep it according to docs?

include apt

if($mongodb::repo::ensure == 'present' or $mongodb::repo::ensure == true) {
if($ensure == 'present') {
# The apt module does not implement gpg --dearmor
Copy link
Member

Choose a reason for hiding this comment

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

IIRC apt expect file with name ending with .gpg to be in the binary OpenPGP format, and files with name ending with .asc to use the ASCII armored format. Downloading the .asc file and saving it in a file with the .asc extension should work, alternatively saving the .pub file with the .gpg should also work. The archive module seems not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks I'll give it a try

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried using

    $keyring_file = split($keyring_location, '/')[-1]
    apt::source { 'mongodb':
      location => $repo_location,
      release  => $mongodb::repo::release,
      repos    => $mongodb::repo::repos,
      key      => {
        dir    => '/usr/share/keyrings',
        name   => "mongodb-${keyring_file}",
        source => $keyring_location,
      },
      comment  => $comment,
    }

with .asc and .pub. and saving .pub as .gpg
All of them fail with

  Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Reading package lists...
  Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: W: GPG error: https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B00A0BD1E2C63C11
  Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: E: The repository 'https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 Release' is not signed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Figured it out.
There is a bug in the apt module I think.
When adding signed-by in the sources.list the module does not add the missing '/' when concatenating 'dir' and 'name' ...
Changing 'dir' to '/usr/share/keyrings/' solved that :)

@bastelfreak
Copy link
Member

the minimal puppetlabs/apt version probably needs to be updated as well? https://github.com/voxpupuli/puppet-mongodb/blob/master/metadata.json#L55

@h-haaks
Copy link
Contributor Author

h-haaks commented Mar 23, 2024

the minimal puppetlabs/apt version probably needs to be updated as well? https://github.com/voxpupuli/puppet-mongodb/blob/master/metadata.json#L55

Thanks
This actually triggered an update of all dependencies because of stdlib9 requirement.

@bastelfreak bastelfreak changed the title Use keyring for apt repository Use keyring for apt repository; update dependency versions Mar 23, 2024
@h-haaks h-haaks merged commit a240721 into voxpupuli:master Mar 24, 2024
14 checks passed
@h-haaks h-haaks deleted the apt-key-to-keyring branch March 24, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants