mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-24 05:31:04 +01:00
implemented draf for gitlab role
This commit is contained in:
parent
8ae612444c
commit
69ef04bf0c
@ -104,6 +104,7 @@ domain_elk: "elk.{{top_domain}}"
|
||||
domain_discourse: "forum.{{top_domain}}"
|
||||
domain_funkwhale: "music.{{top_domain}}"
|
||||
domain_gitea: "git.{{top_domain}}"
|
||||
domain_gitlab: "gitlab.{{top_domain}}"
|
||||
domain_listmonk: "newsletter.{{top_domain}}"
|
||||
domain_mailu: "mail.{{top_domain}}"
|
||||
domain_mastodon: "microblog.{{top_domain}}"
|
||||
@ -121,6 +122,9 @@ domain_attendize: "tickets.{{top_domain}}"
|
||||
domain_yourls: "s.{{top_domain}}"
|
||||
domain_openproject: "project.{{top_domain}}"
|
||||
|
||||
### Common Configurations
|
||||
postgres_default_version: "16"
|
||||
|
||||
### Docker Role Specific Parameters
|
||||
|
||||
#### Pixelfed
|
||||
|
35
roles/docker-gitlab/README.md
Normal file
35
roles/docker-gitlab/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Docker-GitLab Ansible Role README.md
|
||||
|
||||
## Overview
|
||||
This Ansible role is designed for setting up and managing a GitLab server running in a Docker container. It automates the process of installing GitLab, configuring its environment, and managing dependencies such as a PostgreSQL database and an Nginx reverse proxy.
|
||||
|
||||
## Features
|
||||
- **GitLab Installation**: Automatically deploys GitLab using Docker.
|
||||
- **External PostgreSQL Database**: Configures GitLab to use an external PostgreSQL database.
|
||||
- **Nginx Reverse Proxy Integration**: Includes tasks for setting up an Nginx reverse proxy for GitLab.
|
||||
- **Customizable Configuration**: Variables and templates allow for easy customization.
|
||||
|
||||
## Requirements
|
||||
- Docker and Docker Compose installed on the target machine.
|
||||
- Ansible for automation.
|
||||
|
||||
## Role Variables
|
||||
Variables are defined in `vars/main.yml`. Key variables include:
|
||||
- `docker_compose_instance_directory`: Directory for Docker Compose instances.
|
||||
- `database_instance`, `database_host`, `database_databasename`, `database_username`, `database_password`: Database configuration variables.
|
||||
- `database_version`: PostgreSQL version, with a default fallback.
|
||||
|
||||
## Handlers
|
||||
- `recreate gitlab`: Restarts GitLab using Docker Compose when changes are detected.
|
||||
|
||||
## Dependencies
|
||||
- `nginx-docker-reverse-proxy`: A role for setting up an Nginx reverse proxy for GitLab.
|
||||
|
||||
## Template Files
|
||||
- `docker-compose.yml.j2`: Jinja2 template for the Docker Compose configuration.
|
||||
- Additional templates for database and proxy configuration.
|
||||
|
||||
## Usage
|
||||
Include this role in your Ansible playbooks and specify the necessary variables. Run the playbook to deploy and configure GitLab in a Docker environment.
|
||||
|
||||
For a detailed walkthrough and explanation of this role, refer to the conversation at [ChatGPT Session Transcript](https://chat.openai.com/share/1b0147bf-d4de-4790-b8ed-c332aa4e3ce3).
|
8
roles/docker-gitlab/handlers/main.yml
Normal file
8
roles/docker-gitlab/handlers/main.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: recreate gitlab
|
||||
command:
|
||||
cmd: docker-compose -p gitlab up -d --force-recreate
|
||||
chdir: "{{docker_compose_instance_directory}}"
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
2
roles/docker-gitlab/meta/main.yml
Normal file
2
roles/docker-gitlab/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- nginx-docker-reverse-proxy
|
13
roles/docker-gitlab/tasks/main.yml
Normal file
13
roles/docker-gitlab/tasks/main.yml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: "include tasks nginx-docker-proxy-domain.yml"
|
||||
include_tasks: nginx-docker-proxy-domain.yml
|
||||
|
||||
- name: "create {{docker_compose_instance_directory}}"
|
||||
file:
|
||||
path: "{{docker_compose_instance_directory}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: add docker-compose.yml
|
||||
template: src=docker-compose.yml.j2 dest={{docker_compose_instance_directory}}docker-compose.yml
|
||||
notify: recreate gitlab
|
32
roles/docker-gitlab/templates/docker-compose.yml.j2
Normal file
32
roles/docker-gitlab/templates/docker-compose.yml.j2
Normal file
@ -0,0 +1,32 @@
|
||||
version: '3.6'
|
||||
services:
|
||||
web:
|
||||
image: 'gitlab/gitlab-ee:latest'
|
||||
restart: always
|
||||
hostname: '{{domain}}'
|
||||
environment:
|
||||
GITLAB_OMNIBUS_CONFIG: |
|
||||
external_url 'https://{{domain}}'
|
||||
postgresql['enable'] = false
|
||||
gitlab_rails['gitlab_shell_ssh_port'] = {{ssh_port}}
|
||||
gitlab_rails['db_adapter'] = 'postgresql'
|
||||
gitlab_rails['db_encoding'] = 'utf8'
|
||||
gitlab_rails['db_host'] = '{{database_host}}'
|
||||
gitlab_rails['db_port'] = 5432
|
||||
gitlab_rails['db_username'] = '{{database_username}}'
|
||||
gitlab_rails['db_password'] = '{{database_password}}'
|
||||
ports:
|
||||
- '8929:8929'
|
||||
ports:
|
||||
- "127.0.0.1:{{http_port}}:80"
|
||||
- "{{ssh_port}}:22"
|
||||
volumes:
|
||||
- 'config:/etc/gitlab'
|
||||
- 'logs:/var/log/gitlab'
|
||||
- 'data:/var/opt/gitlab'
|
||||
shm_size: '256m'
|
||||
|
||||
{% include 'templates/docker-postgres-service.yml.j2' %}
|
||||
|
||||
volumes:
|
||||
database:
|
7
roles/docker-gitlab/vars/main.yml
Normal file
7
roles/docker-gitlab/vars/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
docker_compose_instance_directory: "{{path_docker_compose_instances}}gitlab/"
|
||||
database_instance: "gitlab"
|
||||
database_host: "database"
|
||||
database_databasename: "gitlabhq_production"
|
||||
database_username: "gitlab"
|
||||
database_password: "{{gitlab_database_password}}"
|
||||
database_version: "{{ gitlab_database_version | default(postgres_default_version) }}"
|
@ -1,24 +1,8 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
database:
|
||||
image: postgres:13-alpine
|
||||
ports:
|
||||
- "9432:5432"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD={{database_password}}
|
||||
- POSTGRES_USER={{database_username}}
|
||||
- POSTGRES_DB={{database_databasename}}
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U {{database_username}}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
volumes:
|
||||
- type: volume
|
||||
source: database
|
||||
target: /var/lib/postgresql/data
|
||||
|
||||
{% include 'templates/docker-postgres-service.yml.j2' %}
|
||||
|
||||
application:
|
||||
restart: unless-stopped
|
||||
|
@ -4,3 +4,4 @@ database_host: "database"
|
||||
database_databasename: "{{database_instance}}"
|
||||
database_username: "{{database_instance}}"
|
||||
database_password: "{{listmonk_database_password}}"
|
||||
database_version: "{{ listmonk_database_version | default(postgres_default_version) }}"
|
10
servers.yml
10
servers.yml
@ -229,6 +229,16 @@
|
||||
domain: "{{domain_openproject}}"
|
||||
http_port: 8023
|
||||
|
||||
- name: setup gitlab hosts
|
||||
hosts: gitlab
|
||||
become: true
|
||||
roles:
|
||||
- role: docker-gitlab
|
||||
vars:
|
||||
domain: "{{domain_gitlab}}"
|
||||
http_port: 8024
|
||||
ssh_port: 2202
|
||||
|
||||
- name: setup akaunting hosts
|
||||
hosts: akaunting
|
||||
become: true
|
||||
|
19
templates/docker-postgres-service.yml.j2
Normal file
19
templates/docker-postgres-service.yml.j2
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
database:
|
||||
image: postgres:{{database_version}}-alpine
|
||||
ports:
|
||||
- "9432:5432"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD={{database_password}}
|
||||
- POSTGRES_USER={{database_username}}
|
||||
- POSTGRES_DB={{database_databasename}}
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U {{database_username}}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
volumes:
|
||||
- type: volume
|
||||
source: database
|
||||
target: /var/lib/postgresql/data
|
Loading…
Reference in New Issue
Block a user