#
# === Parameters
#
-# [*key*]
+# [*id*]
# _default_: +$title+, the title/name of the resource
#
# Is a GPG key ID or full key fingerprint. This value is validated with
#
# Additional options to pass on to `apt-key adv --keyserver-options`.
define apt::key (
- $key = $title,
+ $id = $title,
$ensure = present,
$content = undef,
$source = undef,
$options = undef,
) {
- validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
+ validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z'])
validate_re($ensure, ['\Aabsent|present\Z',])
if $content {
case $ensure {
present: {
- if defined(Anchor["apt_key ${key} absent"]){
- fail("key with id ${key} already ensured as absent")
+ if defined(Anchor["apt_key ${id} absent"]){
+ fail("key with id ${id} already ensured as absent")
}
- if !defined(Anchor["apt_key ${key} present"]) {
+ if !defined(Anchor["apt_key ${id} present"]) {
apt_key { $title:
ensure => $ensure,
- id => $key,
+ id => $id,
source => $source,
content => $content,
server => $server,
options => $options,
} ->
- anchor { "apt_key ${key} present": }
+ anchor { "apt_key ${id} present": }
}
}
absent: {
- if defined(Anchor["apt_key ${key} present"]){
- fail("key with id ${key} already ensured as present")
+ if defined(Anchor["apt_key ${id} present"]){
+ fail("key with id ${id} already ensured as present")
}
- if !defined(Anchor["apt_key ${key} absent"]){
+ if !defined(Anchor["apt_key ${id} absent"]){
apt_key { $title:
ensure => $ensure,
- id => $key,
+ id => $id,
source => $source,
content => $content,
server => $server,
options => $options,
} ->
- anchor { "apt_key ${key} absent": }
+ anchor { "apt_key ${id} absent": }
}
}
end
let :params do {
- :key => GPG_KEY_ID,
+ :id => GPG_KEY_ID,
} end
it 'contains the apt_key' do
describe 'duplication' do
context 'two apt::key resources for same key, different titles' do
let :pre_condition do
- "apt::key { 'duplicate': key => '#{title}', }"
+ "apt::key { 'duplicate': id => '#{title}', }"
end
it 'contains two apt::key resources' do
is_expected.to contain_apt__key('duplicate').with({
- :key => title,
+ :id => title,
:ensure => 'present',
})
is_expected.to contain_apt__key(title).with({
- :key => title,
+ :id => title,
:ensure => 'present',
})
end
context 'two apt::key resources, different ensure' do
let :pre_condition do
- "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }"
+ "apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }"
end
it 'informs the user of the impossibility' do
expect { subject }.to raise_error(/already ensured as absent/)
it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
:ensure => 'present',
- :key => GPG_KEY_ID,
+ :id => GPG_KEY_ID,
})
}
end
it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
:ensure => 'present',
- :key => GPG_KEY_ID,
+ :id => GPG_KEY_ID,
:server => 'pgp.mit.edu',
:content => 'GPG key content',
:source => 'http://apt.puppetlabs.com/pubkey.gpg',