Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfabc38a46 | ||
|
818626b236
|
|||
|
|
d3927f6c5d | ||
|
1120daab40
|
|||
|
|
e4ea3a420d | ||
|
14d463a882
|
|||
|
|
1816d8a585 | ||
|
a22b78d585
|
|||
|
aafa72a464
|
|||
|
ae3af7ea83
|
|||
|
|
09e8534569 | ||
|
6928e8cf54
|
|||
|
dc1b18019a
|
|||
|
02426968fb
|
|||
|
edb227a763
|
|||
|
c03f0a0f4f
|
|||
|
|
7b0b2e8194 | ||
|
2cca3d5403
|
|||
|
9e68459916
|
|||
|
e23f9b1901
|
|||
|
|
c8fa7680ca | ||
|
007ae9a90a
|
|||
|
557fe0d5dc
|
|||
|
ab06bc177e
|
|||
|
|
0f2c17071c | ||
|
2b3391bf18
|
|||
|
18e2fe1204
|
|||
|
|
4340021552 | ||
|
f0aecb43dd
|
|||
|
|
d716fefb88 | ||
|
c088b18b49
|
|||
|
d010774f45
|
|||
|
fe98b961ab
|
|||
|
a8a8907463
|
|||
|
f6a20bb16f
|
|||
|
852791e15a
|
|||
|
fe2672d55b
|
|||
|
56d6401155
|
118
README.org
118
README.org
@@ -1,57 +1,91 @@
|
|||||||
#+TITLE: Gitea Server Installer Role
|
#+TITLE: Gitea Server Role
|
||||||
#+AUTHOR: DeadSwitch | The Silent Architect
|
#+AUTHOR: DeadSwitch | The Silent Architect
|
||||||
#+OPTIONS: toc:nil num:nil \n:t
|
#+OPTIONS: toc:nil num:nil \n:t
|
||||||
|
|
||||||
|
[[https://opensource.org/licenses/MIT][https://img.shields.io/badge/license-MIT-blue.svg]] [[https://img.shields.io/badge/version-3.0.2-green.svg]]
|
||||||
|
|
||||||
* ds-gitea
|
* ds-gitea
|
||||||
|
|
||||||
This role installs and configures a basic [[https://docs.gitea.com/][Gitea]] server.
|
This role can install and configures a [[https://docs.gitea.com/][Gitea]] server.
|
||||||
|
|
||||||
Currently it uses SQLite as its database service.
|
It uses SQLite as its default database service - with optional PostgreSQL support (=ds-posgresql=).
|
||||||
|
|
||||||
Use the =ds-ufw= role to set up the firewall.
|
The role can set up a reverse proxy with SSL using Nginx (=ds-nginx=).
|
||||||
|
Self-signed certificates and Let's Encrypt with =certbot= are supported.
|
||||||
|
|
||||||
* Features
|
The =ds-ufw= role can configure the firewall.
|
||||||
|
|
||||||
- Download and install the Gitea binary
|
The =ds-act_runner= role can configure and register Actions runners.
|
||||||
- Set up the user and group for the service
|
|
||||||
- Create the required directory structure
|
* Role Behavior
|
||||||
- Deploy the Gitea configuration
|
|
||||||
- Deploy the Gitea service file
|
1. Download and install the Gitea binary
|
||||||
- Enable and start the service
|
2. (Optionally) Set up the PostgreSQL user and database
|
||||||
|
3. (Optionally) Set up an =nginx= reverse proxy with SSL support
|
||||||
|
4. Create a user and group for the service
|
||||||
|
5. Create the required directory structure
|
||||||
|
6. Wait to save the secrets in SOPS (only if secrets are not present)
|
||||||
|
7. Deploy the Gitea =app.ini= configuration
|
||||||
|
8. Deploy the Gitea systemd service
|
||||||
|
9. Enable and start the services
|
||||||
|
|
||||||
* Defaults
|
* Defaults
|
||||||
|
|
||||||
#+begin_src yaml
|
#+begin_src yaml
|
||||||
gitea_user: git
|
gitea_user: git
|
||||||
gitea_group: git
|
gitea_group: git
|
||||||
|
gitea_http_port: 3000
|
||||||
|
gitea_ssh_port: 22
|
||||||
|
gitea_require_signin_view: true
|
||||||
|
gitea_disable_registration: true
|
||||||
|
gitea_register_manual_confirm: false
|
||||||
|
gitea_enable_captcha: false
|
||||||
|
gitea_default_keep_email_private: true
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
The remaining variables must be declared in the inventory.
|
|
||||||
|
|
||||||
* Requirements
|
* Requirements
|
||||||
|
|
||||||
- Ansible >= 2.12
|
- Ansible >= 2.12
|
||||||
- Debian-based OS (Bookworm, Trixie)
|
- Debian 12+ or compatible
|
||||||
- git
|
- git
|
||||||
- sudo
|
- sudo
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
|
- (optional) PosgreSQL database
|
||||||
|
- (optional) Nginx server
|
||||||
|
- (optional) certbot for Let's Encrypt
|
||||||
|
|
||||||
* Variables
|
* Variables
|
||||||
|
|
||||||
| Variable | Type | Comment |
|
| Variable | Type | Comment |
|
||||||
|----------------------+--------+----------------------------|
|
|----------------------------------+---------+--------------------------------------------------|
|
||||||
| gitea_user | string | Gitea user |
|
| gitea_user | string | Gitea user |
|
||||||
| gitea_group | string | Gitea group |
|
| gitea_group | string | Gitea group |
|
||||||
| gitea_binary_url | string | Download URL of Gitea |
|
| gitea_binary_url | string | Download URL of Gitea |
|
||||||
| gitea_checksum_url | string | Checksum URL of the binary |
|
| gitea_checksum_url | string | Checksum URL of the binary |
|
||||||
| gitea_app_name | string | Gitea application title |
|
| gitea_app_name | string | Gitea server title |
|
||||||
| gitea_ssh_domain | string | SSH domain |
|
| gitea_ssh_domain | string | SSH domain |
|
||||||
| gitea_domain | string | Domain to reach Gitea |
|
| gitea_domain | string | Domain to reach Gitea |
|
||||||
| gitea_http_port | int | Gitea HTTP port |
|
| gitea_http_port | int | HTTP port |
|
||||||
| gitea_root_url | string | Protocoll + FQDN |
|
| gitea_ssh_port | int | SSH port |
|
||||||
| gitea_lfs_jwt_secret | string | LFS storage secret |
|
| gitea_root_url | string | Protocol + FQDN + port |
|
||||||
| gitea_internal_token | string | Internal token |
|
| gitea_lfs_jwt_secret | string | LFS storage secret |
|
||||||
| gitea_jwt_secret | string | JWT secret |
|
| gitea_internal_token | string | Internal token |
|
||||||
|
| gitea_jwt_secret | string | JWT secret |
|
||||||
|
| gitea_database_server | string | DB server - 'postgresql' or empty for sqlite |
|
||||||
|
| gitea_db_password | string | PosgreSQL db password (if pgsql is used) |
|
||||||
|
| gitea_reverse_proxy | string | Reverse proxy to use or not set for no proxy |
|
||||||
|
| gitea_enable_https | boolean | Configure HTTPS in the proxy |
|
||||||
|
| gitea_ssl_cert | string | SSL certificate |
|
||||||
|
| gitea_ssl_key | string | SSL key |
|
||||||
|
| gitea_enable_http_redirect | boolean | Redirect HTTP to HTTPS |
|
||||||
|
| gitea_self_signed | boolean | Generate a self-signed cert and key |
|
||||||
|
| gitea_lets_encrypt | boolean | Use certbot to configure the SSL |
|
||||||
|
| gitea_certbot_email | string | Email to register the certificates |
|
||||||
|
| gitea_require_signin_view | boolean | If false, public repos are visible without login |
|
||||||
|
| gitea_disable_registration | boolean | Turn off the user registration feature |
|
||||||
|
| gitea_register_manual_confirm | boolean | Registration requires admin verification |
|
||||||
|
| gitea_enable_captcha | boolean | Enable captcha for registration |
|
||||||
|
| gitea_default_keep_email_private | boolean | Default email policy: private |
|
||||||
|
|
||||||
* Handlers
|
* Handlers
|
||||||
|
|
||||||
@@ -60,9 +94,9 @@ The remaining variables must be declared in the inventory.
|
|||||||
|
|
||||||
* Secrets
|
* Secrets
|
||||||
|
|
||||||
Always store the production secrets in SOPS, or in Ansible Vault.
|
Always save the production secrets in SOPS, or in Ansible Vault.
|
||||||
|
|
||||||
Generate the secrets manually when the playbook stops:
|
You can generate the secrets manually when the playbook stops:
|
||||||
|
|
||||||
#+begin_src shell
|
#+begin_src shell
|
||||||
gitea generate secret INTERNAL_TOKEN
|
gitea generate secret INTERNAL_TOKEN
|
||||||
@@ -75,6 +109,8 @@ Then re-run the playbook to finish the installation.
|
|||||||
|
|
||||||
* Example Playbook
|
* Example Playbook
|
||||||
|
|
||||||
|
You can find more playbook examples in the =examples= directory.
|
||||||
|
|
||||||
#+begin_src yaml
|
#+begin_src yaml
|
||||||
- name: Deploy a Gitea server
|
- name: Deploy a Gitea server
|
||||||
hosts: gitea
|
hosts: gitea
|
||||||
@@ -89,11 +125,29 @@ Then re-run the playbook to finish the installation.
|
|||||||
gitea_ssh_domain: gitea.tomsitcafe.com
|
gitea_ssh_domain: gitea.tomsitcafe.com
|
||||||
gitea_domain: gitea.tomsitcafe.com
|
gitea_domain: gitea.tomsitcafe.com
|
||||||
gitea_http_port: 3000
|
gitea_http_port: 3000
|
||||||
gitea_root_url: http://gitea.tomsitcafe.com:3000
|
gitea_root_url: https://gitea.tomsitcafe.com
|
||||||
# In prod put these secrets in SOPS:
|
|
||||||
|
# Optional Postgresql database backend
|
||||||
|
gitea_database_server: postgresql
|
||||||
|
|
||||||
|
# Optional Nginx reverse proxy configuration
|
||||||
|
gitea_reverse_proxy: nginx
|
||||||
|
gitea_enable_https: true # Use HTTPS
|
||||||
|
gitea_self_signed: false # Don't generate self-signed certs
|
||||||
|
gitea_lets_encrypt: true # Use certbot
|
||||||
|
gitea_enable_http_redirect: true # Redirect HTTP to HTTPS
|
||||||
|
|
||||||
|
# Certbot configuration
|
||||||
|
gitea_certbot_email: email@domain.tld
|
||||||
|
gitea_ssl_cert: /etc/letsencrypt/live/{{ gitea_domain }}/fullchain.pem
|
||||||
|
gitea_ssl_key: /etc/letsencrypt/live/{{ gitea_domain }}/privkey.pem
|
||||||
|
gitea_ssl_trusted_certificate: /etc/letsencrypt/live/{{ gitea_domain }}/chain.pem
|
||||||
|
|
||||||
|
# In prod put the secrets in SOPS:
|
||||||
gitea_lfs_jwt_secret: G9bZrRHMhRQ8w4R0KkH2VLnx2rzq81ROQ951IQjlMs4
|
gitea_lfs_jwt_secret: G9bZrRHMhRQ8w4R0KkH2VLnx2rzq81ROQ951IQjlMs4
|
||||||
gitea_internal_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3NzA2Mzk1Njh9.ybbaeNLFiLbyvxfj4vkqhXSAXKRGpwvP8jIm9YLPgXw
|
gitea_internal_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3NzA2Mzk1Njh9.ybbaeNLFiLbyvxfj4vkqhXSAXKRGpwvP8jIm9YLPgXw
|
||||||
gitea_jwt_secret: uJni4x4e0AzpkLYc-t4keRJKOB6EaLzwVsdLeamkFyU
|
gitea_jwt_secret: uJni4x4e0AzpkLYc-t4keRJKOB6EaLzwVsdLeamkFyU
|
||||||
|
gitea_db_password: Eegh7Aothooph7pa6eu7eitha_zaim0G
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: ds-gitea
|
- role: ds-gitea
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
---
|
---
|
||||||
gitea_user: git
|
gitea_user: git
|
||||||
gitea_group: git
|
gitea_group: git
|
||||||
|
gitea_http_port: 3000
|
||||||
|
gitea_ssh_port: 22
|
||||||
|
gitea_require_signin_view: true
|
||||||
|
gitea_disable_registration: true
|
||||||
|
gitea_register_manual_confirm: false
|
||||||
|
gitea_enable_captcha: false
|
||||||
|
gitea_default_keep_email_private: true
|
||||||
|
|||||||
34
examples/certbot-playbook.yml
Normal file
34
examples/certbot-playbook.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- name: Install Gitea
|
||||||
|
hosts: gitea
|
||||||
|
become: true
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: ds-postgresql
|
||||||
|
- role: ds-nginx
|
||||||
|
- role: ds-gitea
|
||||||
|
vars:
|
||||||
|
gitea_user: git
|
||||||
|
gitea_group: git
|
||||||
|
gitea_database_server: postgresql
|
||||||
|
gitea_binary_url: https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64
|
||||||
|
gitea_checksum_url: https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64.sha256
|
||||||
|
gitea_app_name: Tom's IT Cafe Test Gitea Server
|
||||||
|
gitea_domain: gitea.tomsitcafe.com
|
||||||
|
gitea_ssh_domain: "{{ gitea_domain }}"
|
||||||
|
gitea_http_port: 3000
|
||||||
|
gitea_ssh_port: 22
|
||||||
|
gitea_root_url: https://{{ gitea_domain }}
|
||||||
|
gitea_reverse_proxy: nginx
|
||||||
|
gitea_enable_https: true
|
||||||
|
gitea_lets_encrypt: true
|
||||||
|
gitea_enable_http_redirect: true
|
||||||
|
gitea_certbot_email: tom@tomsitcafe.com
|
||||||
|
gitea_ssl_cert: /etc/letsencrypt/live/{{ gitea_domain }}/fullchain.pem
|
||||||
|
gitea_ssl_key: /etc/letsencrypt/live/{{ gitea_domain }}/privkey.pem
|
||||||
|
gitea_ssl_trusted_certificate: /etc/letsencrypt/live/{{ gitea_domain }}/chain.pem
|
||||||
|
# Secrets to SOPS
|
||||||
|
gitea_lfs_jwt_secret: G9bZrRHMhRQ8w4R0KkH2VLnx2rzq81ROQ951IQjlMs4
|
||||||
|
gitea_internal_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3NzA2Mzk1Njh9.ybbaeNLFiLbyvxfj4vkqhXSAXKRGpwvP8jIm9YLPgXw
|
||||||
|
gitea_jwt_secret: uJni4x4e0AzpkLYc-t4keRJKOB6EaLzwVsdLeamkFyU
|
||||||
|
gitea_db_password: Eegh7Aothooph7pa6eu7eitha_zaim0G
|
||||||
21
examples/lightweight-playbook.yml
Normal file
21
examples/lightweight-playbook.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
- name: Install Gitea
|
||||||
|
hosts: gitea
|
||||||
|
become: true
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: ds-gitea
|
||||||
|
vars:
|
||||||
|
gitea_user: git
|
||||||
|
gitea_group: git
|
||||||
|
gitea_binary_url: https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64
|
||||||
|
gitea_checksum_url: https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64.sha256
|
||||||
|
gitea_app_name: Tom's IT Cafe Test Gitea Server
|
||||||
|
gitea_domain: gitea.tomsitcafe.com
|
||||||
|
gitea_ssh_domain: "{{ gitea_domain }}"
|
||||||
|
gitea_http_port: 3000
|
||||||
|
gitea_ssh_port: 22
|
||||||
|
gitea_root_url: http://{{ gitea_domain }}:{{ gitea_http_port }}
|
||||||
|
# Secrets to SOPS
|
||||||
|
gitea_lfs_jwt_secret: G9bZrRHMhRQ8w4R0KkH2VLnx2rzq81ROQ951IQjlMs4
|
||||||
|
gitea_internal_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3NzA2Mzk1Njh9.ybbaeNLFiLbyvxfj4vkqhXSAXKRGpwvP8jIm9YLPgXw
|
||||||
|
gitea_jwt_secret: uJni4x4e0AzpkLYc-t4keRJKOB6EaLzwVsdLeamkFyU
|
||||||
31
examples/self-signed-playbook.yml
Normal file
31
examples/self-signed-playbook.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
- name: Install Gitea
|
||||||
|
hosts: gitea
|
||||||
|
become: true
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: ds-postgresql
|
||||||
|
- role: ds-nginx
|
||||||
|
- role: ds-gitea
|
||||||
|
vars:
|
||||||
|
gitea_user: git
|
||||||
|
gitea_group: git
|
||||||
|
gitea_database_server: postgresql
|
||||||
|
gitea_binary_url: https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64
|
||||||
|
gitea_checksum_url: https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64.sha256
|
||||||
|
gitea_app_name: Tom's IT Cafe Test Gitea Server
|
||||||
|
gitea_domain: gitea.tomsitcafe.com
|
||||||
|
gitea_ssh_domain: "{{ gitea_domain }}"
|
||||||
|
gitea_http_port: 3000
|
||||||
|
gitea_ssh_port: 22
|
||||||
|
gitea_root_url: https://{{ gitea_domain }}
|
||||||
|
gitea_reverse_proxy: nginx
|
||||||
|
gitea_enable_https: true
|
||||||
|
gitea_self_signed: true
|
||||||
|
gitea_ssl_cert: /var/lib/gitea/certs/cert.pem
|
||||||
|
gitea_ssl_key: /var/lib/gitea/certs/key.pem
|
||||||
|
gitea_enable_http_redirect: true
|
||||||
|
# Secrets to SOPS
|
||||||
|
gitea_lfs_jwt_secret: G9bZrRHMhRQ8w4R0KkH2VLnx2rzq81ROQ951IQjlMs4
|
||||||
|
gitea_internal_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3NzA2Mzk1Njh9.ybbaeNLFiLbyvxfj4vkqhXSAXKRGpwvP8jIm9YLPgXw
|
||||||
|
gitea_jwt_secret: uJni4x4e0AzpkLYc-t4keRJKOB6EaLzwVsdLeamkFyU
|
||||||
|
gitea_db_password: Eegh7Aothooph7pa6eu7eitha_zaim0G
|
||||||
29
tasks/lets-encrypt.yml
Normal file
29
tasks/lets-encrypt.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
- name: Install certbot
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- certbot
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure webroot directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /var/www/html/.well-known/acme-challenge
|
||||||
|
state: directory
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Obtain or renew TLS certificate (non-destructive)
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: >
|
||||||
|
certbot certonly
|
||||||
|
--webroot
|
||||||
|
-w /var/www/html
|
||||||
|
-d {{ gitea_domain }}
|
||||||
|
--agree-tos
|
||||||
|
--email {{ gitea_certbot_email }}
|
||||||
|
--non-interactive
|
||||||
|
--keep-until-expiring
|
||||||
|
register: certbot_result
|
||||||
|
changed_when: "'Congratulations' in certbot_result.stdout"
|
||||||
|
notify: Reload_nginx
|
||||||
@@ -8,6 +8,64 @@
|
|||||||
update_cache: true
|
update_cache: true
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Set up the PostgreSQL database
|
||||||
|
block:
|
||||||
|
- name: Ensure PostgreSQL Python client is installed
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: python3-psycopg2
|
||||||
|
update_cache: true
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create the gitea DB role
|
||||||
|
community.postgresql.postgresql_user:
|
||||||
|
name: gitea
|
||||||
|
password: "{{ gitea_db_password }}"
|
||||||
|
role_attr_flags: "NOSUPERUSER,NOCREATEDB,NOCREATEROLE"
|
||||||
|
become_user: postgres
|
||||||
|
|
||||||
|
- name: Create the gitea database
|
||||||
|
community.postgresql.postgresql_db:
|
||||||
|
name: giteadb
|
||||||
|
owner: gitea
|
||||||
|
template: template0
|
||||||
|
encoding: UTF8
|
||||||
|
lc_collate: en_US.UTF-8
|
||||||
|
lc_ctype: en_US.UTF-8
|
||||||
|
become_user: postgres
|
||||||
|
|
||||||
|
- name: Ensure pg_hba.conf has local access for gitea
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf
|
||||||
|
regexp: '^local\s+giteadb\s+gitea\s+'
|
||||||
|
line: 'local giteadb gitea scram-sha-256'
|
||||||
|
state: present
|
||||||
|
backup: yes
|
||||||
|
notify:
|
||||||
|
- Reload_postgresql
|
||||||
|
when: gitea_database_server | default('') == "postgresql"
|
||||||
|
|
||||||
|
- name: Set up the reverse proxy
|
||||||
|
block:
|
||||||
|
- name: Deploy the site configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: gitea.j2
|
||||||
|
dest: /etc/nginx/sites-available/gitea
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
notify: Reload_nginx
|
||||||
|
|
||||||
|
- name: Enable the gitea site
|
||||||
|
ansible.builtin.file:
|
||||||
|
src: /etc/nginx/sites-available/gitea
|
||||||
|
dest: /etc/nginx/sites-enabled/gitea
|
||||||
|
state: link
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
force: true
|
||||||
|
notify: Reload_nginx
|
||||||
|
when: gitea_reverse_proxy | default('') == "nginx"
|
||||||
|
|
||||||
- name: Create the gitea group
|
- name: Create the gitea group
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ gitea_group }}"
|
name: "{{ gitea_group }}"
|
||||||
@@ -18,7 +76,8 @@
|
|||||||
name: "{{ gitea_user }}"
|
name: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
home: /home/{{ gitea_user }}
|
home: /home/{{ gitea_user }}
|
||||||
shell: /usr/sbin/nologin
|
shell: /bin/bash
|
||||||
|
password: '*'
|
||||||
system: true
|
system: true
|
||||||
create_home: true
|
create_home: true
|
||||||
|
|
||||||
@@ -35,6 +94,16 @@
|
|||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: '0750'
|
mode: '0750'
|
||||||
|
|
||||||
|
- name: Generate self-signed certificates
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: self-signed-cert.yml
|
||||||
|
when: gitea_self_signed | default(false)
|
||||||
|
|
||||||
|
- name: Configure the Let's Encrypt certificates
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: lets-encrypt.yml
|
||||||
|
when: gitea_lets_encrypt | default(false)
|
||||||
|
|
||||||
- name: Pause to generate and save the secrets in SOPS
|
- name: Pause to generate and save the secrets in SOPS
|
||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
prompt: |
|
prompt: |
|
||||||
|
|||||||
18
tasks/self-signed-cert.yml
Normal file
18
tasks/self-signed-cert.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
- name: Create the certs directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /var/lib/gitea/certs
|
||||||
|
owner: "{{ gitea_user }}"
|
||||||
|
group: "{{ gitea_group }}"
|
||||||
|
mode: '0750'
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Generate the self-signed certs for Gitea
|
||||||
|
ansible.builtin.command: >
|
||||||
|
gitea cert
|
||||||
|
--host {{ gitea_domain }},{{ gitea_ssh_domain }}
|
||||||
|
--out /var/lib/gitea/certs/cert.pem
|
||||||
|
--keyout /var/lib/gitea/certs/key.pem
|
||||||
|
become_user: "{{ gitea_user }}"
|
||||||
|
args:
|
||||||
|
creates: /var/lib/gitea/certs/cert.pem
|
||||||
@@ -5,6 +5,15 @@ RUN_USER = {{ gitea_user }}
|
|||||||
WORK_PATH = /var/lib/gitea
|
WORK_PATH = /var/lib/gitea
|
||||||
RUN_MODE = prod
|
RUN_MODE = prod
|
||||||
|
|
||||||
|
{% if gitea_database_server | default('') == "postgresql" %}
|
||||||
|
[database]
|
||||||
|
DB_TYPE = postgres
|
||||||
|
HOST = 127.0.0.1:5432
|
||||||
|
NAME = giteadb
|
||||||
|
USER = gitea
|
||||||
|
PASSWD = {{ gitea_db_password }}
|
||||||
|
SSL_MODE = disable
|
||||||
|
{% else %}
|
||||||
[database]
|
[database]
|
||||||
DB_TYPE = sqlite3
|
DB_TYPE = sqlite3
|
||||||
HOST = 127.0.0.1:3306
|
HOST = 127.0.0.1:3306
|
||||||
@@ -15,6 +24,7 @@ SCHEMA =
|
|||||||
SSL_MODE = disable
|
SSL_MODE = disable
|
||||||
PATH = /var/lib/gitea/data/gitea.db
|
PATH = /var/lib/gitea/data/gitea.db
|
||||||
LOG_SQL = false
|
LOG_SQL = false
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[repository]
|
[repository]
|
||||||
ROOT = /var/lib/gitea/data/gitea-repositories
|
ROOT = /var/lib/gitea/data/gitea-repositories
|
||||||
@@ -26,7 +36,7 @@ HTTP_PORT = {{ gitea_http_port }}
|
|||||||
ROOT_URL = {{ gitea_root_url }}
|
ROOT_URL = {{ gitea_root_url }}
|
||||||
APP_DATA_PATH = /var/lib/gitea/data
|
APP_DATA_PATH = /var/lib/gitea/data
|
||||||
DISABLE_SSH = false
|
DISABLE_SSH = false
|
||||||
SSH_PORT = 22
|
SSH_PORT = {{ gitea_ssh_port }}
|
||||||
LFS_START_SERVER = true
|
LFS_START_SERVER = true
|
||||||
LFS_JWT_SECRET = {{ gitea_lfs_jwt_secret }}
|
LFS_JWT_SECRET = {{ gitea_lfs_jwt_secret }}
|
||||||
OFFLINE_MODE = true
|
OFFLINE_MODE = true
|
||||||
@@ -40,14 +50,15 @@ ENABLED = false
|
|||||||
[service]
|
[service]
|
||||||
REGISTER_EMAIL_CONFIRM = false
|
REGISTER_EMAIL_CONFIRM = false
|
||||||
ENABLE_NOTIFY_MAIL = false
|
ENABLE_NOTIFY_MAIL = false
|
||||||
DISABLE_REGISTRATION = false
|
DISABLE_REGISTRATION = {{ gitea_disable_registration }}
|
||||||
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
|
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
|
||||||
ENABLE_CAPTCHA = false
|
ENABLE_CAPTCHA = {{ gitea_enable_captcha }}
|
||||||
REQUIRE_SIGNIN_VIEW = false
|
REQUIRE_SIGNIN_VIEW = {{ gitea_require_signin_view }}
|
||||||
DEFAULT_KEEP_EMAIL_PRIVATE = false
|
DEFAULT_KEEP_EMAIL_PRIVATE = {{ gitea_default_keep_email_private }}
|
||||||
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
|
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
|
||||||
DEFAULT_ENABLE_TIMETRACKING = true
|
DEFAULT_ENABLE_TIMETRACKING = true
|
||||||
NO_REPLY_ADDRESS = noreply.localhost
|
NO_REPLY_ADDRESS = noreply.localhost
|
||||||
|
REGISTER_MANUAL_CONFIRM = {{ gitea_register_manual_confirm }}
|
||||||
|
|
||||||
[openid]
|
[openid]
|
||||||
ENABLE_OPENID_SIGNIN = false
|
ENABLE_OPENID_SIGNIN = false
|
||||||
|
|||||||
72
templates/gitea.j2
Normal file
72
templates/gitea.j2
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% if gitea_enable_https | default(false) %}
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
http2 on;
|
||||||
|
server_name {{ gitea_domain }};
|
||||||
|
|
||||||
|
ssl_certificate {{ gitea_ssl_cert }};
|
||||||
|
ssl_certificate_key {{ gitea_ssl_key }};
|
||||||
|
{% if gitea_lets_encrypt | default(false) %}
|
||||||
|
ssl_trusted_certificate {{ gitea_ssl_trusted_certificate }};
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
|
||||||
|
client_max_body_size 50M;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
client_max_body_size 512M;
|
||||||
|
proxy_pass http://localhost:{{ gitea_http_port }};
|
||||||
|
proxy_set_header Connection $http_connection;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{% if gitea_enable_http_redirect | default(true) %}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name {{ gitea_domain }};
|
||||||
|
|
||||||
|
{% if gitea_lets_encrypt | default(false) %}
|
||||||
|
# Allow Let's Encrypt to verify certificates
|
||||||
|
location ^~ /.well-known/acme-challenge/ {
|
||||||
|
root /var/www/html;
|
||||||
|
allow all;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Redirect everything else to HTTPS
|
||||||
|
location / {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
{% else %}
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
# HTTP-only configuration
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name {{ gitea_domain }};
|
||||||
|
|
||||||
|
client_max_body_size 50M;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
client_max_body_size 512M;
|
||||||
|
proxy_pass http://localhost:{{ gitea_http_port }};
|
||||||
|
proxy_set_header Connection $http_connection;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
@@ -3,6 +3,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Gitea (Git with a cup of tea)
|
Description=Gitea (Git with a cup of tea)
|
||||||
After=network.target
|
After=network.target
|
||||||
|
{% if gitea_database_server | default('') == "postgresql" %}
|
||||||
|
Wants=postgresql.service
|
||||||
|
After=postgresql.service
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
RestartSec=2s
|
RestartSec=2s
|
||||||
|
|||||||
Reference in New Issue
Block a user