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