This template allows deploying a forgejo en either Scaleway or Hetzner (untested) without much knowledge about them. It DOES require knowledge about Terragrunt and ansible. A wizard of sorts is provided but it will not guarantee success without some knowledge about the underlying technology.
122 lines
4 KiB
YAML
122 lines
4 KiB
YAML
---
|
|
# Deploy Forgejo Git Forge
|
|
# This playbook deploys a complete Forgejo instance with PostgreSQL, Redis, Nginx, and SSL
|
|
|
|
- name: Deploy Forgejo
|
|
hosts: forgejo
|
|
become: yes
|
|
gather_facts: yes
|
|
|
|
vars_files:
|
|
- vars/main.yml
|
|
- vars/secrets.yml # Ansible Vault encrypted
|
|
|
|
pre_tasks:
|
|
- name: Verify Ansible version
|
|
ansible.builtin.assert:
|
|
that:
|
|
- ansible_version.full is version('2.14', '>=')
|
|
fail_msg: "This playbook requires Ansible 2.14 or higher"
|
|
success_msg: "Ansible version is compatible"
|
|
|
|
- name: Gather system facts
|
|
ansible.builtin.setup:
|
|
|
|
- name: Check system requirements
|
|
ansible.builtin.assert:
|
|
that:
|
|
- ansible_memtotal_mb >= 3500
|
|
- ansible_processor_vcpus >= 2
|
|
fail_msg: "System does not meet minimum requirements (4GB RAM, 2 vCPUs)"
|
|
success_msg: "System meets requirements"
|
|
|
|
- name: Display deployment information
|
|
ansible.builtin.debug:
|
|
msg: |
|
|
Deploying Forgejo {{ forgejo_version }}
|
|
Domain: {{ forgejo_domain }}
|
|
Database: {{ forgejo_db_type }}
|
|
HTTPS: {{ forgejo_enable_letsencrypt }}
|
|
S3: {{ forgejo_enable_s3 }}
|
|
|
|
roles:
|
|
- role: forgejo
|
|
tags: ['forgejo']
|
|
|
|
post_tasks:
|
|
- name: Display completion message
|
|
ansible.builtin.debug:
|
|
msg: |
|
|
========================================
|
|
Forgejo Deployment Complete!
|
|
========================================
|
|
|
|
Access your Forgejo instance at:
|
|
{{ forgejo_protocol }}://{{ forgejo_domain }}
|
|
|
|
SSH clone URL:
|
|
git@{{ forgejo_domain }}:{{ forgejo_ssh_port }}
|
|
|
|
Admin credentials (if first install):
|
|
Username: {{ forgejo_admin_username }}
|
|
Password: (set in vault)
|
|
|
|
Next steps:
|
|
1. Visit the web interface and complete setup
|
|
2. Configure OAuth/LDAP if needed
|
|
3. Set up CI/CD with Forgejo Actions
|
|
4. Configure webhooks for integrations
|
|
|
|
Backup location: {{ forgejo_backup_path }}
|
|
Logs: {{ forgejo_data_path }}/gitea/log
|
|
|
|
========================================
|
|
|
|
- name: Verify Forgejo is running
|
|
ansible.builtin.uri:
|
|
url: "http://localhost:{{ forgejo_http_port }}"
|
|
status_code: 200
|
|
register: health_check
|
|
until: health_check.status == 200
|
|
retries: 5
|
|
delay: 3
|
|
|
|
- name: Create deployment summary file
|
|
ansible.builtin.copy:
|
|
dest: "{{ forgejo_base_path }}/DEPLOYMENT_INFO.txt"
|
|
content: |
|
|
Forgejo Deployment Information
|
|
==============================
|
|
|
|
Deployment Date: {{ ansible_date_time.iso8601 }}
|
|
Forgejo Version: {{ forgejo_version }}
|
|
Ansible User: {{ ansible_user }}
|
|
|
|
Server Details:
|
|
- Hostname: {{ ansible_hostname }}
|
|
- IP Address: {{ ansible_default_ipv4.address }}
|
|
- OS: {{ ansible_distribution }} {{ ansible_distribution_version }}
|
|
- RAM: {{ ansible_memtotal_mb }} MB
|
|
- CPUs: {{ ansible_processor_vcpus }}
|
|
|
|
Configuration:
|
|
- Domain: {{ forgejo_domain }}
|
|
- HTTP Port: {{ forgejo_http_port }}
|
|
- SSH Port: {{ forgejo_ssh_port }}
|
|
- Database: {{ forgejo_db_type }}
|
|
- Redis: {{ forgejo_use_redis }}
|
|
- LFS: {{ forgejo_enable_lfs }}
|
|
|
|
Paths:
|
|
- Base: {{ forgejo_base_path }}
|
|
- Data: {{ forgejo_data_path }}
|
|
- Config: {{ forgejo_config_path }}
|
|
- Backups: {{ forgejo_backup_path }}
|
|
|
|
Maintenance Commands:
|
|
- Restart: docker compose -f {{ forgejo_base_path }}/docker-compose.yml restart
|
|
- Logs: docker logs forgejo
|
|
- Backup: /usr/local/bin/forgejo_backup.sh
|
|
- Update: docker compose -f {{ forgejo_base_path }}/docker-compose.yml pull && docker compose up -d
|
|
mode: '0644'
|
|
become: yes
|