diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..6530dd1 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,18 @@ + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.box = "centos/7" + + config.vm.box_url = "centos/7" + + config.vm.network "private_network", ip: "10.0.3.17" + + config.vm.provision "shell", keep_color: true, path: 'provision.sh' + + #config.vm.network :forwarded_port, guest: 8080, host: 8080 # Gitlab + config.vm.network :forwarded_port, guest: 8081, host: 8081 # Nginx + +end diff --git a/provision.sh b/provision.sh new file mode 100755 index 0000000..42a9302 --- /dev/null +++ b/provision.sh @@ -0,0 +1,131 @@ +#!/bin/bash + +set -x + +# Disable SELINUX (for now) +sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config +setenforce 0 + +yum -y install epel-release +yum -y install wget postgresql-server nginx + +wget -P /etc/yum.repos.d/ https://copr.fedorainfracloud.org/coprs/softwarepublico/v4/repo/epel-7/softwarepublico-v4-epel-7.repo + +yum -y install gitlab + +############################################ +# Coisas estranhas: +# +# Installing : gitlab-shell-2.4.0-5.1.noarch +# id: git: no such user +# mkdir -p /var/lib/gitlab-shell/repositories/: OK +# mkdir -p /var/lib/gitlab-shell/.ssh: OK +# chmod 700 /var/lib/gitlab-shell/.ssh: OK +# touch /var/lib/gitlab-shell/.ssh/authorized_keys: OK +# chmod 600 /var/lib/gitlab-shell/.ssh/authorized_keys: OK +# chmod -R ug+rwX,o-rwx /var/lib/gitlab-shell/repositories/: OK +# find /var/lib/gitlab-shell/repositories/ -type d -exec chmod g+s {} ;: OK +# +# +# +# Installing : gitlab-7.6.2-13.2.noarch +# chown: cannot access ‘/var/lib/gitlab-assets’: No such file or directory +# Redirecting to /bin/systemctl start redis.service +# rake aborted! +# Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret +# +# Tasks: TOP => db:migrate:status => environment +# (See full trace by running task with --trace) +# rake aborted! +# Errno::EACCES: Permission denied - /usr/lib/gitlab/.gitlab_shell_secret +# +# Tasks: TOP => gitlab:setup => environment +# (See full trace by running task with --trace) +# I, [2016-04-25T22:50:47.389656 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_32-7d94ec26bfa902d9573dac174421752a.png +# I, [2016-04-25T22:50:47.391563 #11843] INFO -- : Writing /usr/lib/gitlab/public/assets/authbuttons/github_64-cfef80f36a1826b9c90eeb38534dbd18.png +# +# +# +############################################ + + +postgresql-setup initdb + +#TODO: edit /var/lib/pgsql/data/pg_hba.conf ? + +systemctl enable postgresql redis +systemctl start postgresql redis +sudo -u postgres createuser git +#sudo -u postgres createdb --owner=git gitlabhq_production +cd /usr/lib/gitlab +sudo -u git bundle exec rake db:setup RAILS_ENV=production && touch /var/lib/gitlab/setup.done + +sed -i 's,http://localhost:8080/,http://localhost:8080/gitlab,' /etc/gitlab-shell/config.yml + +echo 'production: redis://localhost:6379' > /usr/lib/gitlab/config/resque.yml +sed -i 's,localhost,localhost\n relative_url_root: /gitlab,' /etc/gitlab/gitlab.yml + +cat << EOF > /usr/lib/gitlab/config/initializers/gitlab_shell_secret_token.rb +Gitlab::Application.configure do + config.relative_url_root = "/gitlab" +end +EOF + +cat << EOF > /etc/nginx/conf.d/gitlab.conf +upstream gitlab { + server 0.0.0.0:8080 fail_timeout=10s; +} + +server { + listen *:8081; + server_name localhost:8081; + underscores_in_headers on; + access_log /var/log/nginx/gitlab.access.log; + error_log /var/log/nginx/gitlab.error.log; + client_max_body_size 20m; + + location /gitlab/assets/ { + alias /usr/lib/gitlab/public/assets/; + } + + location /gitlab/uploads/ { + alias /usr/lib/gitlab/public/uploads/; + } + + location / { + proxy_pass http://gitlab; + proxy_read_timeout 90; + proxy_connect_timeout 90; + proxy_redirect off; + proxy_set_header Host localhost:8081; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + } +} +EOF + +systemctl enable nginx +systemctl restart nginx + + +sed -i 's/# ENV/ENV/' /etc/gitlab/unicorn.rb + +sed -i 's/# config.relative_url_root/config.relative_url_root/' /usr/lib/gitlab/config/application.rb + +chown -R git:git /usr/lib/gitlab/tmp/cache +chown -R git:git /usr/lib/gitlab/public/assets +chown -R git:git /var/lib/gitlab-assets + +cd /usr/lib/gitlab && +sudo -u git bundle exec rake assets:precompile RAILS_ENV=production + +systemctl enable gitlab +systemctl start gitlab + + + +# bootstrap / provision + +#sudo su - vagrant + + -- libgit2 0.21.2