summaryrefslogtreecommitdiff
path: root/manifests/init.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/init.pp')
-rw-r--r--manifests/init.pp62
1 files changed, 41 insertions, 21 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index fb23328..4deaf9a 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,33 +1,54 @@
+# @summary Configures the Pacman package manager
+# @param hooks_path
+# Path for puppet added hooks
+# @param conf_path
+# Path for pacman configuration
+# @param ilovecandy
+# It's a secret to everybody.
+# @param parallel_downloads
+# @param mirrorlist
+# @param update
+# Should 'pacman -Sy' be run after changes to the configuration?
class pacman (
String $hooks_path = '/etc/pacman.d/hooks-puppet',
String $conf_path = '/etc/pacman.conf',
Boolean $ilovecandy = false,
+ Optional[Integer] $parallel_downloads = undef,
+ String $mirrorlist = "puppet:///modules/${module_name}/mirrorlist",
+ Boolean $update = false,
) {
+ $hooks_ = [$hooks_path]
+ $parallel_downloads_ = if versioncmp($facts['pacman-version'], '6.0.0') != -1 {
+ $parallel_downloads
+ } else {
+ false
+ }
- ini_setting { 'Pacman HookDir':
- path => $conf_path,
- section => 'options',
- setting => 'HookDir',
- value => $hooks_path,
+ concat { $conf_path:
+ ensure => present,
+ order => 'numeric',
+ backup => true,
+ }
+ if $update {
+ exec { 'pacman -Sy':
+ command => ['pacman', '-Sy'],
+ path => ['/bin', '/usr/bin'],
+ refreshonly => true,
+ subscribe => Concat[$conf_path],
+ }
}
- ini_setting { 'Pacman ILoveCandy':
- ensure => if ($ilovecandy) { present } else { absent },
- path => '/etc/pacman.conf',
- section => 'options',
- setting => 'ILoveCandy',
- key_val_separator => '',
- value => '',
+ concat::fragment { 'pacman.conf header':
+ target => $conf_path,
+ source => "puppet:///modules/${module_name}/header",
+ order => 0,
}
- if versioncmp($facts['pacman-version'], '6.0.0') >= 0 {
- ini_setting { 'Pacman parallel downloads':
- path => '/etc/pacman.conf',
- section => 'options',
- setting => 'ParallelDownloads',
- value => 8,
- }
+ concat::fragment { 'pacman.conf options':
+ target => $conf_path,
+ order => 1,
+ content => epp("${module_name}/pacman.conf.epp"),
}
file { $hooks_path:
@@ -37,8 +58,7 @@ class pacman (
}
file { '/etc/pacman.d/mirrorlist':
- ensure => present,
backup => true,
- source => 'puppet:///modules/pacman/mirrorlist',
+ source => $mirrorlist,
}
}