From 5057b9fed1215abe23ce7e7faad8a1d58e36bd7a Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Thu, 14 Nov 2024 15:40:40 +0100 Subject: [PATCH] feat(forgejo): add quadlet deployment Related to #51 Signed-off-by: Matej Focko --- roles/forgejo/tasks/main.yml | 19 +++++++++++++++++ roles/forgejo/templates/forgejo.container | 25 +++++++++++++++++++++++ roles/forgejo/templates/forgejo.network | 2 ++ roles/forgejo/templates/forgejo.volume | 2 ++ 4 files changed, 48 insertions(+) create mode 100644 roles/forgejo/tasks/main.yml create mode 100644 roles/forgejo/templates/forgejo.container create mode 100644 roles/forgejo/templates/forgejo.network create mode 100644 roles/forgejo/templates/forgejo.volume diff --git a/roles/forgejo/tasks/main.yml b/roles/forgejo/tasks/main.yml new file mode 100644 index 0000000..66b7ae0 --- /dev/null +++ b/roles/forgejo/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Install the Forgejo quadlets + ansible.builtin.template: + src: "templates/{{ item }}" + dest: "/etc/containers/systemd/{{ item }}" + mode: 0644 + owner: root + group: root + loop: + - forgejo.container + - forgejo.network + - forgejo.volume + +- name: Enable the Forgejo quadlet + ansible.builtin.systemd_service: + daemon_reload: true + enabled: true + name: forgejo.service + state: "started" diff --git a/roles/forgejo/templates/forgejo.container b/roles/forgejo/templates/forgejo.container new file mode 100644 index 0000000..f003a5f --- /dev/null +++ b/roles/forgejo/templates/forgejo.container @@ -0,0 +1,25 @@ +[Unit] +Description=Forgejo + +[Container] +ContainerName=forgejo +Image=codeberg.org/forgejo/forgejo:9 + +Environment=USER_UID=1000 +Environment=USER_GID=1000 +Environment=TZ=Europe/Prague +Environment=START_SSH_SERVER=true +Environment=SSH_CREATE_AUTHORIZED_PRINCIPALS_FILES=true +Environment=SSH_AUTHORIZED_PRINCIPALS_ALLOW="username,email" + +Network=forgejo.network +PublishPort=2222:22 +PublishPort=3000:3000 + +Volume=forgejo-data:/data + +[Service] +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/roles/forgejo/templates/forgejo.network b/roles/forgejo/templates/forgejo.network new file mode 100644 index 0000000..3c1d111 --- /dev/null +++ b/roles/forgejo/templates/forgejo.network @@ -0,0 +1,2 @@ +[Network] +NetworkName=forgejo diff --git a/roles/forgejo/templates/forgejo.volume b/roles/forgejo/templates/forgejo.volume new file mode 100644 index 0000000..38b2d8a --- /dev/null +++ b/roles/forgejo/templates/forgejo.volume @@ -0,0 +1,2 @@ +[Volume] +VolumeName=forgejo-data