diff --git a/roles/forgejo/tasks/main.yml b/roles/forgejo/tasks/main.yml index ed90b8d..85bfa4b 100644 --- a/roles/forgejo/tasks/main.yml +++ b/roles/forgejo/tasks/main.yml @@ -24,26 +24,8 @@ group: 1000 mode: '0660' register: appini -- name: Create forgejo container - become: true - community.docker.docker_container: - name: forgejo - image: codeberg.org/forgejo/forgejo:{{ tag }} - env: - USER_UID: "{{ user_uid | string }}" - USER_GID: "{{ user_gid | string }}" - FORGEJO_WORK_DIR: "{{ work_path }}" - FORGEJO_CUSTOM: "{{ work_path }}/custom" - networks: - - name: postgresql - - name: forgejo - - name: minio - - name: haproxy - volumes: - - forgejo:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "{{ ssh_listen_port }}:{{ ssh_listen_port }}" - recreate: "{{ appini.changed }}" - restart_policy: unless-stopped +- include_tasks: start_server.yml + # We need to solve the problems with queues/locks before adding more servers. + loop: [1] + loop_control: + loop_var: server_idx diff --git a/roles/forgejo/tasks/start_server.yml b/roles/forgejo/tasks/start_server.yml new file mode 100644 index 0000000..d67f858 --- /dev/null +++ b/roles/forgejo/tasks/start_server.yml @@ -0,0 +1,38 @@ +--- +- name: Disable forgejo server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: disabled + backend: forgejo + host: s{{ server_idx }} + fail_on_not_found: true +- name: Create forgejo container + become: true + community.docker.docker_container: + name: forgejo-{{ server_idx }} + image: codeberg.org/forgejo/forgejo:{{ tag }} + env: + USER_UID: "{{ user_uid | string }}" + USER_GID: "{{ user_gid | string }}" + FORGEJO_WORK_DIR: "{{ work_path }}" + FORGEJO_CUSTOM: "{{ work_path }}/custom" + networks: + - name: postgresql + - name: forgejo + - name: minio + - name: haproxy + volumes: + - forgejo:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + recreate: "{{ appini.changed }}" + restart_policy: unless-stopped +- name: Enable forgejo server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: enabled + backend: forgejo + host: s{{ server_idx }} + fail_on_not_found: true diff --git a/roles/haproxy/files/haproxy.cfg b/roles/haproxy/files/haproxy.cfg index d466f85..dcda9c5 100644 --- a/roles/haproxy/files/haproxy.cfg +++ b/roles/haproxy/files/haproxy.cfg @@ -128,6 +128,11 @@ frontend matrix-federation default_backend matrix +frontend forgejo_ssh + mode tcp + bind :8022 + default_backend forgejo_ssh + frontend authentik_ldap mode tcp bind *:389 @@ -172,7 +177,11 @@ backend minio backend forgejo mode http - server green forgejo:3000 check + server s1 forgejo-1:3000 check + +backend forgejo_ssh + mode tcp + server s1 forgejo-1:8022 check backend matrix mode http diff --git a/roles/haproxy/tasks/main.yml b/roles/haproxy/tasks/main.yml index cb7dfb8..8dfaf81 100644 --- a/roles/haproxy/tasks/main.yml +++ b/roles/haproxy/tasks/main.yml @@ -72,6 +72,7 @@ - "80:80" - "389:389" - "443:443" + - "8022:8022" - "8448:8448" restart_policy: unless-stopped - name: Reload haproxy