Skip to content

Commit e55560a

Browse files
committed
First commit Adds erb template
1 parent 3335b31 commit e55560a

8 files changed

Lines changed: 186 additions & 36 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Facter.add("operatingsystem_lowercase") do
2+
setcode do
3+
Facter.value('operatingsystem').downcase
4+
end
5+
end

manifests/backup.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class gitlab::backup inherits ::gitlab {
2+
3+
# Execute rake backup every night at 2 am
4+
cron { 'gitlab-backup':
5+
command => "/opt/gitlab/bin/gitlab-rake gitlab:backup:create",
6+
user => root,
7+
hour => 2,
8+
minute => 0,
9+
}
10+
}

manifests/config.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class gitlab::config inherits ::gitlab {
2+
3+
file {'/tmp/herp':
4+
content => template('gitlab/gitlab-puppet.rb.erb'),
5+
}
6+
7+
}

manifests/init.pp

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
# init -> packages -> user -> setup -> install -> config -> service
22
class gitlab (
33

4-
4+
$puppet_manage_config = $gitlab::params::puppet_manage_config,
55
# Gitlab server settings
66
$gitlab_branch = $gitlab::params::gitlab_branch,
7-
$gitlabshell_branch = $gitlab::params::gitlabshell_branch,
7+
$gitlab_release = $gitlab::params::gitlab_release,
88
$git_user = $gitlab::params::git_user,
99
$git_home = $gitlab::params::git_home,
1010
$git_email = $gitlab::params::git_email,
1111
$git_comment = $gitlab::params::git_comment,
1212
$git_ssh_port = $gitlab::params::git_ssh_port,
13-
$gitlab_sources = $gitlab::params::gitlab_sources,
14-
$gitlabshell_sources = $gitlab::params::gitlabshell_sources,
1513

1614
# Database
17-
$gitlab_dbtype = $gitlab::params::gitlab_dbtype,
1815
$gitlab_dbname = $gitlab::params::gitlab_dbname,
1916
$gitlab_dbuser = $gitlab::params::gitlab_dbuser,
2017
$gitlab_dbpwd = $gitlab::params::gitlab_dbpwd,
@@ -64,6 +61,8 @@
6461
$backup_keep_time = $gitlab::params::backup_keep_time,
6562

6663

64+
$redis_port = $gitlab::params::redis_port,
65+
6766
) inherits ::gitlab::params {
6867

6968

@@ -76,17 +75,33 @@
7675
'7.5': {}
7776
'6.5': {}
7877
default: { warning("${operatingsystem} ${operatingsystemrelease} is not on approved list,\
79-
download may fail. See https://about.gitlab.com/downloads/"
78+
download may fail. See https://about.gitlab.com/downloads/ for supported OS's"
8079
) }
8180
}
8281

8382

84-
85-
include gitlab::install
83+
if $puppet_manage_config == true {
84+
notice("Puppet will manage the configuration file because \$puppet_manage_config is true")
85+
include gitlab::install
86+
include gitlab::config
87+
88+
anchor { 'gitlab::begin':}
89+
anchor { 'gitlab::end':}
90+
91+
Anchor['gitlab::begin'] ->
92+
Class['::gitlab::install'] ->
93+
Class['::gitlab::config'] ->
94+
Anchor['gitlab::end']
95+
}
96+
else {
97+
notice("Puppet will not manage the configuration file because \$puppet_manage_config is false")
98+
include gitlab::install
99+
}
86100

87101

102+
if $puppet_manage_backups {
103+
include gitlab::backup
104+
}
105+
88106
}# end gitlab
89-
90-
91-
92-
107+

manifests/install.pp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,45 @@
77
'Debian': {
88
$omnibus_release = "-omnibus-1_amd64.deb"
99
$url_separator = "_"
10+
$package_manager = 'dpkg'
1011
}
1112
'RedHat': {
1213
$omnibus_release = "_omnibus-1.el6x86_64.rpm"
1314
$url_separator = "-"
15+
$package_manager = 'rpm'
16+
1417
}
15-
default: {fail("Only RedHat and Debain OS's are supported, you have: ${operatingsystem} ")}
18+
default: {fail("Only RedHat and Debain OS's are supported, you have: ${operatingsystem} ${operatingsystemrelease} ")}
1619
}
20+
21+
1722

