(#13125) Apt keys should be case insensitive
Previously lowercase keys would be installed every puppet run because apt-key list returns an uppercase key. This commit makes the comparison case insensitive.
This commit is contained in:
parent
3dd2d1f227
commit
5148cbf5a6
2 changed files with 19 additions and 15 deletions
|
@ -8,6 +8,8 @@ define apt::key (
|
||||||
|
|
||||||
include apt::params
|
include apt::params
|
||||||
|
|
||||||
|
$upkey = upcase($key)
|
||||||
|
|
||||||
if $key_content {
|
if $key_content {
|
||||||
$method = "content"
|
$method = "content"
|
||||||
} elsif $key_source {
|
} elsif $key_source {
|
||||||
|
@ -20,7 +22,7 @@ define apt::key (
|
||||||
# It is used as a unique identifier for this instance of apt::key. It gets
|
# It is used as a unique identifier for this instance of apt::key. It gets
|
||||||
# hashed to ensure that the resource name doesn't end up being pages and
|
# hashed to ensure that the resource name doesn't end up being pages and
|
||||||
# pages (e.g. in the situation where key_content is specified).
|
# pages (e.g. in the situation where key_content is specified).
|
||||||
$digest = sha1("${key}/${key_content}/${key_source}/${key_server}/")
|
$digest = sha1("${upkey}/${key_content}/${key_source}/${key_server}/")
|
||||||
|
|
||||||
# Allow multiple ensure => present for the same key to account for many
|
# Allow multiple ensure => present for the same key to account for many
|
||||||
# apt::source resources that all reference the same key.
|
# apt::source resources that all reference the same key.
|
||||||
|
@ -29,40 +31,40 @@ define apt::key (
|
||||||
|
|
||||||
anchor { "apt::key/$title":; }
|
anchor { "apt::key/$title":; }
|
||||||
|
|
||||||
if defined(Exec["apt::key $key absent"]) {
|
if defined(Exec["apt::key $upkey absent"]) {
|
||||||
fail ("Cannot ensure Apt::Key[$key] present; $key already ensured absent")
|
fail ("Cannot ensure Apt::Key[$upkey] present; $upkey already ensured absent")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !defined(Anchor["apt::key $key present"]) {
|
if !defined(Anchor["apt::key $upkey present"]) {
|
||||||
anchor { "apt::key $key present":; }
|
anchor { "apt::key $upkey present":; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if !defined(Exec[$digest]) {
|
if !defined(Exec[$digest]) {
|
||||||
exec { $digest:
|
exec { $digest:
|
||||||
path => "/bin:/usr/bin",
|
path => "/bin:/usr/bin",
|
||||||
unless => "/usr/bin/apt-key list | /bin/grep '${key}'",
|
unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'",
|
||||||
before => Anchor["apt::key $key present"],
|
before => Anchor["apt::key $upkey present"],
|
||||||
command => $method ? {
|
command => $method ? {
|
||||||
"content" => "echo '${key_content}' | /usr/bin/apt-key add -",
|
"content" => "echo '${key_content}' | /usr/bin/apt-key add -",
|
||||||
"source" => "wget -q '${key_source}' -O- | apt-key add -",
|
"source" => "wget -q '${key_source}' -O- | apt-key add -",
|
||||||
"server" => "apt-key adv --keyserver '${key_server}' --recv-keys '${key}'",
|
"server" => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Anchor["apt::key $key present"] -> Anchor["apt::key/$title"]
|
Anchor["apt::key $upkey present"] -> Anchor["apt::key/$title"]
|
||||||
|
|
||||||
}
|
}
|
||||||
absent: {
|
absent: {
|
||||||
|
|
||||||
if defined(Anchor["apt::key $key present"]) {
|
if defined(Anchor["apt::key $upkey present"]) {
|
||||||
fail ("Cannot ensure Apt::Key[$key] absent; $key already ensured present")
|
fail ("Cannot ensure Apt::Key[$upkey] absent; $upkey already ensured present")
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { "apt::key $key absent":
|
exec { "apt::key $upkey absent":
|
||||||
path => "/bin:/usr/bin",
|
path => "/bin:/usr/bin",
|
||||||
onlyif => "apt-key list | grep '$key'",
|
onlyif => "apt-key list | grep '$upkey'",
|
||||||
command => "apt-key del '$key'",
|
command => "apt-key del '$upkey'",
|
||||||
user => "root",
|
user => "root",
|
||||||
group => "root",
|
group => "root",
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ describe 'apt::key', :type => :define do
|
||||||
].each do |param_set|
|
].each do |param_set|
|
||||||
|
|
||||||
let :param_hash do
|
let :param_hash do
|
||||||
default_params.merge(param_set)
|
param_hash = default_params.merge(param_set)
|
||||||
|
param_hash[:key].upcase! if param_hash[:key]
|
||||||
|
param_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
|
|
Loading…
Reference in a new issue