refactor(gitea): support using forgejo in the role
This commit is contained in:
		@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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 }}"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user