1823
# Sets the download url. Examples
1924
# https://downloads-packages.s3.amazonaws.com/centos-6.5/gitlab-7.0.0_omnibus-1.el6.x86_64.rpm
2025
# https://downloads-packages.s3.amazonaws.com/debian-7.5/gitlab_7.0.0-omnibus-1_amd64.deb
2126
# https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.0.0-omnibus-1_amd64.deb
2227
# https://downloads-packages.s3.amazonaws.com/ubuntu-12.04/gitlab_7.0.0-omnibus-1_amd64.deb
23-
$gitlab_url = "https://downloads-packages.s3.amazonaws.com/ubuntu-${operatingsystemrelease}/gitlab${url_separator}${::gitlab::gitlab_branch}${omnibus_release}"
24-
# $gitlab_url = "https://downloads-packages.s3.amazonaws.com/${operatingsystem}-${operatingsystemrelease}/gitlab${url_separator}${::gitlab::gitlab_branch}${omnibus_release}"
28+
$download_location = '/var/tmp'
29+
$omnibus_filename = "gitlab${url_separator}${::gitlab::gitlab_branch}${omnibus_release}"
30+
$gitlab_url = "https://downloads-packages.s3.amazonaws.com/${::operatingsystem_lowercase}-${operatingsystemrelease}/${omnibus_filename}"
31+
2532

2633
notice("Downloading from ${gitlab_url}")
2734

2835
package {'wget':
2936
ensure => present,
3037
}
31-
exec { "download gitlab":
32-
command => "/usr/bin/wget --progress=dot -nv ${gitlab_url} -O /tmp/gitlab${url_separator}${::gitlab::gitlab_branch}${omnibus_release} 2>&1",
33-
creates => "/var/tmp/gitlab${url_separator}${::gitlab::gitlab_branch}${omnibus_release}",
38+
exec { 'download gitlab':
39+
command => "/usr/bin/wget ${gitlab_url} -O ${download_location}/${omnibus_filename}",
40+
creates => "${download_location}/${omnibus_filename}",
3441
require => Package['wget'],
3542
}
36-
37-
38-
43+
# package { "${omnibus_filename}":
44+
# ensure => installed,
45+
# source => "${download_location}/${omnibus_filename}",
46+
# provider => "${package_manager}",
47+
# require => Exec['download gitlab'],
48+
# }
49+
50+
3951
}

manifests/params.pp

Lines changed: 91 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
class gitlab::params {
33

44
# Manage Packages
5-
$gitlab_manage_packages = true
5+
$puppet_manage_config = false
6+
$puppet_manage_backups = true
67

78
# Gitlab server settings
89
$gitlab_branch = '7.0.0'
9-
$git_user = 'git' # only change if you really know what you are doing
10-
$git_home = '/home/git'
10+
$gitlab_release = 'basic' # enterprise or basic
11+
# $git_home = '/home/git'
1112
$git_email = 'example@example.com'
1213
$git_comment = 'GitLab'
1314
$git_ssh_port = '22'
@@ -28,15 +29,15 @@
2829
$default_servername = 'gitlab' # example gitlab.foo.com
2930

3031

31-
# LDAP
32-
$ldap_enabled = false
33-
$ldap_host = 'ldap.domain.com'
34-
$ldap_base = 'dc=domain,dc=com'
35-
$ldap_uid = 'uid' # Active directory = 'sAMAccountName'
36-
$ldap_port = '636'
37-
$ldap_method = 'ssl' # "tls" or "ssl" or "plain"
38-
$ldap_bind_dn = ''
39-
$ldap_bind_password = ''
32+
# # LDAP
33+
# $ldap_enabled = false
34+
# $ldap_host = 'ldap.domain.com'
35+
# $ldap_base = 'dc=domain,dc=com'
36+
# $ldap_uid = 'uid' # Active directory = 'sAMAccountName'
37+
# $ldap_port = '636'
38+
# $ldap_method = 'ssl' # "tls" or "ssl" or "plain"
39+
# $ldap_bind_dn = ''
40+
# $ldap_bind_password = ''
4041

4142
# Company Branding
4243
$use_custom_login_logo = false
@@ -59,8 +60,83 @@
5960
$gitlab_projects = '15'
6061
$visibility_level = 'internal'
6162

62-
# Backup
63-
$backup_path = 'tmp/backups' # Relative paths are relative to Rails.root (default: tmp/backups/)
64-
$backup_keep_time = '0' # default: 0 (forever) (in seconds), 604800 = 1 week
63+
# # Backup
64+
# $backup_path = 'tmp/backups' # Relative paths are relative to Rails.root (default: tmp/backups/)
65+
# $backup_keep_time = '0' # default: 0 (forever) (in seconds), 604800 = 1 week
66+
67+
#Omnibus configuration
68+
69+
# Define port numbers as strings
70+
$redis_port = undef # 6379
71+
$postgresql_port = undef # 5432
72+
$unicorn_port = undef # 8080
73+
74+
$git_data_dir = undef # "/var/opt/gitlab/git-data"
75+
$gitlab_username = undef # "gitlab"
76+
$gitlab_group = undef # "gitlab"
77+
78+
# These settings are documented in more detail at
79+
# https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/gitlab.yml.example#L118
80+
$ldap_enabled = true
81+
$ldap_host = 'hostname of LDAP server'
82+
$ldap_port = 389 # or 636
83+
$ldap_uid = 'sAMAccountName' # or 'uid'
84+
$ldap_method = 'plain' # 'ssl' or 'plain'
85+
$ldap_bind_dn = 'CN=query user,CN=Users,DC=mycorp,DC=com'
86+
$ldap_password = 'query user password'
87+
88+
$ldap_allow_username_or_email_login = true
89+
$ldap_base = 'DC=mycorp,DC=com'
90+
91+
# GitLab Enterprise Edition only
92+
$ldap_group_base = '' # Example: 'OU=groups,DC=mycorp,DC=com'
93+
$ldap_user_filter = '' # Example: '(memberOf=CN=my department,OU=groups,DC=mycorp,DC=com)'
94+
95+
# external_url "https://gitlab.example.com"
96+
97+
$redirect_http_to_https = true
98+
$ssl_certificate = "/etc/gitlab/ssl/gitlab.crt"
99+
$ssl_certificate_key = "/etc/gitlab/ssl/gitlab.key"
100+
101+
$git_uid = 1001
102+
$git_gid = 1002
103+
$gitlab_redis_uid = 998
104+
$gitlab_redis_gid = 1003
105+
$gitlab_psql_uid = 997
106+
$gitlab_psql_gid = 1004
107+
108+
$aws_enable = true
109+
$aws_access_key_id = 'AKIA1111111111111UA'
110+
$aws_secret_access_key = 'secret'
111+
$aws_bucket = 'my_gitlab_bucket'
112+
$aws_region = 'us-east-1'
113+
114+
$smtp_enable = true
115+
$smtp_address = "smtp.server"
116+
$smtp_port = 456
117+
$smtp_user_name = "smtp user"
118+
$smtp_password = "smtp password"
119+
$smtp_domain = "example.com"
120+
$smtp_authentication = "login"
121+
$smtp_enable_starttls_auto = true
122+
123+
$omniauth_enabled = true
124+
$omniauth_providers = '[
125+
{
126+
"name" => "google_oauth2",
127+
"app_id" => "YOUR APP ID",
128+
"app_secret" => "YOUR APP SECRET",
129+
"args" => { "access_type" => "offline", "approval_prompt" => "" }
130+
}
131+
]'
132+
133+
# Below are the default values
134+
$svlogd_size = 200 * 1024 * 1024 # rotate after 200 MB of log data
135+
$svlogd_num = 30 # keep 30 rotated log files
136+
$svlogd_timeout = 24 * 60 * 60 # rotate after 24 hours
137+
$svlogd_filter = "gzip" # compress logs with gzip
138+
$svlogd_udp = nil # transmit log messages via UDP
139+
$svlogd_prefix = nil # custom prefix for log messages
140+
65141

