6 $key_server = 'keyserver.ubuntu.com'
21 # This is a hash of the parts of the key definition that we care about.
22 # It is used as a unique identifier for this instance of apt::key. It gets
23 # hashed to ensure that the resource name doesn't end up being pages and
24 # pages (e.g. in the situation where key_content is specified).
25 $digest = sha1("${upkey}/${key_content}/${key_source}/${key_server}/")
27 # Allow multiple ensure => present for the same key to account for many
28 # apt::source resources that all reference the same key.
32 anchor { "apt::key/${title}":; }
34 if defined(Exec["apt::key $upkey absent"]) {
35 fail ("Cannot ensure Apt::Key[$upkey] present; $upkey already ensured absent")
38 if !defined(Anchor["apt::key $upkey present"]) {
39 anchor { "apt::key $upkey present":; }
42 if !defined(Exec[$digest]) {
44 path => '/bin:/usr/bin',
45 unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'",
46 before => Anchor["apt::key ${upkey} present"],
47 command => $method ? {
48 'content' => "echo '${key_content}' | /usr/bin/apt-key add -",
49 'source' => "wget -q '${key_source}' -O- | apt-key add -",
50 'server' => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'",
55 Anchor["apt::key $upkey present"] -> Anchor["apt::key/$title"]
60 if defined(Anchor["apt::key $upkey present"]) {
61 fail ("Cannot ensure Apt::Key[$upkey] absent; $upkey already ensured present")
64 exec { "apt::key $upkey absent":
65 path => '/bin:/usr/bin',
66 onlyif => "apt-key list | grep '${upkey}'",
67 command => "apt-key del '${upkey}'",
74 fail "Invalid 'ensure' value '${ensure}' for aptkey"