- Implemented complete Valkey infrastructure role following PostgreSQL patterns - Provides 100% Redis-compatible high-performance data structure store - Configured for multi-application support with database isolation - Security-focused: localhost-only binding, password auth, systemd hardening - Arch Linux compatible: uses native Valkey package with Redis compatibility - Database allocation strategy: DB 0 reserved, DB 1+ for applications - Full systemd integration with security overrides and proper service management - Redis client compatibility maintained for seamless application integration - Ready for Authentik and future container workloads requiring cache services
115 lines
2.7 KiB
YAML
115 lines
2.7 KiB
YAML
---
|
|
# Gitea Service Role - Self-Contained Implementation
|
|
# Manages Gitea Git service with own database
|
|
|
|
- name: Install Gitea from Arch repository
|
|
pacman:
|
|
name: gitea
|
|
state: present
|
|
|
|
- name: Install Git
|
|
pacman:
|
|
name: git
|
|
state: present
|
|
|
|
- name: Create Gitea user and group
|
|
user:
|
|
name: "{{ gitea_user }}"
|
|
group: "{{ gitea_group }}"
|
|
system: yes
|
|
shell: /bin/bash
|
|
home: "{{ gitea_home }}"
|
|
create_home: yes
|
|
|
|
- name: Create Gitea directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ gitea_user }}"
|
|
group: "{{ gitea_group }}"
|
|
mode: '0755'
|
|
loop:
|
|
- "{{ gitea_home }}"
|
|
- "{{ gitea_home }}/data"
|
|
- "{{ gitea_home }}/repositories"
|
|
- "{{ gitea_home }}/log"
|
|
- /etc/gitea
|
|
|
|
- name: Create Gitea SSH directory with proper permissions
|
|
file:
|
|
path: "{{ gitea_home }}/.ssh"
|
|
state: directory
|
|
owner: "{{ gitea_user }}"
|
|
group: "{{ gitea_group }}"
|
|
mode: '0700'
|
|
|
|
# Self-contained database management
|
|
- name: Create Gitea database user
|
|
postgresql_user:
|
|
name: "{{ gitea_db_user }}"
|
|
password: "{{ gitea_db_password }}"
|
|
encrypted: yes
|
|
become: yes
|
|
become_user: postgres
|
|
|
|
- name: Create Gitea database
|
|
postgresql_db:
|
|
name: "{{ gitea_db_name }}"
|
|
owner: "{{ gitea_db_user }}"
|
|
encoding: UTF8
|
|
template: template0
|
|
become: yes
|
|
become_user: postgres
|
|
|
|
- name: Deploy Gitea configuration
|
|
template:
|
|
src: app.ini.j2
|
|
dest: /etc/gitea/app.ini
|
|
owner: "{{ gitea_user }}"
|
|
group: "{{ gitea_group }}"
|
|
mode: '0600'
|
|
notify: restart gitea
|
|
|
|
- name: Deploy Gitea systemd service file
|
|
template:
|
|
src: gitea.service.j2
|
|
dest: /etc/systemd/system/gitea.service
|
|
mode: '0644'
|
|
notify:
|
|
- reload systemd
|
|
- restart gitea
|
|
|
|
- name: Deploy Caddy configuration for Gitea
|
|
template:
|
|
src: gitea.caddy.j2
|
|
dest: "{{ caddy_sites_enabled_dir }}/gitea.caddy"
|
|
mode: '0644'
|
|
notify: reload caddy
|
|
when: caddy_sites_enabled_dir is defined
|
|
|
|
- name: Enable and start Gitea service
|
|
systemd:
|
|
name: gitea
|
|
enabled: "{{ gitea_service_enabled }}"
|
|
state: "{{ gitea_service_state }}"
|
|
daemon_reload: yes
|
|
|
|
- name: Wait for Gitea to be ready
|
|
wait_for:
|
|
port: "{{ gitea_http_port }}"
|
|
host: "127.0.0.1"
|
|
timeout: 30
|
|
when: gitea_service_state == "started"
|
|
|
|
- name: Display Gitea service status
|
|
debug:
|
|
msg: |
|
|
✅ Gitea Git service deployed successfully!
|
|
|
|
🌐 Web Interface: https://{{ gitea_full_domain }}
|
|
🔗 SSH Clone: ssh://git@{{ gitea_full_domain }}:{{ gitea_ssh_port }}
|
|
📦 Local HTTP: http://127.0.0.1:{{ gitea_http_port }}
|
|
🗄️ Database: {{ gitea_db_name }} (self-managed)
|
|
|
|
🏗️ Self-contained service ready for Git repositories!
|