diff --git a/roles/mastodon/tasks/main.yml b/roles/mastodon/tasks/main.yml index eee3162..988307d 100644 --- a/roles/mastodon/tasks/main.yml +++ b/roles/mastodon/tasks/main.yml @@ -40,31 +40,10 @@ mode: '0660' owner: root group: root -- name: Create web container - become: true - community.docker.docker_container: - name: mastodon-web-{{ item }} - image: ghcr.io/mastodon/mastodon:{{ version }} - env_file: /etc/mastodon/.env - command: ["bundle", "exec", "puma", "-C", "config/puma.rb"] - networks: - - name: mastodon - - name: postgresql - - name: minio - - name: haproxy - - name: authentik - volumes: - - mastodon-public-system:/mastodon/public/system - restart_policy: unless-stopped - healthcheck: - test: ["CMD", "curl", "--fail", "127.0.0.1:3000/health"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 30s - # TODO: enable after ansible update - # state: healthy - loop: ["1", "2"] +- include_tasks: start_web_server.yml + loop: [1, 2] + loop_control: + loop_var: server_idx - name: Create streaming container become: true community.docker.docker_container: diff --git a/roles/mastodon/tasks/start_web_server.yml b/roles/mastodon/tasks/start_web_server.yml new file mode 100644 index 0000000..b6ec50e --- /dev/null +++ b/roles/mastodon/tasks/start_web_server.yml @@ -0,0 +1,41 @@ +--- +- name: Disable web server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: disabled + backend: mastodon + host: s{{ server_idx }} + fail_on_not_found: true +- name: Create web container + become: true + community.docker.docker_container: + name: mastodon-web-{{ server_idx }} + image: ghcr.io/mastodon/mastodon:{{ version }} + env_file: /etc/mastodon/.env + command: ["bundle", "exec", "puma", "-C", "config/puma.rb"] + networks: + - name: mastodon + - name: postgresql + - name: minio + - name: haproxy + - name: authentik + volumes: + - mastodon-public-system:/mastodon/public/system + restart_policy: unless-stopped + healthcheck: + test: ["CMD", "curl", "--fail", "127.0.0.1:3000/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + # TODO: enable after ansible update + # state: healthy +- name: Enable web server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: enabled + backend: mastodon + host: s{{ server_idx }} + fail_on_not_found: true