Puppet Class: consul::params

Inherited by:
consul
Defined in:
manifests/params.pp

Overview

Class consul::params

This class is meant to be called from consul It sets variables according to platform



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
90
91
92
93
94
# File 'manifests/params.pp', line 7

class consul::params {
  case $facts['os']['architecture'] {
    'x86_64', 'x64', 'amd64': { $arch = 'amd64' }
    'i386':                   { $arch = '386' }
    'aarch64':                { $arch = 'arm64' }
    'armv7l':                 { $arch = 'armhfv6' }
    /^arm.*/:                 { $arch = 'arm' }
    default:                  {
      fail("Unsupported kernel architecture: ${facts['os']['architecture']}")
    }
  }

  $config_dir = $facts['os']['family'] ? {
    'FreeBSD' => '/usr/local/etc/consul.d',
    'windows' => 'C:\\ProgramData\\consul\\config',
    default   => '/etc/consul'
  }

  $bin_dir = $facts['os']['family'] ? {
    'windows' => 'C:\\ProgramData\\consul',
    default   => '/usr/local/bin'
  }

  case $facts['os']['name'] {
    'windows': {
      $data_dir_mode = '0775'
      $binary_group = undef
      $binary_mode = '0775'
      $binary_name = 'consul.exe'
      $binary_owner = 'NT AUTHORITY\NETWORK SERVICE'
      $config_defaults  = {
        data_dir => 'C:\\ProgramData\\consul',
      }
      $manage_user = false
      $manage_group = false
      $user = 'NT AUTHORITY\NETWORK SERVICE'
      $group = 'Administrators'
    }
    default: {
      # 0 instead of root because OS X uses "wheel".
      $data_dir_mode = '0755'
      $binary_group = '0'
      $binary_mode = '0555'
      $binary_name = 'consul'
      $binary_owner = 'root'
      $config_defaults  = {
        data_dir => '/opt/consul',
      }
      $manage_user = true
      $manage_group = true
      $user = 'consul'
      $group = 'consul'
    }
  }

  case $facts['os']['name'] {
    'Ubuntu': {
      $shell = '/usr/sbin/nologin'
    }
    'RedHat': {
      $shell = '/sbin/nologin'
    }
    'Debian': {
      $shell = '/usr/sbin/nologin'
    }
    'Archlinux': {
      $shell = '/sbin/nologin'
    }
    'OpenSuSE': {
      $shell = '/usr/sbin/nologin'
    }
    /SLE[SD]/: {
      $shell = '/usr/sbin/nologin'
    }
    default: {
      $shell = undef
    }
  }

  if $facts['os']['family'] == 'windows' {
    $init_style = 'unmanaged'
  } else {
    $init_style = $facts['service_provider'] ? {
      undef   => 'systemd',
      default => $facts['service_provider']
    }
  }
}