summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 9b65050359c8796d0a9dc009744969f71d21ffca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# @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?
# @param include_default
#   Should Archlinux' regular repositories be included
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,
  Boolean $include_default = true,
) {
  $hooks_ = [$hooks_path]
  $parallel_downloads_ = if versioncmp($facts['pacman-version'], '6.0.0') != -1 {
    $parallel_downloads
  } else {
    false
  }

  include pacman::setup

  if $update {
    exec { 'pacman -Sy':
      command     => ['pacman', '-Sy'],
      path        => ['/bin', '/usr/bin'],
      refreshonly => true,
      subscribe   => Concat[$conf_path],
    }
  }

  concat::fragment { 'pacman.conf header':
    target => $conf_path,
    source => "puppet:///modules/${module_name}/header",
    order  => 0,
  }

  concat::fragment { 'pacman.conf options':
    target  => $conf_path,
    order   => 1,
    content => epp("${module_name}/pacman.conf.epp"),
  }

  file { $hooks_path:
    ensure  => directory,
    recurse => true,
    purge   => true,
  }

  file { '/etc/pacman.d/mirrorlist':
    backup => true,
    source => $mirrorlist,
  }

  if $include_default {
    pacman::repo { ['core', 'extra', 'community']:
      include => '/etc/pacman.d/mirrorlist',
    }
  }
}