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

(MODULES-4521) Use local copy of Puppet GPG keys #216

Merged
merged 2 commits into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ task :gen_nodeset do
agent_target = ENV['TEST_TARGET']
if ! agent_target
STDERR.puts 'TEST_TARGET environment variable is not set'
STDERR.puts 'setting to default value of "redhat-64default."'
agent_target = 'redhat-64default.'
STDERR.puts 'setting to default value of "redhat7-64default.a"'
agent_target = 'redhat7-64default.a'
end

master_target = ENV['MASTER_TEST_TARGET']
Expand Down
File renamed without changes.
File renamed without changes.
29 changes: 27 additions & 2 deletions manifests/osfamily/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,42 @@
}
}

$legacy_keyname = 'GPG-KEY-puppetlabs'
$legacy_gpg_path = "/etc/pki/deb-gpg/${legacy_keyname}"
$keyname = 'GPG-KEY-puppet'
$gpg_path = "/etc/pki/deb-gpg/${keyname}"

file { ['/etc/pki', '/etc/pki/deb-gpg']:
ensure => directory,
}

file { $legacy_gpg_path:
ensure => present,
owner => 0,
group => 0,
mode => '0644',
source => "puppet:///modules/puppet_agent/${legacy_keyname}",
}

apt::key { 'legacy key':
id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
server => 'pgp.mit.edu',
source => $legacy_gpg_path,
}

file { $gpg_path:
ensure => present,
owner => 0,
group => 0,
mode => '0644',
source => "puppet:///modules/puppet_agent/${keyname}",
}

apt::source { 'pc_repo':
location => $source,
repos => $::puppet_agent::collection,
key => {
'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
'server' => 'pgp.mit.edu',
'source' => $gpg_path,
},
notify => Notify['pc_repo_force'],
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/osfamily/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
}
}

$legacy_keyname = 'RPM-GPG-KEY-puppetlabs'
$legacy_gpg_path = "/etc/pki/rpm-gpg/${legacy_keyname}"
$keyname = 'RPM-GPG-KEY-puppet'
$gpg_path = "/etc/pki/rpm-gpg/${keyname}"
$legacy_keyname = 'GPG-KEY-puppetlabs'
$legacy_gpg_path = "/etc/pki/rpm-gpg/RPM-${legacy_keyname}"
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'm preserving the path here so that we don't write another copy for people who are already using this module.

$keyname = 'GPG-KEY-puppet'
$gpg_path = "/etc/pki/rpm-gpg/RPM-${keyname}"
$gpg_keys = "file://${legacy_gpg_path}
file://${gpg_path}"

Expand Down
24 changes: 20 additions & 4 deletions spec/classes/puppet_agent_osfamily_debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,33 @@
'content' => apt_settings.join(''),
}) }

it { is_expected.to contain_file('/etc/pki/deb-gpg/GPG-KEY-puppetlabs').with({
'ensure' => 'present',
'owner' => '0',
'group' => '0',
'mode' => '0644',
'source' => 'puppet:///modules/puppet_agent/GPG-KEY-puppetlabs',
}) }

it { is_expected.to contain_file('/etc/pki/deb-gpg/GPG-KEY-puppet').with({
'ensure' => 'present',
'owner' => '0',
'group' => '0',
'mode' => '0644',
'source' => 'puppet:///modules/puppet_agent/GPG-KEY-puppet',
}) }

it { is_expected.to contain_apt__key('legacy key').with({
'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
'server' => 'pgp.mit.edu',
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppetlabs',
}) }

it { is_expected.to contain_apt__source('pc_repo').with({
'location' => 'https://master.example.vm:8140/packages/4.0.0/debian-7-x86_64',
'repos' => 'PC1',
'key' => {
'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
'server' => 'pgp.mit.edu',
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet',
},
}) }
end
Expand Down Expand Up @@ -193,15 +209,15 @@

it { is_expected.to contain_apt__key('legacy key').with({
'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30',
'server' => 'pgp.mit.edu',
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppetlabs',
}) }

it { is_expected.to contain_apt__source('pc_repo').with({
'location' => 'http://apt.puppetlabs.com',
'repos' => 'PC1',
'key' => {
'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
'server' => 'pgp.mit.edu',
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet',
},
}) }
end
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/puppet_agent_osfamily_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
:operatingsystemmajrelease => osmajor,
}}

it { is_expected.to contain_exec('import-RPM-GPG-KEY-puppetlabs').with({
it { is_expected.to contain_exec('import-GPG-KEY-puppetlabs').with({
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
'command' => 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs',
'unless' => 'rpm -q gpg-pubkey-`echo $(gpg --throw-keyids < /etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs) | cut --characters=11-18 | tr [:upper:] [:lower:]`',
'require' => 'File[/etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs]',
'logoutput' => 'on_failure',
}) }

it { is_expected.to contain_exec('import-RPM-GPG-KEY-puppet').with({
it { is_expected.to contain_exec('import-GPG-KEY-puppet').with({
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
'command' => 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puppet',
'unless' => 'rpm -q gpg-pubkey-`echo $(gpg --throw-keyids < /etc/pki/rpm-gpg/RPM-GPG-KEY-puppet) | cut --characters=11-18 | tr [:upper:] [:lower:]`',
Expand All @@ -47,15 +47,15 @@
'owner' => '0',
'group' => '0',
'mode' => '0644',
'source' => 'puppet:///modules/puppet_agent/RPM-GPG-KEY-puppetlabs',
'source' => 'puppet:///modules/puppet_agent/GPG-KEY-puppetlabs',
}) }

it { is_expected.to contain_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-puppet').with({
'ensure' => 'present',
'owner' => '0',
'group' => '0',
'mode' => '0644',
'source' => 'puppet:///modules/puppet_agent/RPM-GPG-KEY-puppet',
'source' => 'puppet:///modules/puppet_agent/GPG-KEY-puppet',
}) }

context 'when FOSS and manage_repo enabled' do
Expand Down