From 64ff95622154df33439988f586d810bf0bbe3166 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 27 Nov 2025 05:45:27 +0000 Subject: [PATCH] Update 4 files - /roles/gitlab/tasks/main.yml - /roles/gitlab/templates/docker-compose.gitlab.yml.j2 - /olimp-deploy.yml - /inventories/hosts --- inventories/hosts | 13 ++++- olimp-deploy.yml | 8 +++- roles/gitlab/tasks/main.yml | 48 +++++++++++++++++++ .../templates/docker-compose.gitlab.yml.j2 | 37 ++++++++++++++ 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 roles/gitlab/tasks/main.yml create mode 100644 roles/gitlab/templates/docker-compose.gitlab.yml.j2 diff --git a/inventories/hosts b/inventories/hosts index b36cfb9..c407aff 100644 --- a/inventories/hosts +++ b/inventories/hosts @@ -9,7 +9,7 @@ talk ansible_host=192.168.1.206 int_ip=192.168.1.206 ansible_python_i games ansible_host=192.168.1.207 int_ip=192.168.1.207 ansible_python_interpreter=/usr/bin/python3 manage ansible_host=192.168.1.208 int_ip=192.168.1.208 ansible_python_interpreter=/usr/bin/python3 git ansible_host=192.168.1.209 int_ip=192.168.1.209 ansible_python_interpreter=/usr/bin/python3 -ansible ansible_host=192.168.1.210 int_ip=192.168.1.192.168.1.210 ansible_python_interpreter=/usr/bin/python3 +ansible ansible_host=192.168.1.210 int_ip=192.168.1.210 ansible_python_interpreter=/usr/bin/python3 #gitlab ansible_host=192.168.1.229 int_ip=192.168.1.229 ansible_python_interpreter=/usr/bin/python3 [pve-server] @@ -30,8 +30,17 @@ photo [talk-server] talk +#[cloud-server] +#cloud + [games-server] games [manage-server] -manage \ No newline at end of file +manage + +[git-server] +git + +[ansible-server] +ansible \ No newline at end of file diff --git a/olimp-deploy.yml b/olimp-deploy.yml index 877b1b7..4f0c1a9 100644 --- a/olimp-deploy.yml +++ b/olimp-deploy.yml @@ -58,4 +58,10 @@ - { role: docker, tags: deploy_docker } - { role: meshcentral, tags: deploy_meshcentral } - { role: grafana, tags: deploy_grafana } - - { role: loki, tags: deploy_loki } \ No newline at end of file + - { role: loki, tags: deploy_loki } +- hosts: git-server + roles: + - { role: base_setup, tags: deploy_base } + - { role: docker, tags: deploy_docker } + - { role: gitlab, tags: deploy_gitlab } + - { role: promtail, tags: deploy_promtail } \ No newline at end of file diff --git a/roles/gitlab/tasks/main.yml b/roles/gitlab/tasks/main.yml new file mode 100644 index 0000000..48595c5 --- /dev/null +++ b/roles/gitlab/tasks/main.yml @@ -0,0 +1,48 @@ +--- +- name: Create GitLab directories + file: + path: "{{ item }}" + state: directory + owner: root + group: root + mode: '0755' + loop: + - "{{ gitlab_config_dir }}" + - "{{ gitlab_logs_dir }}" + - "{{ gitlab_data_dir }}" + - "{{ gitlab_backup_dir }}" + +- name: Deploy Docker Compose file for GitLab + template: + src: docker-compose.gitlab.yml.j2 + dest: "{{ gitlab_base_dir }}/docker-compose.yml" + mode: '0644' + +- name: Start GitLab container + community.docker.docker_compose: + project_src: "{{ gitlab_base_dir }}" + build: no + state: present + +- name: Wait for GitLab to be ready (first boot can take 5-10 minutes) + wait_for: + host: "{{ ansible_host }}" + port: "{{ gitlab_http_port }}" + timeout: 600 + state: started + delay: 30 + +- name: Check GitLab status + uri: + url: "http://{{ ansible_host }}:{{ gitlab_http_port }}/users/sign_in" + status_code: 200 + timeout: 30 + register: gitlab_status + until: gitlab_status.status == 200 + retries: 20 + delay: 30 + +- name: Show GitLab status + debug: + msg: "GitLab is running and accessible at http://{{ ansible_host }}:{{ gitlab_http_port }}" + when: gitlab_status.status == 200 \ No newline at end of file diff --git a/roles/gitlab/templates/docker-compose.gitlab.yml.j2 b/roles/gitlab/templates/docker-compose.gitlab.yml.j2 new file mode 100644 index 0000000..8a17c11 --- /dev/null +++ b/roles/gitlab/templates/docker-compose.gitlab.yml.j2 @@ -0,0 +1,37 @@ +version: '3.8' +services: + gitlab: + image: gitlab/gitlab-ce:{{ gitlab_version }} + container_name: gitlab + restart: always + hostname: '{{ gitlab_hostname }}' + environment: + GITLAB_OMNIBUS_CONFIG: | + external_url '{{ gitlab_external_url }}' + gitlab_rails['gitlab_shell_ssh_port'] = {{ gitlab_ssh_port }} + nginx['listen_port'] = 80 + nginx['listen_https'] = false + letsencrypt['enable'] = false + gitlab_rails['initial_root_password'] = '{{ gitlab_root_password }}' + gitlab_rails['time_zone'] = '{{ timezone }}' + # Отключаем встроенный мониторинг для экономии ресурсов + prometheus_monitoring['enable'] = false + node_exporter['enable'] = false + redis_exporter['enable'] = false + postgres_exporter['enable'] = false + gitaly['prometheus_listen_addr'] = false + ports: + - "{{ gitlab_http_port }}:80" + - "{{ gitlab_ssh_port }}:22" + volumes: + - '{{ gitlab_config_dir }}:/etc/gitlab' + - '{{ gitlab_logs_dir }}:/var/log/gitlab' + - '{{ gitlab_data_dir }}:/var/opt/gitlab' + - '{{ gitlab_backup_dir }}:/var/opt/gitlab/backups' + shm_size: '256m' + networks: + - gitlab-network + +networks: + gitlab-network: + driver: bridge \ No newline at end of file