summaryrefslogtreecommitdiff
path: root/puppet/modules/site_config/manifests/hosts.pp
blob: a3ce0c1f68131310d807ba263c4e280205626b5e (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
class site_config::hosts() {
  $hosts         = hiera('hosts', false)
  $hostname      = hiera('name')
  $domain_hash   = hiera('domain')
  $domain_public = $domain_hash['full_suffix']

  file { '/etc/hostname':
    ensure  => present,
    content => $hostname
  }

  exec { "/bin/hostname ${hostname}":
    subscribe   => [ File['/etc/hostname'], File['/etc/hosts'] ],
    refreshonly => true;
  }

  # we depend on reliable hostnames from /etc/hosts for the stunnel services
  # so restart stunnel service when /etc/hosts is modified
  # because this is done in an early stage, the stunnel module may not
  # have been deployed and will not be available for overriding, so
  # this is handled in an unorthodox manner
  exec { '/etc/init.d/stunnel4 restart':
    subscribe   => File['/etc/hosts'],
    refreshonly => true,
    onlyif      => 'test -f /etc/init.d/stunnel4';
  }

  file { '/etc/hosts':
    content => template('site_config/hosts'),
    mode    => '0644',
    owner   => root,
    group   => root;
  }
}