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