aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystem/apt.pp
blob: c927062bf10224c5801d8926c3dae2b7559137c1 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class nodo::subsystem::apt {
  #
  # Apt configuration
  #
  class { '::apt':
    include_src      => hiera('nodo::subsystem::apt::include_src',      false),
    use_next_release => hiera('nodo::subsystem::apt::use_next_release', false),
    custom_key_dir   => hiera('nodo::subsystem::apt::custom_key_dir',   'puppet:///modules/site_apt/keys.d')
  }

  class { '::apt::unattended_upgrades': }

  $apt_domain_source = hiera('nodo::subsystem::apt::domain_source', false)

  ::apt::sources_list { "${::domain}.list":
    source => [ "puppet:///modules/site_apt/sources.list.d/${::operatingsystem}/${::lsbdistcodename}/${::domain}.list",
                "puppet:///modules/site_apt/sources.list.d/${::operatingsystem}/${::domain}.list",
                "puppet:///modules/nodo/etc/sources.list.d/domain.list", ],
    ensure => $apt_domain_source ? {
      true    => present,
      default => absent,
    }
  }

  # Preferences file can't have dots in the filename
  $apt_domain_preferences = regsubst($::domain, '\.', '-', 'G')

  file { "/etc/apt/preferences.d/${apt_domain_preferences}":
    source => [ "puppet:///modules/site_apt/preferences.d/${::operatingsystem}/${::domain}",
                "puppet:///modules/nodo/preferences.d/custom" ],
    ensure => $apt_domain_source ? {
      true    => present,
      default => absent,
    },
    owner => root,
    group => root,
    mode  => 0644,
  }

  $apt_proxy = hiera('nodo::subsystem::apt::proxy', false)

  if $apt_proxy != false {
    class { 'apt::proxy_client':
      proxy => $apt_proxy,
      port  => hiera('nodo::subsystem::apt::proxy_port', '3142'),
    }
  } else {
    class { 'apt::proxy_client':
      proxy  => 'none',
      ensure => absent,
    }
  }

  $apt_include_sid = hiera('nodo::subsystem::apt::include_sid', false)

  ::apt::sources_list { 'sid.list':
    content => "deb http://http.debian.net/debian/ unstable main contrib non-free\n",
    ensure  => $apt_include_sid ? {
      true    => present,
      default => absent,
    },
  }

  $squeeze_lts = 'http://http.debian.net/debian/ squeeze-lts main contrib non-free'

  # See https://wiki.debian.org/LTS/Using
  ::apt::sources_list { 'squeeze-lts.list':
    content => "deb ${squeeze_lts}\ndeb-src ${squeeze_lts}",
    ensure  => $::lsbdistcodename ? {
      'squeeze' => present,
      default   => absent,
    }
  }

  file { '/etc/apt/apt.conf.d/80default-release':
    owner   => root,
    group   => root,
    mode    => 0644,
    content => "APT::Default-Release \"squeeze-lts\";\n",
    ensure  => $::lsbdistcodename ? {
      'squeeze' => present,
      default   => absent,
    }
  }

  package { 'apt-transport-https':
    ensure => present,
  }
}