Skip to content
This repository was archived by the owner on Feb 19, 2024. It is now read-only.

Updated repo.pp to only install repo key if it is not already installed #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 4 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,22 @@
path => "/etc/apt/sources.list.d/${normalized_name}.list",
mode => '0644',
content => template('packagecloud/apt.erb'),
notify => Exec["apt_get_update_${normalized_name}"],
}

exec { "apt_key_add_${normalized_name}":
command => "wget --auth-no-challenge -qO - ${base_url}/${repo_name}/gpgkey | apt-key add -",
path => '/usr/bin/:/bin/',
require => File[$normalized_name],
unless => "apt-key exportall | gpg --with-fingerprint | grep \"$(curl -L ${base_url}/${repo_name}/gpgkey | gpg --with-fingerprint $line | head -2 | tail -1 | cut -d'=' -f2 | cut -d ' ' -f2-12)\"",
notify => Exec["apt_get_update_${normalized_name}"],
}

exec { "apt_get_update_${normalized_name}":
command => "apt-get update -o Dir::Etc::sourcelist=\"sources.list.d/${normalized_name}.list\" -o Dir::Etc::sourceparts=\"-\" -o APT::Get::List-Cleanup=\"0\"",
path => '/usr/bin/:/bin/',
require => Exec["apt_key_add_${normalized_name}"],
refreshonly => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure adding a refreshonly here will work. A lot of our users re-run their puppet configs as part of CI/CD pipeline and would expect the latest repository metadata to get pulled in. I think adding a refresh only here would prevent that update from happening.

}
}
default: {
Expand Down