Skip to content

Commit

Permalink
Merge pull request #133 from benben/master
Browse files Browse the repository at this point in the history
trim keys to 8 chars for matching with apt-key list (fix for #100)
  • Loading branch information
hunner committed Jul 1, 2013
2 parents 18ee4cc + 733ece6 commit 142b72b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions manifests/key.pp
Expand Up @@ -9,6 +9,8 @@
include apt::params

$upkey = upcase($key)
# trim the key to the last 8 chars so we can match longer keys with apt-key list too
$trimmedkey = regsubst($upkey, '^.*(.{8})$', '\1')

if $key_content {
$method = 'content'
Expand Down Expand Up @@ -48,7 +50,7 @@
exec { $digest:
command => $digest_command,
path => '/bin:/usr/bin',
unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'",
unless => "/usr/bin/apt-key list | /bin/grep '${trimmedkey}'",
logoutput => 'on_failure',
before => Anchor["apt::key ${upkey} present"],
}
Expand All @@ -66,7 +68,7 @@
exec { "apt::key ${upkey} absent":
command => "apt-key del '${upkey}'",
path => '/bin:/usr/bin',
onlyif => "apt-key list | grep '${upkey}'",
onlyif => "apt-key list | grep '${trimmedkey}'",
user => 'root',
group => 'root',
logoutput => 'on_failure',
Expand Down

0 comments on commit 142b72b

Please sign in to comment.