ansible-nas/roles/gitlab/tasks/main.yml
Anarion 4960286632
First portion of migration
freshrss, get_iplayer, gitlab, glances, gotify, guacamole, healthchecks.io
2023-03-08 21:47:39 +01:00

69 lines
2.3 KiB
YAML

---
- name: Start Gitlab
block:
# The gitlab uid/gid matches 'git:git' in the Gitlab Docker image.
- name: Create Gitlab group account
group:
name: gitlab
gid: 998
state: present
- name: Create Gitlab user account
user:
name: gitlab
uid: 998
state: present
system: yes
update_password: on_create
create_home: no
group: gitlab
- name: Create Gitlab Directories
file:
path: "{{ item }}"
state: directory
owner: gitlab
group: gitlab
with_items:
- "{{ gitlab_data_directory }}/config"
- "{{ gitlab_data_directory }}/log"
- "{{ gitlab_data_directory }}/data"
- name: Create Gitlab Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ gitlab_container_name }}"
image: "{{ gitlab_image_name }}:{{ gitlab_image_version }}"
pull: true
volumes:
- "{{ gitlab_data_directory }}/config:/etc/gitlab:rw"
- "{{ gitlab_data_directory }}/log:/var/log/gitlab:rw"
- "{{ gitlab_data_directory }}/data:/var/opt/gitlab:rw"
network_mode: "bridge"
ports:
- "{{ gitlab_port_http }}:80"
- "{{ gitlab_port_https }}:443"
- "{{ gitlab_port_ssh }}:22"
env:
TZ: "{{ ansible_nas_timezone }}"
PUID: "{{ gitlab_user_id }}"
PGID: "{{ gitlab_group_id }}"
restart_policy: unless-stopped
hostname: "{{ gitlab_hostname }}.{{ ansible_nas_domain }}"
memory: "{{ gitlab_memory }}"
labels:
traefik.enable: "{{ gitlab_available_externally | string }}"
traefik.http.routers.gitlab.rule: "Host(`{{ gitlab_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.gitlab.tls.certresolver: "letsencrypt"
traefik.http.routers.gitlab.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.gitlab.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.gitlab.loadbalancer.server.port: "80"
when: gitlab_enabled is true
- name: Stop Gitlab
block:
- name: Stop Gitlab
community.docker.docker_container:
name: "{{ gitlab_container_name }}"
state: absent
when: gitlab_enabled is false