-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generating and configuring repo metadata gpg keys
- Loading branch information
Showing
8 changed files
with
235 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# == Class: certs | ||
# Sets up the GPG key for Pulp repository metadata signing | ||
class certs::repomd_gpg ( | ||
$enable = $::certs::enable_repomd_gpg, | ||
$regenerate = $::certs::regenerate_repomd_gpg, | ||
$dir = $::certs::repomd_gpg_dir, | ||
$user = $::certs::repomd_gpg_user, | ||
$group = $::certs::repomd_gpg_group, | ||
$gpg_name = $::certs::repomd_gpg_name, | ||
$comment = $::certs::repomd_gpg_comment, | ||
$email = $::certs::repomd_gpg_email, | ||
$key_type = $::certs::repomd_gpg_key_type, | ||
$key_length = $::certs::repomd_gpg_key_length, | ||
$expire_date = $::certs::repomd_gpg_expire_date, | ||
$batch_params = $::certs::repomd_gpg_batch_params, | ||
) { | ||
if $enable { | ||
|
||
$gpg_name_param = $gpg_name ? { undef => '', default => "Name-Real: ${gpg_name}\n", } | ||
$gpg_comment_param = $comment ? { undef => '', default => "Name-Comment: ${comment}\n", } | ||
$gpg_email_param = $email ? { undef => '', default => "Name-Email: ${email}\n", } | ||
$gpg_batch_params = $batch_params ? { undef => '', default => "${batch_params}\n", } | ||
$gpg_params = "Key-Type: ${key_type}\nKey-Length: ${key_length}\nExpire-Date: ${expire_date}\n${gpg_name_param}${gpg_comment_param}${gpg_email_param}${gpg_batch_params}%no-protection\n%commit\n" | ||
if $regenerate { | ||
exec { 'delete existing repomd gpg': | ||
onlyif => "/usr/bin/test -e '${dir}/private-keys-v1.d'", | ||
command => "rm -rf '${dir}'", | ||
before => File[$dir], | ||
} | ||
} | ||
file { $dir: | ||
ensure => directory, | ||
owner => $user, | ||
group => $group, | ||
mode => '0700', | ||
} -> | ||
exec { 'generate repomd gpg': | ||
unless => "/usr/bin/test -e '${dir}/secring.gpg' -o -e '${dir}/private-keys-v1.d'", | ||
user => $user, | ||
group => $group, | ||
provider => shell, | ||
command => "echo '${gpg_params}' | /usr/bin/gpg --homedir '${dir}' --gen-key --batch", | ||
} | ||
|
||
$pub_file = "${dir}/pub.gpg" | ||
$fp_cmd_print = "/usr/bin/gpg --homedir '${dir}' --list-secret-keys --with-colons" | ||
$fp_cmd_parse = "/usr/bin/awk -F: '\$1 == \"fpr\" {print \$10; exit;}'" | ||
$fp_cmd = "`${fp_cmd_print} | ${fp_cmd_parse}`" | ||
exec { 'extract public repomd gpg key': | ||
require => Exec['generate repomd gpg'], | ||
creates => $pub_file, | ||
user => $user, | ||
group => $group, | ||
command => "/usr/bin/gpg --homedir '${dir}' --armor --export ${fp_cmd} --output '${pub_file}'", | ||
} | ||
|
||
file { '/etc/pulp/server/plugins.conf.d/yum_distributor.json': | ||
replace => false, | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0644', | ||
content => "{ \"gpg_sign_metadata\": true}\n", | ||
} | ||
|
||
} else { | ||
$pub_file = undef | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper' | ||
|
||
describe 'certs::repomd_gpg' do | ||
let :facts do | ||
on_supported_os['redhat-7-x86_64'] | ||
end | ||
let :default_params do | ||
{ | ||
:enable => false, | ||
:regenerate => false, | ||
:dir => '/usr/share/httpd/.gnupg', | ||
:user => 'apache', | ||
:group => 'apache', | ||
:gpg_name => 'Repository Metadata Signing Key', | ||
:comment => nil, | ||
:email => nil, | ||
:key_type => 'RSA', | ||
:key_length => '4096', | ||
:expire_date => '0', | ||
:batch_params => nil, | ||
} | ||
end | ||
|
||
context 'with default parameters' do | ||
let(:params) { default_params } | ||
it { should compile.with_all_deps } | ||
end | ||
|
||
context 'with enable_repomd_gpg => true' do | ||
let :params do | ||
default_params.merge(:enable => true) | ||
end | ||
it { should compile.with_all_deps } | ||
it { is_expected.to contain_file('/usr/share/httpd/.gnupg') } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters