Wire Spaces runtime storage config
- SHA
be5b659855d439b65f5f3e4dc98726d0640768b8- Parents
-
290fe3d - Tree
3d686ad
be5b659
be5b659855d439b65f5f3e4dc98726d0640768b8290fe3d
3d686addeploy/ansible/inventory/production.examplemodified@@ -21,6 +21,15 @@ shithub_db_pool_max=20 | ||
| 21 | 21 | # Postmark sender + DKIM are configured before the deploy. |
| 22 | 22 | shithub_email_from="shithub <noreply@shithub.example>" |
| 23 | 23 | shithub_email_backend=postmark |
| 24 | +# Runtime object storage. DigitalOcean Spaces uses virtual-hosted style | |
| 25 | +# addressing and TLS; region remains us-east-1 for SigV4 signing. | |
| 26 | +s3_endpoint=nyc3.digitaloceanspaces.com | |
| 27 | +s3_region=us-east-1 | |
| 28 | +s3_bucket=shithub-prod | |
| 29 | +s3_access_key_id=REPLACE_ME | |
| 30 | +s3_secret_access_key=REPLACE_ME | |
| 31 | +s3_use_ssl=true | |
| 32 | +s3_force_path_style=false | |
| 24 | 33 | # WireGuard peer for the bare-metal monitoring box. |
| 25 | 34 | wg_metal_endpoint=metal.shithub.example:51820 |
| 26 | 35 | wg_metal_pubkey=REPLACE_ME |
deploy/ansible/inventory/staging.examplemodified@@ -12,3 +12,13 @@ shithub_data_root=/data | ||
| 12 | 12 | shithub_db_pool_max=8 |
| 13 | 13 | shithub_email_from="shithub-staging <noreply@staging.shithub.example>" |
| 14 | 14 | shithub_email_backend=stdout # no real outbound mail in staging |
| 15 | + | |
| 16 | +# Optional runtime object storage. Leave blank/undefined to disable | |
| 17 | +# avatar uploads in staging. When set, all S3 fields are required. | |
| 18 | +# s3_endpoint=nyc3.digitaloceanspaces.com | |
| 19 | +# s3_region=us-east-1 | |
| 20 | +# s3_bucket=shithub-staging | |
| 21 | +# s3_access_key_id=REPLACE_ME | |
| 22 | +# s3_secret_access_key=REPLACE_ME | |
| 23 | +# s3_use_ssl=true | |
| 24 | +# s3_force_path_style=false | |
deploy/ansible/roles/shithubd/tasks/main.ymlmodified@@ -40,6 +40,24 @@ | ||
| 40 | 40 | group: "{{ shithub_group }}" |
| 41 | 41 | mode: "0750" |
| 42 | 42 | |
| 43 | +- name: Runtime object storage config is complete when enabled | |
| 44 | + assert: | |
| 45 | + that: | |
| 46 | + - (s3_endpoint | default("") | string | length) > 0 | |
| 47 | + - (s3_bucket | default("") | string | length) > 0 | |
| 48 | + - (s3_access_key_id | default("") | string | length) > 0 | |
| 49 | + - (s3_secret_access_key | default("") | string | length) > 0 | |
| 50 | + fail_msg: >- | |
| 51 | + Runtime object storage is partially configured. Set s3_endpoint, | |
| 52 | + s3_bucket, s3_access_key_id, and s3_secret_access_key for the | |
| 53 | + DigitalOcean Spaces bucket, or leave all s3_* variables unset to | |
| 54 | + disable avatar uploads. | |
| 55 | + when: > | |
| 56 | + (s3_endpoint | default("") | string | length) > 0 or | |
| 57 | + (s3_bucket | default("") | string | length) > 0 or | |
| 58 | + (s3_access_key_id | default("") | string | length) > 0 or | |
| 59 | + (s3_secret_access_key | default("") | string | length) > 0 | |
| 60 | + | |
| 43 | 61 | - name: Web env file (0640 — group-readable for ssh-shell wrapper) |
| 44 | 62 | # The git user (running ssh-shell via the AKC's forced command) |
| 45 | 63 | # is in the shithub group and needs to source this file via the |
@@ -62,6 +80,18 @@ | ||
| 62 | 80 | mode: "0600" |
| 63 | 81 | notify: restart shithubd-worker |
| 64 | 82 | |
| 83 | +- name: Storage check — repos root and runtime object bucket | |
| 84 | + shell: | | |
| 85 | + set -a | |
| 86 | + . /etc/shithub/web.env | |
| 87 | + set +a | |
| 88 | + /usr/local/bin/shithubd storage check | |
| 89 | + args: | |
| 90 | + executable: /bin/bash | |
| 91 | + become_user: "{{ shithub_user }}" | |
| 92 | + changed_when: false | |
| 93 | + when: not ansible_check_mode | |
| 94 | + | |
| 65 | 95 | - name: systemd unit — web |
| 66 | 96 | copy: |
| 67 | 97 | src: "{{ playbook_dir }}/../systemd/shithubd-web.service" |
deploy/ansible/roles/shithubd/templates/web.env.j2modified@@ -29,6 +29,16 @@ SHITHUB_AUTH__SSH__HOST=git@{{ shithub_domain }} | ||
| 29 | 29 | |
| 30 | 30 | # storage |
| 31 | 31 | SHITHUB_STORAGE__REPOS_ROOT={{ shithub_data_root }}/repos |
| 32 | +{% if s3_bucket | default("") %} | |
| 33 | +# DigitalOcean Spaces runtime bucket via its S3-compatible API. | |
| 34 | +SHITHUB_STORAGE__S3__ENDPOINT={{ s3_endpoint }} | |
| 35 | +SHITHUB_STORAGE__S3__REGION={{ s3_region | default("us-east-1") }} | |
| 36 | +SHITHUB_STORAGE__S3__ACCESS_KEY_ID={{ s3_access_key_id }} | |
| 37 | +SHITHUB_STORAGE__S3__SECRET_ACCESS_KEY={{ s3_secret_access_key }} | |
| 38 | +SHITHUB_STORAGE__S3__BUCKET={{ s3_bucket }} | |
| 39 | +SHITHUB_STORAGE__S3__USE_SSL={{ (s3_use_ssl | default(true)) | ternary("true", "false") }} | |
| 40 | +SHITHUB_STORAGE__S3__FORCE_PATH_STYLE={{ (s3_force_path_style | default(false)) | ternary("true", "false") }} | |
| 41 | +{% endif %} | |
| 32 | 42 | |
| 33 | 43 | # AEAD keys (32-byte base64). Aliased single-underscore names. |
| 34 | 44 | SHITHUB_SESSION_KEY={{ shithub_session_key_b64 }} |
deploy/ansible/roles/shithubd/templates/worker.env.j2modified@@ -12,6 +12,16 @@ SHITHUB_AUTH__EMAIL_FROM={{ shithub_email_from }} | ||
| 12 | 12 | SHITHUB_AUTH__EMAIL_BACKEND={{ shithub_email_backend }} |
| 13 | 13 | |
| 14 | 14 | SHITHUB_STORAGE__REPOS_ROOT={{ shithub_data_root }}/repos |
| 15 | +{% if s3_bucket | default("") %} | |
| 16 | +# DigitalOcean Spaces runtime bucket via its S3-compatible API. | |
| 17 | +SHITHUB_STORAGE__S3__ENDPOINT={{ s3_endpoint }} | |
| 18 | +SHITHUB_STORAGE__S3__REGION={{ s3_region | default("us-east-1") }} | |
| 19 | +SHITHUB_STORAGE__S3__ACCESS_KEY_ID={{ s3_access_key_id }} | |
| 20 | +SHITHUB_STORAGE__S3__SECRET_ACCESS_KEY={{ s3_secret_access_key }} | |
| 21 | +SHITHUB_STORAGE__S3__BUCKET={{ s3_bucket }} | |
| 22 | +SHITHUB_STORAGE__S3__USE_SSL={{ (s3_use_ssl | default(true)) | ternary("true", "false") }} | |
| 23 | +SHITHUB_STORAGE__S3__FORCE_PATH_STYLE={{ (s3_force_path_style | default(false)) | ternary("true", "false") }} | |
| 24 | +{% endif %} | |
| 15 | 25 | |
| 16 | 26 | SHITHUB_TOTP_KEY={{ shithub_totp_key_b64 }} |
| 17 | 27 | |
deploy/redeploy.shmodified@@ -45,6 +45,7 @@ set -a | ||
| 45 | 45 | . /etc/shithub/web.env |
| 46 | 46 | set +a |
| 47 | 47 | "$BIN" migrate up |
| 48 | +"$BIN" storage check | |
| 48 | 49 | |
| 49 | 50 | systemctl restart shithubd-web |
| 50 | 51 | systemctl restart shithubd-worker |