forked from tingtun/ansible-playbook-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab.yml
207 lines (187 loc) · 6.72 KB
/
gitlab.yml
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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
---
# From https://github.com/gitlabhq/gitlabhq/blob/6-1-stable/doc/install/installation.md
# 1. Packages / Dependencies
- hosts: gitlab
sudo: yes
tasks:
- name: ensure apt cache is up to date
action: apt update_cache=yes
- name: ensure app apt dependencies are installed
action: apt pkg=$item
with_items:
- build-essential
- zlib1g-dev
- libyaml-dev
- libssl-dev
- libgdbm-dev
- libreadline-dev
- libncurses5-dev
- libffi-dev
- curl
- git-core
- redis-server
- checkinstall
- libxml2-dev
- libxslt1-dev
- libcurl4-openssl-dev
- libicu-dev
- python-docutils
- libmysqlclient-dev
- python-mysqldb # Required for ansible mysql module to work, see: http://ansible.cc/docs/modules.html#mysql-user
- hosts: gitlab
sudo: yes
tasks:
- name: ensure /usr/local/bin/python2 links to /usr/bin/python
file: state=link src=/usr/bin/python path=/usr/local/bin/python2
# 2. Ruby
- hosts: gitlab
sudo: no
vars:
url: ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
path: /tmp/ruby/ruby-2.0.0-p247
tasks:
- name: check if ruby is installed
command: ruby --version | grep 2.0.0p247
register: rubyPresent
ignore_errors: True
- name: ensure directory /tmp/ruby is present
file: state=directory path=/tmp/ruby
when: rubyPresent|failed
- name: ensure ruby is downloaded
get_url: url=$url dest=/tmp/ruby
when: rubyPresent|failed
- name: ensure ruby is extracted
command: tar -xf ruby-2.0.0-p247.tar.gz chdir=/tmp/ruby creates=$path
when: rubyPresent|failed
- name: ensure ruby is configured
command: ./configure chdir=$path creates=$path/Makefile
when: rubyPresent|failed
- name: ensure ruby is compiled
command: make chdir=$path creates=$path/ruby
when: rubyPresent|failed
- hosts: gitlab
sudo: yes
vars:
path: /tmp/ruby/ruby-2.0.0-p247
tasks:
- name: ensure ruby is installed
command: make install chdir=$path creates=/usr/local/bin/ruby
when: rubyPresent|failed
- name: ensure bundler is installed
command: gem install bundler --no-ri --no-rdoc creates=/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5
when: rubyPresent|failed
# 3. System Users
- hosts: gitlab
sudo: yes
tasks:
- name: ensure user git is present
user: state=present name=git system=yes shell=/bin/sh comment="Git Version Control"
# 4. GitLab shell
- hosts: gitlab
sudo: yes
sudo_user: git
vars_files:
- vars.yml
tasks:
- name: ensure Gitlab-Shell git repository is cloned
git: repo=https://github.com/gitlabhq/gitlab-shell.git dest=/home/git/gitlab-shell version=v1.7.1
- name: ensure gitlab-shell config is written
action: template src=templates/gitlab_shell_config.yml.tmpl dest=/home/git/gitlab-shell/config.yml mode=0755
- name: ensure gitlab-shell is installed
command: /home/git/gitlab-shell/bin/install
# 6. GitLab
- hosts: gitlab
sudo: yes
sudo_user: git
vars_files:
- vars.yml
tasks:
- name: ensure GitLab 6.1-stable is cloned
git: repo=https://github.com/gitlabhq/gitlabhq.git dest=/home/git/gitlab version=6-1-stable
- name: ensure GitLab config file exists
action: template src=templates/gitlab.yml.tmpl dest=/home/git/gitlab/config/gitlab.yml mode=0755
# 5. Database (MUST BE DONE AFTER GITLAB CHECKOUT)
- hosts: gitlab
sudo: yes
sudo_user: git
vars_files:
- vars.yml
tasks:
- name: ensure database config is written
action: template src=templates/database.yml.tmpl dest=/home/git/gitlab/config/database.yml mode=0755
- name: ensure database gitlabhq_production is present
mysql_db: state=present name=gitlabhq_production collation=utf8_unicode_ci encoding=utf8 login_user=root login_password=$root_database_password
- name: ensure database user gitlab is present and has privleges
mysql_user: state=present name=gitlab host=localhost password=$gitlab_database_password priv=gitlabhq_production.*:ALL login_user=root login_password=$root_database_password
# 6. GitLab Reloaded
- hosts: gitlab
sudo: yes
tasks:
- name: ensure GitLab can write to log
command: chmod -R u+rwX /home/git/gitlab/log
- name: ensure GitLab can write to tmp
command: chmod -R u+rwX /home/git/gitlab/tmp
- hosts: gitlab
sudo: yes
sudo_user: git
vars_files:
- vars.yml
tasks:
- name: ensure directory for satellites exists
file: state=directory path=/home/git/gitlab-satellites
- name: Make sure that socket dir exists
action: file path=/home/git/gitlab/tmp/sockets state=directory
- name: Make sure that pids dir exists
action: file path=/home/git/gitlab/tmp/pids state=directory
- name: Make sure that public/uploads dir exists
action: file path=/home/git/gitlab/public/uploads state=directory
- name: ensure copy of unicorn config exists
command: cp /home/git/gitlab/config/unicorn.rb.example /home/git/gitlab/config/unicorn.rb creates=/home/git/gitlab/config/unicorn.rb
- hosts: gitlab
sudo: yes
tasks:
- name: ensure gem charlock_holmes is installed
command: gem install charlock_holmes --version '0.6.9.4' creates=/usr/local/lib/ruby/gems/2.0.0/gems/charlock_holmes-0.6.9.4
- hosts: gitlab
sudo: yes
sudo_user: git
vars_files:
- vars.yml
tasks:
- name: ensure GitLab bundle is installed
command: bundle install --deployment --without development test postgres aws chdir=/home/git/gitlab
- hosts: gitlab
sudo: yes
sudo_user: git
tasks:
- shell: yes 'yes' | bundle exec rake gitlab:setup RAILS_ENV=production chdir=/home/git/gitlab
- hosts: gitlab
sudo: yes
tasks:
- name: get init script
fetch: src=/home/git/gitlab/lib/support/init.d/gitlab dest=/tmp/gitlab.init.d flat=yes
- name: ensure init script is installed
copy: src=/tmp/gitlab.init.d dest=/etc/init.d/gitlab mode=0755
- name: make GitLab start on boot
command: update-rc.d gitlab defaults 21
- name: restart GitLab
service: name=gitlab state=restarted
# 7. Nginx
- hosts: gitlab
sudo: yes
vars_files:
- vars.yml
tasks:
- name: ensure package nginx is present
apt: state=present pkg=nginx
- name: ensure GitLab Nginx site is available
action: template src=templates/nginx.conf.tmpl dest=/etc/nginx/sites-available/gitlab mode=0755
- name: ensure default Nginx site is not enabled
file: state=absent path=/etc/nginx/sites-enabled/default
- name: ensure GitLab Nginx site is enabled
file: state=link src=/etc/nginx/sites-available/gitlab path=/etc/nginx/sites-enabled/gitlab
- hosts: gitlab
sudo: yes
tasks:
- name: restart Nginx
service: name=nginx state=restarted