Infrastructure as Code to create and maintain the Forgejo.dev instance https://forgejo.dev
Find a file
2024-10-11 16:28:46 +02:00
doc Adds documentation draft on how to manually update from Debian 11 to 12 2024-07-21 11:38:46 +02:00
inventory Updates Forgejo to v8.0.3 2024-09-09 18:47:52 +02:00
roles Updates Minio to 2024-10-02 release 2024-10-11 16:28:46 +02:00
s3-migration Fixes s3 playbook + adds notice to run migration directly on the servers 2023-03-29 07:31:15 +02:00
scripts Updates user email notifications preference to 'onmention' 2024-07-16 20:48:37 +02:00
vars Updates restic to v0.16.4 2024-02-07 07:11:49 +01:00
.ansible-lint Init from development repo 2023-01-15 16:52:26 +01:00
.gitignore Fixes s3 playbook + adds notice to run migration directly on the servers 2023-03-29 07:31:15 +02:00
ansible.cfg Adapts Ansible config + Docker installation repository 2024-07-21 10:34:34 +02:00
backup.yaml Adds restic role to create an automatic daily backup 2023-02-11 15:59:19 +01:00
firewall.tf Introduces the Terraform config for the Hetzner cloud firewall 2023-04-06 11:23:26 +02:00
forgejo-prod.yaml Init from development repo 2023-01-15 16:52:26 +01:00
forgejo-staging.yaml Init from development repo 2023-01-15 16:52:26 +01:00
infra.yaml Adds UFW Docker workaround + allows default ports to any 2024-04-21 10:50:29 +02:00
LICENSE Init from development repo 2023-01-15 16:52:26 +01:00
main.tf Adapts terraform configs 2024-07-21 10:34:05 +02:00
monitoring.yaml Init from development repo 2023-01-15 16:52:26 +01:00
playbook.yaml Adds restic role to create an automatic daily backup 2023-02-11 15:59:19 +01:00
README.md Fixes the broken woodpecker documentation URL in README.md 2024-07-21 11:24:18 +02:00
requirements.yml Ansible role ansible: disables installation of Docker packages via pip 2024-07-21 12:45:38 +02:00
s3-mig.tf Split main Terraform file up into multiple parts 2023-04-06 10:45:09 +02:00
s3-mig.yaml Adds the migration playbook (to only deploy Minio at the temp server) 2023-03-28 17:26:45 +02:00
s3.yaml Fixes s3 playbook + adds notice to run migration directly on the servers 2023-03-29 07:31:15 +02:00
secrets.tfvars.example Init from development repo 2023-01-15 16:52:26 +01:00
ssh.yaml Fixes a typo in SSH playbook 2023-04-06 10:15:24 +02:00
staging.tf Adapts terraform configs 2024-07-21 10:34:05 +02:00
user_data.yml.tpl Init from development repo 2023-01-15 16:52:26 +01:00
utils.tf Updates Hetzner Terraform provider to v1.48.1 2024-09-09 18:48:18 +02:00

Forgejo DevOps

Automation to create/configure the infrastructure for all services related to forgejo.dev.

Setup (client/workstation)

  • Install all dependencies:
  • Create a Hetzner Cloud project
    • Create an access token
    • Add the SSH fingerprint to the project
  • Copy secrets.tfvars.example to secrets.tfvars
    • Replace the dummy values with the real ones
  • Copy vars/smtp.yml.example to vars/smtp.yml
    • Replace the dummy values with the real ones
  • Copy vars/woodpecker.yml.example to vars/woodpecker_staging.yml and vars/woodpecker_production.yml
    • Replace the dummy values with the real ones (values are only available after the manual creation of an OAuth2 app)
  • Copy vars/minio.yml.example to vars/minio.yml
    • Replace the dummy values with the real ones
  • Copy vars/backup.yml.example to vars/backup.yml
    • Replace the dummy values with the real ones

Terraform

Terraform is used to create the infrastructure (VMs) and run a basic provisioning script to install all dependencies for Ansible.

  • To create the infrastructure, run:
    • $ terraform init
    • $ terraform plan -var-file="secrets.tfvars"
    • $ terraform apply -var-file="secrets.tfvars"
  • To destroy the infrastructure, run:
    • $ terraform destroy -var-file="secrets.tfvars"

Staging

  • To create the infrastructure, run:
    • $ terraform plan -var-file="secrets.tfvars" -target=hcloud_server.staging
    • $ terraform apply -var-file="secrets.tfvars" -target=hcloud_server.staging
  • To destroy the infrastructure, run:
    • $ terraform destroy -var-file="secrets.tfvars" -target=hcloud_server.staging

Ansible

Ansible is used to configure the VMs and create/configure all necessary services.

  • To create/configure/update all services on the VMs, simply run:
    • $ export ANSIBLE_CONFIG=./ansible.cfg
    • $ ansible-galaxy install -r requirements.yml
    • $ ansible-playbook playbook.yml

Staging

  • To create/configure/update all services only on the staging VM, run:
    • $ export ANSIBLE_CONFIG=./ansible.cfg
    • $ ansible-galaxy install -r requirements.yml
    • $ ansible-playbook playbook.yaml --limit staging

Ansible Lint

  • Installation: $ pip3 install ansible-lint
  • Usage: $ ansible-lint --offline -p ./*.yml

Manual Steps

Unfortunately, there are currently some manual steps required to complete the initial configuration.

  • Go to the webpage and finish the Forgejo installation including the creation of a root user.
    • Login as root + change the profile picture.
  • Add an OAuth2 application for Woodpecker CI
    • Register the tokens within the Woodpecker config and run the Ansible playbook again.
  • Create the organisation staging.forgejo.dev/forgejo.dev.
    • Set the correct profile picture.
  • Create the org repository in the organisation.
    • Set the correct profile picture.
  • Create user(s) and invite them to the organization.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for more details.