aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystem/apt/repo.pp
blob: 0495a0ff4614d80fa4066d08aaae723a60145195 (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
define nodo::subsystem::apt::repo(
  $definition,
  $key_source,
  $keyrings_folder = '/etc/apt/keyrings',
  $keyring_name    = $name,
  $ensure          = present,
) {
  # The recommended locations for keyrings are /usr/share/keyrings for keyrings
  # managed by packages, and /etc/apt/keyrings for keyrings managed by the
  # system operator. If no keyring files are specified the default is the
  # trusted.gpg keyring and all keyrings in the trusted.gpg.d/ directory (see
  # apt-key fingerprint).
  #
  # -- sources.list(5)
  file { "${keyrings_folder}/${name}.gpg":
    ensure  => $ensure,
    owner   => "root",
    group   => "root",
    mode    => "0644",
    source  => $key_source,
  }

  # Old location
  file { "/etc/apt/trusted.gpg.d/${name}.gpg":
    ensure  => absent,
    owner   => "root",
    group   => "root",
    mode    => "0644",
    source  => $key_source,
  }

  file { "/etc/apt/sources.list.d/${name}.list":
    ensure  => $ensure,
    owner   => "root",
    group   => "root",
    mode    => "0644",
    content => "${definition}\n",
    require => [ File["${keyrings_folder}/${name}.gpg"], Package['apt-transport-https'] ],
    notify  => Exec["apt-repo-auto-update-${name}"],
  }

  exec { "apt-repo-auto-update-${name}":
    command     => "/usr/bin/apt-get update",
    user        => "root",
    refreshonly => true,
  }
}