| 1 | --- |
| 2 | # SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | # |
| 4 | # shithubd app role: installs the binary, env files, systemd units. |
| 5 | # Binary is built locally and uploaded — no in-place compile on prod. |
| 6 | |
| 7 | - name: Repo + temp dirs on the block volume |
| 8 | file: |
| 9 | path: "{{ item }}" |
| 10 | state: directory |
| 11 | owner: "{{ shithub_user }}" |
| 12 | group: "{{ shithub_group }}" |
| 13 | mode: "0750" |
| 14 | loop: |
| 15 | - "{{ shithub_data_root }}/repos" |
| 16 | - "{{ shithub_data_root }}/tmp" |
| 17 | - /var/lib/shithub/binaries |
| 18 | |
| 19 | - name: Upload shithubd binary (built by `make deploy` locally) |
| 20 | copy: |
| 21 | src: "{{ playbook_dir }}/../../bin/shithubd" |
| 22 | dest: "/usr/local/bin/shithubd" |
| 23 | mode: "0755" |
| 24 | owner: root |
| 25 | group: root |
| 26 | |
| 27 | - name: Archive a versioned copy under /var/lib/shithub/binaries (rollback path) |
| 28 | shell: cp /usr/local/bin/shithubd /var/lib/shithub/binaries/shithubd-$(date +%Y%m%d-%H%M%S) |
| 29 | args: |
| 30 | creates: /var/lib/shithub/binaries/shithubd-{{ ansible_date_time.iso8601_basic_short }} |
| 31 | |
| 32 | - name: Web env file (0600 — secrets) |
| 33 | template: |
| 34 | src: web.env.j2 |
| 35 | dest: /etc/shithub/web.env |
| 36 | owner: "{{ shithub_user }}" |
| 37 | group: "{{ shithub_group }}" |
| 38 | mode: "0600" |
| 39 | notify: restart shithubd-web |
| 40 | |
| 41 | - name: Worker env file (0600 — secrets) |
| 42 | template: |
| 43 | src: worker.env.j2 |
| 44 | dest: /etc/shithub/worker.env |
| 45 | owner: "{{ shithub_user }}" |
| 46 | group: "{{ shithub_group }}" |
| 47 | mode: "0600" |
| 48 | notify: restart shithubd-worker |
| 49 | |
| 50 | - name: systemd unit — web |
| 51 | copy: |
| 52 | src: "{{ playbook_dir }}/../systemd/shithubd-web.service" |
| 53 | dest: /etc/systemd/system/shithubd-web.service |
| 54 | mode: "0644" |
| 55 | notify: [daemon-reload, restart shithubd-web] |
| 56 | |
| 57 | - name: systemd unit — worker |
| 58 | copy: |
| 59 | src: "{{ playbook_dir }}/../systemd/shithubd-worker.service" |
| 60 | dest: /etc/systemd/system/shithubd-worker.service |
| 61 | mode: "0644" |
| 62 | notify: [daemon-reload, restart shithubd-worker] |
| 63 | |
| 64 | - name: systemd unit — cron service + timer |
| 65 | copy: |
| 66 | src: "{{ playbook_dir }}/../systemd/{{ item }}" |
| 67 | dest: "/etc/systemd/system/{{ item }}" |
| 68 | mode: "0644" |
| 69 | loop: |
| 70 | - shithubd-cron.service |
| 71 | - shithubd-cron.timer |
| 72 | notify: [daemon-reload, enable shithubd-cron] |
| 73 | |
| 74 | - name: sshd_config — render with AKC line for git-over-SSH |
| 75 | template: |
| 76 | src: "{{ playbook_dir }}/../sshd_config.j2" |
| 77 | dest: /etc/ssh/sshd_config |
| 78 | mode: "0644" |
| 79 | notify: restart sshd |
| 80 | |
| 81 | - name: Enable + start shithubd-web |
| 82 | systemd: { name: shithubd-web, state: started, enabled: yes } |
| 83 | |
| 84 | - name: Enable + start shithubd-worker |
| 85 | systemd: { name: shithubd-worker, state: started, enabled: yes } |
| 86 |