openneo-code/setup-forgejo.yml
Emi Matchu e0ffcbdd7f Oops, enable the Forgejo service!
That's a step I've been forgetting with services lately, but yeah, I
ran into this where analytics.openneo.net went down and I wasn't sure
why it didn't get auto-restarted, and I think it being Started But Not
Enabled is why.

So, ta-da! Fix it here before we run into that lol.

Also I refactored the handlers a bit, after seeing how I did it in the
analytics Ansible file and going like. Oh, yeah, that's just better lol
2024-01-14 23:59:18 -08:00

79 lines
1.9 KiB
YAML

---
# Adapted from https://forgejo.org/docs/latest/admin/installation-binary/
- name: Install Forgejo
hosts: webserver
become: yes
become_user: root
tasks:
- name: Download Forgejo binary to /usr/local/bin (and verify its checksum)
get_url:
url: https://codeberg.org/forgejo/forgejo/releases/download/v1.21.3-0/forgejo-1.21.3-0-linux-amd64
dest: /usr/local/bin/forgejo
checksum: "sha256:8c8f34e889f968b4f9357701ceee7daab5b47ea605793325da8e3e740457b45a"
mode: "755"
- name: Update apt cache
apt:
update_cache: true
- name: Install git and git-lfs
apt:
name:
- git
- git-lfs
- name: Create git user
user:
name: git
password: "!" # disables password login
home: /home/git
shell: /bin/bash
comment: Git Version Control
- name: Create Forgejo's data directory
file:
path: /var/lib/forgejo
state: directory
mode: "750"
owner: git
group: git
- name: Create Forgejo's config directory
file:
path: /etc/forgejo
state: directory
mode: "750"
owner: root
group: git
- name: Copy app.ini to Forgejo's config directory
copy:
src: files/app.ini
dest: /etc/forgejo/app.ini
mode: "640"
notify:
- Restart Forgejo
- name: Install systemd service for Forgejo
copy:
src: files/forgejo.service
dest: /etc/systemd/system/forgejo.service
notify:
- Reload service files
- Restart Forgejo
- name: Enable Forgejo service
systemd_service:
name: forgejo
enabled: true
state: started
handlers:
- name: Reload service files
systemd_service:
daemon_reload: true
- name: Restart Forgejo
systemd_service:
name: forgejo
state: restarted