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]) {
43 $digest_command = $method ? {
44 'content' => "echo '${key_content}' | /usr/bin/apt-key add -",
45 'source' => "wget -q '${key_source}' -O- | apt-key add -",
46 'server' => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'",
49 command => $digest_command,
50 path => '/bin:/usr/bin',
51 unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'",
52 logoutput => 'on_failure',
53 before => Anchor["apt::key ${upkey} present"],
57 Anchor["apt::key $upkey present"] -> Anchor["apt::key/$title"]
62 if defined(Anchor["apt::key ${upkey} present"]) {
63 fail("Cannot ensure Apt::Key[${upkey}] absent; ${upkey} already ensured present")
66 exec { "apt::key ${upkey} absent":
67 command => "apt-key del '${upkey}'",
68 path => '/bin:/usr/bin',
69 onlyif => "apt-key list | grep '${upkey}'",
72 logoutput => 'on_failure',
77 fail "Invalid 'ensure' value '${ensure}' for aptkey"