-
Notifications
You must be signed in to change notification settings - Fork 461
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
Add apt::keyring defined type #1120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# @summary Manage GPG keyrings for apt repositories | ||
# | ||
# @example Install the puppetlabs apt source with keyring. | ||
# apt::source { 'puppet7-release': | ||
# location => 'http://apt.puppetlabs.com', | ||
# repos => 'main', | ||
# keyring => '/etc/apt/keyrings/puppetlabs-keyring.gpg', | ||
# } | ||
# apt::keyring {'puppetlabs-keyring.gpg': | ||
# source => 'https://apt.puppetlabs.com/keyring.gpg', | ||
# } | ||
# | ||
# @param keyring_dir | ||
# Path to the directory where the keyring will be stored. | ||
# | ||
# @param keyring_filename | ||
# Optional filename for the keyring. | ||
# | ||
# @param keyring_file | ||
# File path of the keyring. | ||
# | ||
# @param keyring_file_mode | ||
# File permissions of the keyring. | ||
# | ||
# @param source | ||
# Source of the keyring file. Mutually exclusive with 'content'. | ||
# | ||
# @param content | ||
# Content of the keyring file. Mutually exclusive with 'source'. | ||
# | ||
# @param ensure | ||
# Ensure presence or absence of the resource. | ||
# | ||
define apt::keyring ( | ||
Stdlib::Absolutepath $keyring_dir = '/etc/apt/keyrings', | ||
Optional[String] $keyring_filename = $name, | ||
Stdlib::Absolutepath $keyring_file = "${keyring_dir}/${keyring_filename}", | ||
String $keyring_file_mode = '0644', | ||
Optional[Stdlib::Filesource] $source = undef, | ||
Optional[String] $content = undef, | ||
Enum['present','absent'] $ensure = 'present', | ||
) { | ||
ensure_resource('file', $keyring_dir, { ensure => 'directory', mode => '0755', }) | ||
if $source and $content { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want a similar check when none of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I have added another condition which will catch this scenario. |
||
fail("Parameters 'source' and 'content' are mutually exclusive") | ||
} elsif ! $source and ! $content { | ||
fail("One of 'source' or 'content' parameters are required") | ||
} | ||
case $ensure { | ||
'present': { | ||
file { $keyring_file: | ||
ensure => 'file', | ||
mode => $keyring_file_mode, | ||
source => $source, | ||
content => $content, | ||
} | ||
} | ||
'absent': { | ||
file { $keyring_file: | ||
ensure => $ensure, | ||
} | ||
} | ||
default: { | ||
fail("Invalid 'ensure' value '${ensure}' for apt::keyring") | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
$proxy = {} | ||
$sources = {} | ||
$keys = {} | ||
$keyrings = {} | ||
$ppas = {} | ||
$pins = {} | ||
$settings = {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'apt::keyring' do | ||
let(:title) { 'namevar' } | ||
let(:params) do | ||
{} | ||
end | ||
|
||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)
Check failure on line 15 in spec/defines/keyring_spec.rb GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)
|
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already defined as
apt::params::trusted_gpg_d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but for new-style APT keyrings,
/etc/apt/keyrings
is the preferred location.Changing it only here means the new-style keyrings can be deployed to
/etc/apt/keyrings
by default, without affecting the rest of the module.