summaryrefslogtreecommitdiff
path: root/manifests/repo.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/repo.pp')
-rw-r--r--manifests/repo.pp72
1 files changed, 51 insertions, 21 deletions
diff --git a/manifests/repo.pp b/manifests/repo.pp
index 9d62417..8607853 100644
--- a/manifests/repo.pp
+++ b/manifests/repo.pp
@@ -1,29 +1,59 @@
+# @summary A Pacman repo
+#
+# @param ensure
+# @param repo_name
+# Name of repo, exposed to mirrorlists as $repo
+# @param siglevel
+# @param usage
+# @param include
+# A repolist to include, mutually exclusive with $server and $source
+# @param server
+# A direct server to use, mutually exclusive with $include and $source
+# @param source
+# A complete list of sources to pull from.
+# Should be a list of strings on the form "Include = ${include}" or
+# "Server = ${server}". Where include is a path to a mirrorlist, and
+# server is a direct url.
+#
+# Mutually exclusive with $include and $server.
define pacman::repo (
Enum['present', 'absent'] $ensure = 'present',
String $repo_name = $name,
- # String $include,
- String $server,
- String $sig_level,
+ Optional[Enum['Never', 'Optional', 'Required']] $siglevel = undef,
+ Optional[Enum['Sync', 'Search', 'Install', 'Upgrade', 'All']] $usage = undef,
+ Optional[String] $include = undef,
+ Optional[String] $server = undef,
+ Optional[Array[String,1]] $source = undef,
) {
- require ::pacman
+ require pacman
- # NOTE we don't trigger a package database refresh here, since
- # 'pacman -Sy' is strongly discouraged, while
- # 'pacman -Syu' does to much.
+ if $repo_name == 'local' {
+ fail('Repo name "local" is reserved by Pacman')
+ }
+
+ # Check that at mots one of the following are defined
+ # At least one is required, but that is checked bellow.
+ if [$include, $server, $source].filter |$x| { $x =~ NotUndef }.length > 1 {
+ fail('$include, $server, and $source mutually exclusive')
+ }
+
+ $source_ = if $source {
+ $source
+ } elsif $server {
+ ["Server = ${server}"]
+ } elsif $include {
+ ["Include = ${include}"]
+ } else {
+ fail('$source, $include, or $server required')
+ }
- ini_setting {
- default:
- ensure => $ensure,
- path => $::pacman::conf_path,
- section => $repo_name ,
- ;
- "Pacman repo [${repo_name}] server":
- setting => 'Server',
- value => $server ,
- ;
- "Pacman repo [${repo_name}] SigLevel":
- setting => 'SigLevel',
- value => $sig_level ,
- ;
+ concat::fragment { "pacman.conf - repo - ${repo_name}":
+ target => $pacman::conf_path,
+ content => epp("${module_name}/repo.epp", {
+ 'name' => $repo_name,
+ 'siglevel' => $siglevel,
+ 'usage' => $usage,
+ 'source' => $source_,
+ }),
}
}