diff --git a/.vscode/settings.json b/.vscode/settings.json index b7a69a1..0d50b4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -214,6 +214,7 @@ "psql", "pstate", "pulumi", + "pulumiverse", "pvresize", "radeon", "replicatedctl", diff --git a/knowledge base/gitlab.md b/knowledge base/gitlab.md index de8ef1f..75bcb60 100644 --- a/knowledge base/gitlab.md +++ b/knowledge base/gitlab.md @@ -1,6 +1,7 @@ # Gitlab -1. [Omnibus](#omnibus) +1. [TL;DR](#tldr) +1. [Package](#package) 1. [Kubernetes](#kubernetes) 1. [Helm chart](#helm-chart) 1. [Operator](#operator) @@ -20,23 +21,51 @@ 1. [Further readings](#further-readings) 1. [Sources](#sources) -## Omnibus +## TL;DR + +```sh +# List the current application settings of the GitLab instance. +curl --header 'PRIVATE-TOKEN: glpat-m-…' 'https://gitlab.fqdn/api/v4/application/settings' +curl --header 'Authorization: bearer glpat-m-…' 'https://gitlab.fqdn/api/v4/application/settings' +``` + +## Package + +Previously known as 'Omnibus'.
Installation Refer [Install self-managed GitLab]. +```sh +sudo dnf install 'gitlab-ee' +sudo EXTERNAL_URL='http://gitlab.example.com' GITLAB_ROOT_PASSWORD='smthng_Strong_0r_it_llfail' apt install 'gitlab-ee' +``` +
Configuration -[Template][omnibus configuration template] +[Template][package configuration file template] The application of configuration changes is handled by [Chef Infra].
It runs checks, ensures directories, permissions, and services are in place and working, and restarts components if any of their configuration files have changed. +```sh +# Change application settings. +# Useful to reach those ones not available in the configuration file. +sudo gitlab-rails runner ' + ::Gitlab::CurrentSettings.update!(gravatar_enabled: false); + ::Gitlab::CurrentSettings.update!(remember_me_enabled: false); + ::Gitlab::CurrentSettings.update!(email_confirmation_setting: "hard"); +' + +# Disable public registration. +sudo gitlab-rails runner '::Gitlab::CurrentSettings.update!(signup_enabled: false)' +``` + ```sh # Validate. # Just makes sure the file is readable from a ruby app. @@ -78,9 +107,10 @@ gitlab_rails['backup_multipart_chunk_size'] = 104857600 gitlab_rails['backup_keep_time'] = 604800 ``` -Omnibus' installation procedure generates keys and a certificate for the external URL even when LetsEncrypt's support is -explicitly disabled.
-These keys are in the OpenSSH format and are password protected. +The package's included nginx generates keys and a **self-signed** certificate for the external URL upon start if the +given URL's schema is HTTPS.
+The Let's Encrypt account key is in OpenSSL format, while the certificate's key is in OpenSSH format. Both are **not** +password protected.
@@ -91,6 +121,14 @@ These keys are in the OpenSSH format and are password protected. # Check the components' state. sudo gitlab-ctl status +# Get the services' logs. +sudo gitlab-ctl tail +sudo gitlab-ctl tail 'nginx' + +# Restart services. +sudo gitlab-ctl restart +sudo gitlab-ctl restart 'nginx' + # Create backups. sudo gitlab-backup create BACKUP='prefix_override' STRATEGY='copy' @@ -99,9 +137,51 @@ sudo gitlab-backup create BACKUP='prefix_override' STRATEGY='copy' sudo gitlab-backup create … \ SKIP='db,repositories,uploads,builds,artifacts,pages,lfs,terraform_state,registry,packages,ci_secure_files' -# Package upgrade. +# Restore backups. +sudo gitlab-ctl stop 'puma' \ +&& sudo gitlab-ctl stop 'sidekiq' + +# Upgrade the package. sudo yum check-update -tmux new-session -A -s 'gitlab-upgrade' "sudo yum update 'gitlab-ee'" +tmux new-session -As 'gitlab-upgrade' "sudo yum update 'gitlab-ee'" + +# Reset the root user's password. +sudo gitlab-rake 'gitlab:password:reset[root]' +sudo gitlab-rails console \ + # --> user = User.find_by_username 'root' + # --> user.password = 'QwerTy184' + # --> user.password_confirmation = 'QwerTy184' + # --> user.password_automatically_set = false + # --> user.save! + # --> quit +sudo gitlab-rails runner ' + user = User.find_by_username "anUsernameHere"; + new_password = "QwerTy184"; + user.password = new_password; + user.password_confirmation = new_password; + user.password_automatically_set = false; + user.save! +' + +# Disable users' two factor authentication. +sudo gitlab-rails runner 'User.where(username: "anUsernameHere").each(&:disable_two_factor!)' +``` + + + +
+ Removal + +```sh +# Remove all users and groups created by the package. +sudo gitlab-ctl stop && sudo gitlab-ctl remove-accounts + +# Remove all data. +sudo gitlab-ctl cleanse && sudo rm -r '/opt/gitlab' + +# Uninstall the package. +sudo apt remove 'gitlab-ee' +sudo dnf remove 'gitlab-ee' ```
@@ -576,7 +656,13 @@ Solution: give that user _developer_ access or have somebody else with enough pr - [Use kaniko to build Docker images] - [Specify when jobs run with `rules`][specify when jobs run with rules] - [Install self-managed GitLab] -- [Omnibus configuration template] +- [Package configuration file template] +- [Install GitLab with the Linux package] +- [Reset a user's password] +- [Environment variables] +- [Sign-up restrictions] +- [Restore GitLab] +- [How to disable the Two-factor authentication in GitLab?] user = User.find_by_username 'root' + # --> user.password = 'QwerTy184' + # --> user.password_confirmation = 'QwerTy184' + # --> user.password_automatically_set = false + # --> user.save! + # --> quit +sudo gitlab-rails runner ' + user = User.find_by_username "anUsernameHere"; + new_password = "QwerTy184"; + user.password = new_password; + user.password_confirmation = new_password; + user.password_automatically_set = false; + user.save! +' + +# Disable users' two factor authentication. +sudo gitlab-rails runner 'User.where(username: "anUsernameHere").each(&:disable_two_factor!)' +sudo gitlab-rails runner 'User.update_all(otp_required_for_login: false, encrypted_otp_secret: nil)' + +## Maintenance - end ----------------- # + +## +# Restore backups - start +# -------------------------------------- +# Version *and* edition of the installed version must be the exact same of the +# ones from the backup. +## + +sudo aws s3 cp 's3://backups/gitlab/gitlab-secrets.json' '/etc/gitlab/gitlab-secrets.json' +sudo aws s3 cp 's3://backups/gitlab/gitlab.rb' '/etc/gitlab/gitlab.rb' +sudo aws s3 cp \ + 's3://backups/gitlab/11493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar' \ + '/var/opt/gitlab/backups/' +sudo gitlab-ctl stop 'puma' +sudo gitlab-ctl stop 'sidekiq' +sudo gitlab-backup restore BACKUP='11493107454_2018_04_25_10.6.4-ce' +sudo gitlab-ctl start + +## Restore backups - end ------------- # + +## +# Removal - start +## + +sudo gitlab-ctl stop +sudo gitlab-ctl remove-accounts +sudo gitlab-ctl cleanse +sudo rm -rf '/etc/gitlab' '/opt/gitlab' +sudo dnf -y remove --noautoremove 'gitlab-ee' + +## Removal - end --------------------- # diff --git a/snippets/gitlab.omnibus.upgrade.sh b/snippets/gitlab.omnibus.upgrade.sh deleted file mode 100644 index 6b3615d..0000000 --- a/snippets/gitlab.omnibus.upgrade.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!sh - -sudo yum check-update -sudo yum info 'gitlab-ee' -sudo rpm -qa | grep 'gitlab-ee' -tmux new-session -A -s 'gitlab-upgrade' "sudo yum update 'gitlab-ee'"