Postgresql support added.
This commit is contained in:
22
README.org
22
README.org
@@ -6,19 +6,22 @@
|
|||||||
|
|
||||||
This role installs and configures a [[https://docs.gitea.com/][Gitea]] server.
|
This role installs and configures a [[https://docs.gitea.com/][Gitea]] server.
|
||||||
|
|
||||||
It uses SQLite as its default database service.
|
It uses SQLite as its default database service - with optional PostgreSQL support.
|
||||||
|
|
||||||
Use the =ds-ufw= role to configure the firewall.
|
Use the =ds-ufw= role to configure the firewall.
|
||||||
|
|
||||||
|
Use the =ds-posgresql= to configure the database.
|
||||||
|
|
||||||
* Role Workflow
|
* Role Workflow
|
||||||
|
|
||||||
1. Download and install the Gitea binary
|
1. Download and install the Gitea binary
|
||||||
2. Set up the user and group for the service
|
2. (Optionally) Set up the PostgreSQL user and database
|
||||||
3. Create the required directory structure
|
3. Set up the user and group for the service
|
||||||
4. Wait for the secret creation and storage in SOPS - if secrets are not present
|
4. Create the required directory structure
|
||||||
5. Deploy the Gitea configuration
|
5. Wait for the secret creation and storage in SOPS - if secrets are not present
|
||||||
6. Deploy the Gitea service file
|
6. Deploy the Gitea configuration
|
||||||
7. Enable and start the service
|
7. Deploy the Gitea service file
|
||||||
|
8. Enable and start the service
|
||||||
|
|
||||||
* Defaults
|
* Defaults
|
||||||
|
|
||||||
@@ -34,11 +37,12 @@ gitea_group: git
|
|||||||
- git
|
- git
|
||||||
- sudo
|
- sudo
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
|
- (optional) PosgreSQL database
|
||||||
|
|
||||||
* 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 |
|
||||||
@@ -52,6 +56,8 @@ gitea_group: git
|
|||||||
| gitea_lfs_jwt_secret | string | LFS storage secret |
|
| gitea_lfs_jwt_secret | string | LFS storage secret |
|
||||||
| gitea_internal_token | string | Internal token |
|
| gitea_internal_token | string | Internal token |
|
||||||
| gitea_jwt_secret | string | JWT secret |
|
| 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) |
|
||||||
|
|
||||||
* Handlers
|
* Handlers
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,42 @@
|
|||||||
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: Create the gitea group
|
- name: Create the gitea group
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ gitea_group }}"
|
name: "{{ gitea_group }}"
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user