19
0
Fork 0

relecture en cours

This commit is contained in:
gcolpart 2016-12-02 12:03:18 +01:00
parent 62d3e2b550
commit 9e9e72e23f
1 changed files with 117 additions and 83 deletions

View File

@ -139,7 +139,7 @@ Puis :
# systemctl daemon-reload
~~~
Créer une configuration spéciale pour l'instance :
Configuration spéciale pour l'instance :
~~~
# cat /etc/redis/gitlab-demo00.conf
@ -196,10 +196,18 @@ Mettre le mot de passe PostgreSQL :
~~~
$ cp config/secrets.yml.example config/secrets.yml
$ sed -i "s@^# db_key_base:@db_key_base: PASSWORD@" config/secrets.yml
$ sed -i "s@^# db_key_base:@db_key_base: PASSWORD@" config/secrets.yml
$ chmod 600 config/secrets.yml
$ cp config/database.yml.postgresql config/database.yml
$ sed -i -e 's/database: gitlabhq_production/database: foo/' \
-e 's/# username: git/username: foo/' \
-e 's/# password:/password: PASSWORD/' config/database.yml
$ chmod o-rwx config/database.yml
~~~
> **Note** : Conservez l'espace devant le sed pour ne pas enregistrer le mot de passe dans l'historique bash.
Ajuster les droits de certains répertoires :
~~~
@ -214,7 +222,7 @@ $ chmod -R u+rwX shared/artifacts/
## Unicorn
On initialise la configuration d'Unicorn :
Configuration de base d'Unicorn :
~~~
$ cp config/unicorn.rb.example config/unicorn.rb
@ -226,116 +234,116 @@ $ sed -i -e \
## Rack attack
On initialise la configuration de Rack::Attack (qui permet du filtrage / rate-limiting) :
Initialisation de la configuration de Rack::Attack (qui permet du filtrage / rate-limiting) :
~~~
$ cp config/initializers/rack_attack.rb{.example,}
$ cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
~~~
### Configuration de GIT
```
### Git
Configuration :
~~~
$ git config --global core.autocrlf input
$ git config --global gc.auto 0
$ git config --global repack.writeBitmaps true
```
### Configuration de Resque/Redis
```
$ cp config/resque.yml{.example,}
~~~
## Resque
Configuration :
~~~
$ cp config/resque.yml.example config/resque.yml
$ sed -i 's/redis.sock/gitlab-demo00.sock/' config/resque.yml
```
~~~
### Configuration des paramètres de connexion à la base
## Gems
```
$ cp config/database.yml{.postgresql,}
$ sed -i -e 's/database: gitlabhq_production/database: gitlab-demo00/' \
-e 's/# username: git/username: gitlab-demo00/' \
-e 's/# password:/password: VotreMDP/' config/database.yml
$ chmod o-rwx config/database.yml
```
> **Note** : Conservez l'espace devant le sed pour ne pas enregistrer le mot de passe dans l'historique bash.
> **Important**: Votre partition `/home` ne doit pas être montée avec l'option `noexec`.
### Installation des Gems
On installe quelques Gems :
> **Important**: Votre `/home` ne doit pas être monté avec l'option `noexec`.
```
~~~
$ umask 002
$ bundle install -j$(nproc) --deployment --without development test mysql aws kerberos
```
~~~
### Installation de GitLab Shell
## GitLab Shell
```
$ bundle exec rake gitlab:shell:install REDIS_URL=unix:/var/run/redis/gitlab-demo00.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
Installation :
~~~
$ umask 002
$ bundle exec rake gitlab:shell:install REDIS_URL=unix:/var/run/redis/foo.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
$ chmod -R ug+rwX,o-rwx ~/repositories/
$ chmod -R ug-s ~/repositories/
$ chmod g+s ~/repositories/
```
~~~
### Install gitlab-workhorse
## gitlab-workhorse
```
Installation :
~~~
$ umask 002
$ cd
$ git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
$ cd gitlab-workhorse
$ git checkout v$(cat ~/gitlab/GITLAB_WORKHORSE_VERSION)
$ make
```
~~~
### Création de la BDD
```
~~~
$ cd ~/gitlab
$ bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword GITLAB_ROOT_EMAIL=youremail
```
~~~
> **Note :** `GITLAB_ROOT_PASSWORD` concerne le mot de passe de l'utilisateur admin nommé root sur l'interface web de GitLab et `GITLAB_ROOT_EMAIL` le mail associé. Conservez un espace avant la commande pour qu'elle ne se retrouve pas dans l'historique bash.
### Sauvegarder secrets.yml
Le fichier `secrets.yml` contient les clés de chiffrements pour les sessions et les variables. On pourra le copier dans `/root` par exemple, à vous de choisir l'endroit approprié.
```
# install -m 600 -o root -g root /home/gitlab-demo00/gitlab/config/secrets.yml /root/gitlab-demo00.secrets.yml
```
## Script d'init
### Mise en place d'un script d'init
Attention, GitLab ne supporte pas officiellement systemd !
GitLab ne supporte pas officiellement systemd… On doit donc encore passer pas un script d'init classique.
On doit donc encore passer pas un script d'init classique :
```
# sed -i -e \
's/app_user="git"/app_user="gitlab-demo00"/' \
-e 's/# Provides: .*gitlab/# Provides: gitlab-demo00/' \
/home/gitlab-demo00/gitlab/lib/support/init.d/gitlab
# install -m 755 /home/gitlab-demo00/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab-demo00
# systemctl enable gitlab-demo00
# sed -i 's#script_path = "/etc/init.d/gitlab"#script_path = "/etc/init.d/gitlab-demo00"#g' /home/gitlab-demo00/gitlab/lib/tasks/gitlab/check.rake
~~~
# sudo -iu gitlab-demo00
$ cd gitlab
$ sed -i -e 's/app_user="git"/app_user="foo"/' \
-e 's/# Provides: .*gitlab/# Provides: foo/' \
lib/support/init.d/gitlab
$ sed -i 's@script_path = "/etc/init.d/gitlab"@script_path = "/etc/init.d/gitlab-foo"@g' lib/tasks/gitlab/check.rake
$ git commit -a -m 'change default user'
```
### Logrotate
# install -m 755 /home/foo/gitlab/lib/support/init.d/gitlab /etc/init.d/gitlab-foo
# systemctl enable gitlab-foo
~~~
```
# install -m 644 /home/gitlab-demo00/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/gitlab-demo00
# sed -i 's#/home/git/#/home/gitlab-demo00/#g' /etc/logrotate.d/gitlab-demo00
```
## Logrotate
~~~
# install -m 644 /home/gitlab-demo00/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/gitlab-foo
# sed -i 's@/home/git@/home/foo@g' /etc/logrotate.d/gitlab-foo
~~~
### Vérifier l'état de l'installation
```
~~~
# sudo -iu gitlab-demo00
$ cd gitlab
$ bundle exec rake gitlab:env:info RAILS_ENV=production
```
~~~
### Compiler les Assets
```
~~~
$ bundle exec rake assets:precompile RAILS_ENV=production
```
~~~
### Démarrer l'instance
@ -437,65 +445,83 @@ Si tout est au vert, la migration s'est bien passé !
### Backup
```
# sudo -iu gitlab-demo00
$ cd gitlab
~~~
# sudo -iu foo
$ cd #gitlab
$ bundle exec rake gitlab:backup:create RAILS_ENV=production
```
~~~
Cela va créer une archive TAR dans `~/gitlab/tmp/backups/`.
### Mise à jour de GitLab
```
~~~
# sudo -iu foo
$ umask 002
$ cd gitlab
$ git fetch --all
$ git checkout -- Gemfile.lock db/schema.rb
$ git checkout v8.14.2 -b v8.14.2
$ sed -i -e s'/app_user="git"/app_user="gitlab-demo00"/' \
-e 's/# Provides: .*gitlab$/# Provides: gitlab-demo00/' \
$ sed -i -e s'/app_user="git"/app_user="foo"/' \
-e 's/# Provides: .*gitlab$/# Provides: foo/' \
lib/support/init.d/gitlab
$ sed -i 's#script_path = "/etc/init.d/gitlab"#script_path = "/etc/init.d/gitlab-demo00"#g' lib/tasks/gitlab/check.rake
$ sed -i 's@script_path = "/etc/init.d/gitlab"@script_path = "/etc/init.d/foo"@g' lib/tasks/gitlab/check.rake
$ git commit -a -m 'change default user'
```
~~~
### Mise à jour de gitlab-workhorse
```
~~~
$ cd ~/gitlab-workhorse
$ git fetch
$ git checkout v$(cat ~/gitlab/GITLAB_WORKHORSE_VERSION) -b v$(cat ~/gitlab/GITLAB_WORKHORSE_VERSION)
$ make
```
~~~
### Mise à jour BDD, gems et assets
```
~~~
$ cd ~/gitlab
$ bundle install --without development test mysql aws kerberos --deployment
$ bundle clean
$ bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
$ git commit -a -m 'upgraded to 8.14.2'
```
~~~
### Redémarrer GitLab
```
# /etc/init.d/gitlab-demo00 restart
```
~~~
# /etc/init.d/gitlab-foo restart
Shutting down GitLab Unicorn
Shutting down GitLab Sidekiq
Shutting down GitLab Workhorse
.
GitLab is not running.
Starting GitLab Unicorn
Starting GitLab Sidekiq
Starting GitLab Workhorse
The GitLab Unicorn web server with pid 8120 is running.
The GitLab Sidekiq job dispatcher with pid 8221 is running.
The GitLab Workhorse with pid 8202 is running.
GitLab and all its components are up and running.
~~~
### Vérifier le status
```
# sudo -iu gitlab-demo00
~~
# sudo -iu foo
$ cd gitlab
$ bundle exec rake gitlab:env:info RAILS_ENV=production
$ bundle exec rake gitlab:check RAILS_ENV=production
```
~~~
Si tout est au vert, la migration s'est bien passé !
Si tout est au vert, la migration s'est bien passée !
## Majeure
En attente nouvelle release majeure.
En attente d'une nouvelle release majeure :)
# Création d'une autre instance
@ -519,4 +545,12 @@ Dans `~/gitlab/config/gitlab.yml` on pourra indiquer un temps de rétention. Par
keep_time: 432000
```
> **Note** : Par défaut, les backups sont dans ~/gitlab/tmp/backups. Il est conseillé de les sauvegarder ailleurs et sur une machine distante.
> **Note** : Par défaut, les backups sont dans ~/gitlab/tmp/backups. Il est conseillé de les sauvegarder ailleurs et sur une machine distante.
### Sauvegarder secrets.yml
Le fichier `secrets.yml` contient les clés de chiffrements pour les sessions et les variables. On pourra le copier dans `/root` par exemple, à vous de choisir l'endroit approprié.
```
# install -m 600 -o root -g root /home/gitlab-demo00/gitlab/config/secrets.yml /root/gitlab-demo00.secrets.yml
```