Added apt::key and apt::repo
This commit is contained in:
parent
11a5de8781
commit
592d69eb64
1 changed files with 81 additions and 0 deletions
|
@ -7,6 +7,12 @@ class apt {
|
|||
group => root,
|
||||
}
|
||||
|
||||
exec { "apt-get-update":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => "apt-get update",
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,3 +130,78 @@ define apt::package($ensure, $source) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Add apt key.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Key id.
|
||||
# $keyserver:
|
||||
# Name of keyserver.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# apt::key { "886DDD89":
|
||||
# keyserver => "keys.gnupg.net",
|
||||
# }
|
||||
#
|
||||
define apt::key($keyserver) {
|
||||
|
||||
include apt
|
||||
|
||||
exec { "apt-key-add":
|
||||
environment => $http_proxy ? {
|
||||
"" => undef,
|
||||
default => "http_proxy=${http_proxy}",
|
||||
},
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => "apt-key adv --keyserver ${keyserver} --recv ${name}",
|
||||
unless => "apt-key list | grep '\\b${name}\\b'",
|
||||
notify => Exec["apt-get-update"],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Add apt repository.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# Repository name.
|
||||
# $source:
|
||||
# Repository URL.
|
||||
# $dist:
|
||||
# Distribution name. Defaults to $lsbdistcodename.
|
||||
# $components
|
||||
# Repository components. Defaults to "main".
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# apt::repo { "deb.torproject.org":
|
||||
# source => "http://deb.torproject.org/torproject.org",
|
||||
# require => Apt::Key["886DDD89"],
|
||||
# }
|
||||
#
|
||||
define apt::repo($source, $dist="", $components="main") {
|
||||
|
||||
if $dist {
|
||||
$dist_real = $dist
|
||||
} else {
|
||||
$dist_real = $lsbdistcodename
|
||||
}
|
||||
|
||||
include apt
|
||||
|
||||
file { "/etc/apt/sources.list.d/${name}.list":
|
||||
ensure => present,
|
||||
mode => 0644,
|
||||
owner => root,
|
||||
group => root,
|
||||
content => "deb ${source} ${dist_real} ${components}\ndeb-src ${source} ${dist_real} ${components}\n",
|
||||
notify => Exec["apt-get-update"],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue