summaryrefslogtreecommitdiff
path: root/manifests/common.pp
blob: 1b66357dac07d8a52fbf29eae12b0de82f31de0b (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
# Common settings which all hosts should have applied
class profiles::common (
  String $timezone = 'UTC',
  Array[String] $locales = [ 'en_US.UTF-8', ],
) {

  $os_fam = $facts['os']['family'].downcase()
  if defined("profiles::common::${os_fam}") {
    include "profiles::common::${os_fam}"
  }

  file { '/etc/hostname':
    content => "${::hostname}\n",
  }

  file_line { 'hosts ourself':
    ensure => present,
    line   => "::1\t${::fqdn}\t${::hostname}",
    match  => $::fqdn,
    path   => '/etc/hosts',
  }

  file { '/etc/localtime':
    ensure => link,
    target => "../usr/share/zoneinfo/${timezone}",
  }

  if $facts['os']['name'] == 'Debian' {
    ensure_packages (['locales'], {
      before => Exec['locale-gen'],
    })
  }

  # TODO possibly check in /usr/share/i18n/locales if file exists
  # there

  $fixed_locales = ($locales.map |$locale| {
    if $locale =~ /^[^.]*\.(.*)$/ {
      "${locale} ${1}"
    } else {
      "${locale} UTF-8"
    }
  } + [ '' ])

  file { '/etc/locale.gen':
    content => $fixed_locales.join("\n")
  } ~> exec { 'locale-gen':
    path        => [ '/bin', '/usr/bin', '/usr/sbin', ],
    refreshonly => true,
  }

  file { 'Default locales':
    path    => '/etc/locale.conf',
    content => @(EOF)
      LANG=en_US.UTF-8
      LC_TIME=sv_SE.UTF-8
      | EOF
  }

  # Min priority, so it can still be overwritten
  file { '/etc/profile.d/00-terminal-name.sh':
    source => 'puppet:///modules/profiles/terminal-name.sh',
  }

  if $facts['virtual'] == 'systemd_nspawn' {
    include ::profiles::nspawned
  }

  ensure_packages([
    'tree',
    'lsof',
    'unzip',
    ])

  ensure_packages(['nano'], { ensure => absent })

  file { '/etc/ld.so.conf.d/usr-local.conf':
    content => "/usr/local/lib\n",
  }

  # If a btrfs filesystem is detected, install userspace utilities.
  if $facts['filesystems'] =~ 'btrfs' {
    ensure_packages([
      # Package name checked for Archlinux
      'btrfs-progs',
    ])
  }
}