Puppet Class: gitlab::setup

Inherits:
gitlab
Defined in:
manifests/setup.pp

Overview

Class

gitlab::setup



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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'manifests/setup.pp', line 4

class gitlab::setup inherits gitlab {

  include ::git

  File {
    owner => $git_user,
    group => $git_group,
  }

  # user
  if($gitlab_manage_user)
  {
    user { $git_user:
      ensure   => present,
      shell    => '/bin/bash',
      password => '*',
      home     => $git_home,
      comment  => $git_comment,
      system   => true,
    }
  }

  sshkey { 'localhost':
    ensure       => present,
    host_aliases => $::fqdn,
    key          => $::sshrsakey,
    type         => 'ssh-rsa',
  }

  file { "${git_home}/.gitconfig":
    ensure  => file,
    content => template('gitlab/git.gitconfig.erb'),
    mode    => '0644',
  }

  # directories
  if($gitlab_manage_home)
  {
    file { $git_home:
      ensure => directory,
      mode   => '0755',
    }
  }

  file { "${gitlab_satellitedir}/gitlab-satellites":
    ensure => directory,
    mode   => '0750',
  }

  # database dependencies
  case $::osfamily {
    'Debian': {
      case $gitlab_dbtype {
        'mysql': {
          ensure_packages(['libmysql++-dev','libmysqlclient-dev'])
        }
        'pgsql': {
          ensure_packages(['libpq-dev','postgresql-client'])
        }
        default: {
          fail("unknow dbtype (${gitlab_dbtype})")
        }
      }
    }
    'RedHat': {
      case $gitlab_dbtype {
        'mysql': {
          if (versioncmp($::operatingsystemmajrelease, '7') >= 0) {
            $mysql_devel_package = 'mariadb-devel'
          } else {
            $mysql_devel_package = 'mysql-devel'
          }
          ensure_packages([$mysql_devel_package])
        }
        'pgsql': {
          ensure_packages(['postgresql-devel'])
        }
        default: {
          fail("unknow dbtype (${gitlab_dbtype})")
        }
      }
    }
    default: {
      fail("${::osfamily} not supported yet")
    }
  } # Case $::osfamily

  # dev. dependencies
  ensure_packages($gitlab::system_packages)

  if ($gitlab_manage_rbenv) {
    rbenv::install { $git_user:
      group => $git_group,
      home  => $git_home,
    }

    # By default, puppet-rbenv sets ~/.profile to load rbenv, which is
    # read when bash is invoked as an interactive login shell, but we
    # also need ~/.bashrc to load rbenv (which is read by interactive
    # but non-login shells). This works, but may not be the best
    # solution, please see issue #114 if you have a better solution.
    file { "${git_home}/.bashrc":
      ensure  => link,
      target  => "${git_home}/.profile",
      require => Rbenv::Install[$git_user],
    }

    rbenv::compile { 'gitlab/ruby':
      user   => $git_user,
      group  => $git_group,
      home   => $git_home,
      ruby   => $gitlab_ruby_version,
      global => true,
      notify => [
        Exec['install gitlab-shell'],
        Exec['install gitlab'],
      ],
    }

    #Gitlab <= 6.3 requires us to install the charlock_holmes gem
    rbenv::gem { 'charlock_holmes':
      ensure => '0.6.9.4',
      user   => $git_user,
      home   => $git_home,
      ruby   => $gitlab_ruby_version,
    }
  } #end if ($gitlab_manage_rbenv)

  # other packages
  if $gitlab_ensure_curl {
    ensure_packages(['curl'])
  }

  if $gitlab_ensure_postfix {
    ensure_packages(['postfix'])
  }
}