diff --git a/manifests/osfamily/debian.pp b/manifests/osfamily/debian.pp index 7cbd9d3e..3cc2f525 100644 --- a/manifests/osfamily/debian.pp +++ b/manifests/osfamily/debian.pp @@ -71,44 +71,15 @@ } else { $source = $puppet_agent::apt_source } - $legacy_keyname = 'GPG-KEY-puppet' - $legacy_gpg_path = "/etc/pki/deb-gpg/${legacy_keyname}" - $keyname = 'GPG-KEY-puppet-20250406' - $gpg_path = "/etc/pki/deb-gpg/${keyname}" - - if getvar('::puppet_agent::manage_pki_dir') == true { - file { ['/etc/pki', '/etc/pki/deb-gpg']: - ensure => directory, - } - } - - file { $legacy_gpg_path: - ensure => file, - owner => 0, - group => 0, - mode => '0644', - source => "puppet:///modules/puppet_agent/${legacy_keyname}", - } - - apt::key { 'legacy key': - id => '6F6B15509CF8E59E6E469F327F438280EF8D349F', - source => $legacy_gpg_path, - } - file { $gpg_path: - ensure => file, - owner => 0, - group => 0, - mode => '0644', - source => "puppet:///modules/puppet_agent/${keyname}", - } + $keyname = 'GPG-KEY-puppet-20250406' apt::source { 'pc_repo': location => $source, repos => $puppet_agent::collection, key => { - 'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26', - 'source' => $gpg_path, + 'name' => "${keyname}.asc", + 'content' => file("${module_name}/${keyname}"), }, notify => Exec['pc_repo_force'], } diff --git a/spec/classes/puppet_agent_osfamily_debian_spec.rb b/spec/classes/puppet_agent_osfamily_debian_spec.rb index e6040363..ce5798ae 100644 --- a/spec/classes/puppet_agent_osfamily_debian_spec.rb +++ b/spec/classes/puppet_agent_osfamily_debian_spec.rb @@ -151,44 +151,14 @@ }) } - it { - is_expected.to contain_file('/etc/pki/deb-gpg/GPG-KEY-puppet-20250406') - .with({ - 'ensure' => 'file', - 'owner' => '0', - 'group' => '0', - 'mode' => '0644', - 'source' => 'puppet:///modules/puppet_agent/GPG-KEY-puppet-20250406', - }) - } - - it { - is_expected.to contain_file('/etc/pki/deb-gpg/GPG-KEY-puppet') - .with({ - 'ensure' => 'file', - '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' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', - 'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet', - }) - } - it { is_expected.to contain_apt__source('pc_repo') .with({ 'location' => 'https://master.example.vm:8140/packages/2000.0.0/debian-7-x86_64', 'repos' => 'PC1', 'key' => { - 'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26', - 'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet-20250406', + 'name' => 'GPG-KEY-puppet-20250406.asc', + 'content' => File.read('files/GPG-KEY-puppet-20250406'), }, }) } @@ -209,8 +179,8 @@ 'location' => 'https://fake-apt-mirror.com/packages/2000.0.0/debian-7-x86_64', 'repos' => 'PC1', 'key' => { - 'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26', - 'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet-20250406', + 'name' => 'GPG-KEY-puppet-20250406.asc', + 'content' => File.read('files/GPG-KEY-puppet-20250406'), }, }) } @@ -225,7 +195,6 @@ end it { is_expected.not_to contain_apt__setting('conf-pc_repo') } - it { is_expected.not_to contain_apt__key('legacy key') } it { is_expected.not_to contain_apt__source('pc_repo') } end @@ -245,22 +214,14 @@ } end - it { - is_expected.to contain_apt__key('legacy key') - .with({ - 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', - 'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet', - }) - } - it { is_expected.to contain_apt__source('pc_repo') .with({ 'location' => 'https://apt.puppet.com', 'repos' => 'puppet5', 'key' => { - 'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26', - 'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet-20250406', + 'name' => 'GPG-KEY-puppet-20250406.asc', + 'content' => File.read('files/GPG-KEY-puppet-20250406'), }, }) } @@ -282,8 +243,8 @@ 'location' => 'https://fake-apt-mirror.com/', 'repos' => 'puppet5', 'key' => { - 'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26', - 'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet-20250406', + 'name' => 'GPG-KEY-puppet-20250406.asc', + 'content' => File.read('files/GPG-KEY-puppet-20250406'), }, }) } @@ -297,7 +258,6 @@ } end - it { is_expected.not_to contain_apt__key('legacy key') } it { is_expected.not_to contain_apt__source('pc_repo') } end