66142
}

templates/gitlab-puppet.rb.erb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% if @redis_port %> redis['port'] = <%= @redis_port %> <% end %>
2+
<% if @postgresql_port %> posgresql['port'] = <%= @postgresql_port %> <% end %>
3+
<% if @unicorn_port %> unicorn_port['port'] = <%= @unicorn_port %> <% end %>
4+
5+
<% if @git_data_dir %> git_data_dir = <%= @git_data_dir %> <% end %>
6+
<% if @gitlab_username %> user['username'] = <%= @gitlab_username %> <% end %>
7+
<% if @gitlab_group %> user['group'] = <%= @gitlab_group %> <% end %>
8+
9+
10+
<% if @ldap_enabled == true %>
11+
gitlab_rails['ldap_enabled'] = <%= @ldap_enabled %>
12+
gitlab_rails['ldap_host'] = <%= @ldap_host %>
13+
gitlab_rails['ldap_port'] = <%= @ldap_port %>
14+
gitlab_rails['ldap_uid'] = <%= @ldap_uid %>
15+
gitlab_rails['ldap_method'] = <%= @ldap_method %>
16+
gitlab_rails['ldap_bind_dn'] = <%= @ldap_bind_dn %>
17+
gitlab_rails['ldap_password'] = <%= @ldap_password %>
18+
gitlab_rails['ldap_allow_username_or_email_login'] = <%= @ldap_allow_username_or_email_login %>
19+
gitlab_rails['ldap_base'] = <%= @ldap_base %>
20+
<% end %>
21+
<% if @ldap_enabled ==true and @gitlab_release == 'enterprise' %>
22+
gitlab_rails['ldap_group_base'] = <%= @ldap_group_base %>
23+
gitlab_rails['ldap_user_filter'] = <%= @ldap_user_filter %>
24+
<% end %>

tests/init.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# git_ssh_port => '22',
88
# gitlab_sources => 'git://github.com/gitlabhq/gitlabhq.git',
99
gitlab_branch => '7.0.0',
10+
puppet_manage_config => true,
1011
# gitlabshell_sources => 'git://github.com/gitlabhq/gitlab-shell.git',
1112
# gitlabshell_branch => 'v1.9.4',
1213

0 commit comments

Comments
 (0)