Puppet Class: mattermost::install

Inherits:
mattermost
Defined in:
manifests/install.pp

Overview

See README.md.



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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'manifests/install.pp', line 2

class mattermost::install inherits mattermost {
  if $mattermost::edition == 'team' {
    $filename = regsubst(
      $mattermost::filename,
      '__EDITION__-__VERSION__',
      "${mattermost::edition}-${mattermost::version}"
    )
    $download_filename = "mattermost_team_v${mattermost::version}.tar.gz"
  }
  else {
    $filename = regsubst(
      $mattermost::filename,
      '__EDITION__-__VERSION__',
      $mattermost::version
    )
    $download_filename = "mattermost_enterprise_v${mattermost::version}.tar.gz"
  }
  $full_url = regsubst(
    $mattermost::full_url,
    '__PLACEHOLDER__',
    "${mattermost::base_url}/${mattermost::version}/${filename}"
  )
  $dir = regsubst(
    $mattermost::dir,
    '__VERSION__',
    $mattermost::version
  )
  $conf = regsubst(
    $mattermost::conf,
    '__DIR__',
    $dir
  )
  $env_conf = $mattermost::env_conf
  $mode = $mattermost::service_mode? {
    ''      => undef,
    default => $mattermost::service_mode,
  }
  $executable = $mattermost::executable
  $service_name = $mattermost::service_name
  $service_path = regsubst(
    $mattermost::service_path,
    '__SERVICENAME__',
    $service_name
  )
  if $mattermost::install_from_pkg {
    package { $mattermost::pkg:
      ensure => $mattermost::version,
    }
  }
  else {
    if $mattermost::create_user {
      user { $mattermost::user:
        home   => $mattermost::symlink,
        uid    => $mattermost::uid,
        gid    => $mattermost::gid,
        before => [
          File[$dir],
          Archive[$download_filename],
        ],
      }
    }
    if $mattermost::create_group {
      group { $mattermost::group:
        gid    => $mattermost::gid,
        before => [
          File[$dir],
          Archive[$download_filename],
        ],
      }
    }
    file { $dir:
      ensure => directory,
      owner  => $mattermost::user,
      group  => $mattermost::group,
    }
    archive { $download_filename:
      path            => "/tmp/${download_filename}",
      source          => $full_url,
      extract         => true,
      extract_path    => $dir,
      extract_command => 'tar xfz %s --strip-components=1',
      creates         => "${dir}/bin/${executable}",
      user            => $mattermost::user,
      group           => $mattermost::group,
      require         => File[$dir],
    }
    file { $mattermost::symlink:
      ensure => link,
      target => $dir,
    }
    if $mattermost::install_service {
      file { 'mattermost.service':
        path    => $service_path,
        content => template($mattermost::service_template),
        mode    => $mode,
      }
    }
    if $mattermost::data_dir and $mattermost::manage_data_dir{
      file { $mattermost::data_dir:
        ensure  => directory,
        owner   => $mattermost::user,
        group   => $mattermost::group,
        mode    => '0754',
        require => Archive[$download_filename],
      }
    }
    if $mattermost::log_dir and $mattermost::manage_log_dir{
      file { $mattermost::log_dir:
        ensure  => directory,
        owner   => $mattermost::user,
        group   => $mattermost::group,
        mode    => '0754',
        require => Archive[$download_filename],
      }
    }
  }
}