feat(core-git): каркас машины CT 904 под Gitea до миграции
ansible-core-git / deploy (push) Successful in 27s
ansible-core-mon / deploy (push) Successful in 24s
ansible-core-net / deploy (push) Successful in 54s
ansible-core-secrets / deploy (push) Successful in 18s
ansible-ger-nod-02 / deploy (push) Successful in 1m15s
ansible-opnsense / deploy (push) Successful in 6s
ansible-rus-central / deploy (push) Successful in 50s
ansible-core-git / deploy (push) Successful in 27s
ansible-core-mon / deploy (push) Successful in 24s
ansible-core-net / deploy (push) Successful in 54s
ansible-core-secrets / deploy (push) Successful in 18s
ansible-ger-nod-02 / deploy (push) Successful in 1m15s
ansible-opnsense / deploy (push) Successful in 6s
ansible-rus-central / deploy (push) Successful in 50s
Добавляет terraform/ansible/CI и scrape cAdvisor. Стек Gitea без POSTGRES_PASSWORD в Infisical не поднимается — данные придут с CT 109. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
090a92174b
commit
c507ed1fdb
15 files changed
+315
-11
No files matched your search
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- name: cAdvisor core-git
|
||||
ansible.builtin.include_role:
|
||||
name: cadvisor
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
gitea_dir: /opt/gitea
|
||||
gitea_http_port: 3000
|
||||
gitea_ssh_port: 222
|
||||
|
||||
gitea_image: "docker.gitea.com/gitea:28.3.0"
|
||||
gitea_postgres_image: "postgres:14"
|
||||
gitea_runner_image: "docker.io/gitea/runner:5-dind"
|
||||
|
||||
gitea_domain: "gitea.gunihome.ru"
|
||||
gitea_root_url: "https://gitea.gunihome.ru"
|
||||
# Стабильное имя для clone SSH (Unbound), не LAN IP CT.
|
||||
gitea_ssh_domain: "gitea.internal"
|
||||
|
||||
gitea_postgres_user: gitea
|
||||
gitea_postgres_db: gitea
|
||||
gitea_postgres_password: "{{ lookup('env', 'GITEA_POSTGRES_PASSWORD') }}"
|
||||
|
||||
gitea_runner_name: homelab
|
||||
gitea_runner_labels: "homelab:docker://docker.gitea.com/runner-images:ubuntu-latest"
|
||||
gitea_runner_instance_url: "{{ gitea_root_url }}"
|
||||
gitea_runner_registration_token: "{{ lookup('env', 'GITEA_RUNNER_REGISTRATION_TOKEN', default='') }}"
|
||||
# Включается, если есть токен регистрации или уже лежит runner-data/.runner (после миграции).
|
||||
gitea_runner_enabled: false
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Есть ли данные Postgres (после миграции)
|
||||
ansible.builtin.stat:
|
||||
path: "{{ gitea_dir }}/postgres/PG_VERSION"
|
||||
register: gitea_postgres_data
|
||||
|
||||
- name: Есть ли уже регистрация runner
|
||||
ansible.builtin.stat:
|
||||
path: "{{ gitea_dir }}/runner-data/.runner"
|
||||
register: gitea_runner_file
|
||||
|
||||
- name: Нужен ли пароль для запуска стека
|
||||
ansible.builtin.set_fact:
|
||||
gitea_stack_ready: "{{ (gitea_postgres_password | default('') | length > 0) }}"
|
||||
|
||||
- name: Без пароля стек не поднимаем (ожидается миграция)
|
||||
ansible.builtin.debug:
|
||||
msg: "GITEA_POSTGRES_PASSWORD пуст — каталоги при необходимости создадим, compose/up пропустим."
|
||||
when: not gitea_stack_ready
|
||||
|
||||
- name: Пароль обязателен, если данные БД уже на диске
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- gitea_postgres_password | length > 0
|
||||
fail_msg: "Есть данные Postgres в {{ gitea_dir }}/postgres, но GITEA_POSTGRES_PASSWORD пуст."
|
||||
when: gitea_postgres_data.stat.exists | default(false)
|
||||
|
||||
- name: Включить runner при токене или существующем .runner
|
||||
ansible.builtin.set_fact:
|
||||
gitea_runner_enabled: "{{ gitea_stack_ready and ((gitea_runner_registration_token | default('') | length > 0) or (gitea_runner_file.stat.exists | default(false))) }}"
|
||||
|
||||
- name: Создать каталоги Gitea
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ item.owner }}"
|
||||
group: "{{ item.group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- { path: "{{ gitea_dir }}", owner: "root", group: "root", mode: "0755" }
|
||||
- { path: "{{ gitea_dir }}/gitea", owner: "root", group: "root", mode: "0755" }
|
||||
- { path: "{{ gitea_dir }}/postgres", owner: "999", group: "999", mode: "0700" }
|
||||
- { path: "{{ gitea_dir }}/runner-data", owner: "root", group: "root", mode: "0700" }
|
||||
|
||||
- name: Установить compose.yaml для Gitea
|
||||
ansible.builtin.template:
|
||||
src: compose.yaml.j2
|
||||
dest: "{{ gitea_dir }}/compose.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
no_log: true
|
||||
when: gitea_stack_ready
|
||||
|
||||
- name: Запустить Gitea
|
||||
ansible.builtin.command: docker compose -f {{ gitea_dir }}/compose.yaml up -d --remove-orphans
|
||||
register: gitea_compose_up
|
||||
changed_when: >-
|
||||
'Started' in gitea_compose_up.stderr or
|
||||
'Created' in gitea_compose_up.stderr or
|
||||
'Recreated' in gitea_compose_up.stderr or
|
||||
'Pulled' in gitea_compose_up.stderr
|
||||
when: gitea_stack_ready
|
||||
@@ -0,0 +1,76 @@
|
||||
name: gitea
|
||||
|
||||
networks:
|
||||
gitea:
|
||||
external: false
|
||||
{% if gitea_runner_enabled %}
|
||||
|
||||
volumes:
|
||||
runner-docker:
|
||||
{% endif %}
|
||||
|
||||
services:
|
||||
server:
|
||||
image: {{ gitea_image }}
|
||||
container_name: gitea
|
||||
environment:
|
||||
GITEA__database__DB_TYPE: postgres
|
||||
GITEA__database__HOST: db:5432
|
||||
GITEA__database__NAME: {{ gitea_postgres_db | to_json }}
|
||||
GITEA__database__USER: {{ gitea_postgres_user | to_json }}
|
||||
GITEA__database__PASSWD: {{ gitea_postgres_password | to_json }}
|
||||
GITEA__server__ROOT_URL: {{ gitea_root_url | to_json }}
|
||||
GITEA__server__DOMAIN: {{ gitea_domain | to_json }}
|
||||
GITEA__server__SSH_DOMAIN: {{ gitea_ssh_domain | to_json }}
|
||||
GITEA__server__SSH_PORT: "{{ gitea_ssh_port }}"
|
||||
GITEA__service__DISABLE_REGISTRATION: "true"
|
||||
restart: always
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- {{ gitea_dir }}/gitea:/data
|
||||
ports:
|
||||
- "{{ gitea_http_port }}:3000"
|
||||
- "{{ gitea_ssh_port }}:22"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
db:
|
||||
image: {{ gitea_postgres_image }}
|
||||
container_name: gitea-db
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: {{ gitea_postgres_user | to_json }}
|
||||
POSTGRES_PASSWORD: {{ gitea_postgres_password | to_json }}
|
||||
POSTGRES_DB: {{ gitea_postgres_db | to_json }}
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- {{ gitea_dir }}/postgres:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U {{ gitea_postgres_user }} -d {{ gitea_postgres_db }}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 20s
|
||||
{% if gitea_runner_enabled %}
|
||||
|
||||
runner:
|
||||
image: {{ gitea_runner_image }}
|
||||
container_name: gitea-runner
|
||||
restart: always
|
||||
privileged: true
|
||||
environment:
|
||||
GITEA_INSTANCE_URL: {{ gitea_runner_instance_url | to_json }}
|
||||
GITEA_RUNNER_NAME: {{ gitea_runner_name | to_json }}
|
||||
GITEA_RUNNER_LABELS: {{ gitea_runner_labels | to_json }}
|
||||
{% if gitea_runner_registration_token | length > 0 %}
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN: {{ gitea_runner_registration_token | to_json }}
|
||||
{% endif %}
|
||||
networks:
|
||||
- gitea
|
||||
volumes:
|
||||
- {{ gitea_dir }}/runner-data:/data
|
||||
- runner-docker:/var/lib/docker
|
||||
{% endif %}
|
||||
Reference in new issue
Block a user