refactor(gitea): support using forgejo in the role

This commit is contained in:
transcaffeine 2023-10-07 22:18:02 +02:00
parent 4a2d1dec92
commit 5f19b5d9a9
Signed by: transcaffeine
GPG Key ID: 03624C433676E465
3 changed files with 15 additions and 11 deletions

View File

@ -2,6 +2,7 @@
gitea_version: "1.20.5"
gitea_user: git
gitea_run_user: "{{ gitea_user }}"
gitea_base_path: "/opt/gitea"
gitea_data_path: "{{ gitea_base_path }}/data"
@ -9,7 +10,7 @@ gitea_data_path: "{{ gitea_base_path }}/data"
gitea_domain: ~
# container config
gitea_container_name: "git"
gitea_container_name: "{{ gitea_user }}"
gitea_container_image_name: "docker.io/gitea/gitea"
gitea_container_image_tag: "{{ gitea_version }}"
gitea_container_image: "{{ gitea_container_image_name }}:{{ gitea_container_image_tag }}"
@ -17,9 +18,10 @@ gitea_container_networks: []
gitea_container_purge_networks: ~
gitea_container_restart_policy: "unless-stopped"
gitea_container_extra_env: {}
gitea_contianer_extra_labels: {}
gitea_container_extra_labels: {}
gitea_container_extra_ports: []
gitea_container_extra_volumes: []
gitea_container_state: started
# container defaults
gitea_container_base_volumes:

View File

@ -1,10 +1,11 @@
---
- name: Create gitea user
- name: Ensure gitea user '{{ gitea_user }}' is present
user:
name: "{{ gitea_user }}"
state: present
system: no
state: "present"
system: false
create_home: true
register: gitea_user_res
- name: Ensure host directories exist
@ -43,7 +44,7 @@
group: "{{ gitea_user_res.group }}"
mode: 0700
content: |
ssh -p {{ gitea_public_ssh_server_port }} -o StrictHostKeyChecking=no {{ gitea_user }}@127.0.0.1 -i /home/{{ gitea_user }}/.ssh/id_ssh_ed25519 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
ssh -p {{ gitea_public_ssh_server_port }} -o StrictHostKeyChecking=no {{ gitea_run_user }}@127.0.0.1 -i /home/{{ gitea_user }}/.ssh/id_ssh_ed25519 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
- name: Add host pubkey to git users authorized_keys file
lineinfile:
@ -56,23 +57,24 @@
mode: 0600
- name: Ensure gitea container image is present
docker_image:
community.docker.docker_image:
name: "{{ gitea_container_image }}"
state: present
source: pull
force_source: "{{ gitea_container_image.endswith(':latest') }}"
- name: Ensure container '{{ gitea_container_name }}' with gitea is running
docker_container:
- name: Ensure container '{{ gitea_container_name }}' with gitea is {{ gitea_container_state }}
community.docker.docker_container:
name: "{{ gitea_container_name }}"
image: "{{ gitea_container_image }}"
env: "{{ gitea_container_env }}"
labels: "{{ gitea_container_labels }}"
volumes: "{{ gitea_container_volumes }}"
networks: "{{ gitea_container_networks | default(omit, True) }}"
purge_networks: "{{ gitea_container_purge_networks | default(omit, True) }}"
published_ports: "{{ gitea_container_ports }}"
restart_policy: "{{ gitea_container_restart_policy }}"
state: started
state: "{{ gitea_container_state }}"
- name: Ensure given configuration is set in the config file
ini_file:

View File

@ -14,7 +14,7 @@ gitea_container_port_ssh: 22
gitea_config_base:
RUN_MODE: prod
RUN_USER: "{{ gitea_user }}"
RUN_USER: "{{ gitea_run_user }}"
server:
SSH_DOMAIN: "{{ gitea_domain }}"
DOMAIN: "{{ gitea_domain }}"