Skip to content

Instantly share code, notes, and snippets.

@dynax60
Last active October 25, 2021 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dynax60/44ad62a6f906eae6de64be9b7d4ca1ed to your computer and use it in GitHub Desktop.
Save dynax60/44ad62a6f906eae6de64be9b7d4ca1ed to your computer and use it in GitHub Desktop.
Ansible playbook for installing Gitlab

Remove exited containers

docker ps -a -q -f status=exited | xargs --no-run-if-empty docker rm -v

Remove dangling images

docker images -f "dangling=true" -q | xargs --no-run-if-empty docker rmi

Remove unused images (warning!)

docker images | awk '/ago/ { print $3}' | xargs --no-run-if-empty docker rmi

Remove dangling volumes

docker volume ls -qf dangling=true | xargs --no-run-if-empty docker volume rm

Shrink contrainer log file

truncate -s 0 $(docker inspect --format='{{.LogPath}}' gitlab)

#!/usr/bin/env ansible-playbook
---
- hosts: gitlab
gather_facts: no
become: yes
tasks:
- name: create directory /opt/gitlab/config/ssl
file:
path: /opt/gitlab/config/ssl
state: directory
mode: 0755
owner: root
group: root
tags:
- gitlab
- name: add ssl public key for domain.tld
copy:
src: bundle.crt
dest: /opt/gitlab/config/ssl/gitlab.domain.tld.crt
mode: 0644
tags:
- gitlab
- name: add ssl private key for domain.tld
copy:
src: private.key
dest: /opt/gitlab/config/ssl/gitlab.domain.tld.key
mode: 0644
tags:
- gitlab
- name: Create network gitlab
docker_network: name=gitlab
tags:
- gitlab
- gitlab-runner
- name: Run gitlab container
docker_container:
name: gitlab
image: gitlab/gitlab-ce:latest
recreate: true
restart_policy: unless-stopped
hostname: gitlab.domain.tld
published_ports:
- "80:80"
- "443:443"
- "22:22"
volumes:
- "/opt/gitlab/config:/etc/gitlab"
- "/opt/gitlab/logs:/var/log/gitlab"
- "/opt/gitlab/data:/var/opt/gitlab"
network_mode: gitlab
env:
GITLAB_OMNIBUS_CONFIG: |
external_url "https://gitlab.domain.tld"
letsencrypt['enable'] = false
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.domain.tld.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.domain.tld.key"
registry_external_url 'https://registry.domain.tld'
registry_nginx['redirect_http_to_https'] = true
registry_nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.domain.tld.crt"
registry_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.domain.tld.key"
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "mail.domain.tld"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_domain'] = "domain.tld"
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = "none"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_ssl'] = false
gitlab_rails['smtp_force_ssl'] = false
tags:
- gitlab
- name: Run gitlab-runner container
docker_container:
name: gitlab-runner
image: gitlab/gitlab-runner:latest
recreate: true
restart_policy: unless-stopped
volumes:
- "/opt/gitlab-runner/config:/etc/gitlab-runner"
- "/var/run/docker.sock:/var/run/docker.sock"
network_mode: gitlab
tags:
- gitlab-runner

Gitlab Notes

The latest versions here

Gitlab Releases

Another method to see gitlab latest versions

wget -q https://registry.hub.docker.com/v1/repositories/gitlab/gitlab-ce/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | egrep '^14.4'

wget -q https://registry.hub.docker.com/v1/repositories/gitlab/gitlab-runner/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep ^v14.4

URLs

GitLab Docker images

Create a GitLab upgrade plan

UPDATE: Installation using Docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment