summaryrefslogtreecommitdiff
path: root/modules/profiles/manifests/common.pp
blob: 4cb5226a1ba0ce4a0d2fb830d45be33f8638d76e (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
class profiles::common (
  String $timezone,
  Array[String] $locales = [ 'en_US.UTF-8', ],
) {

  file_line { 'hosts ourself':
    ensure => present,
    line   => "::1\t${facts['name']}\t${::fqdn}",
    path   => '/etc/hosts',
  }

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

  # 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', ],
    refreshonly => true,
  }

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

}