Add(module): add girasol module

Add(module): add amap module
Add(module): add common lib and services
Add(module): add base structure for keycloak
Add(module): add base structure for rocket
Add(module): add n8n and windmill modules
Add(docker): add install docker script in common module
Add(template): add root for aldon.fr and mathieu.wiki in traefik.service template
This commit is contained in:
2026-04-21 16:52:41 +02:00
parent 905cc8b43d
commit a56911b896
65 changed files with 1893 additions and 23 deletions

View File

@@ -0,0 +1,22 @@
# Environment files
ENV_FILE_LOCATION=/opt/environment/.env
# gitea act_runner
ACT_RUNNER_VERSION=0.2.13
ACT_RUNNER_LOCATION=/usr/local/bin
ACT_RUNNER_USER=act_runner
GITEA_RUNNER_REGISTRATION_TOKEN=<gitea-repository-runner-token>
USERNAME=girasol
# Gitea instance
GITEA_INSTANCE_URL=https://gitea.aldon.fr
GITEA_SERVICE_APPLICATION_TOKEN=<gitea-auth-token>
GITEA_SERVICE_REPOSITORY=mop/girasol
GITEA_WORKFLOW_NAME=deploy.yaml
# Application specifics
# Backup specifics
SERVICE_BACKUPS_DIR=/backups/girasol
SERVICE_BACKUPS_PREFIX=girasol-dump
SERVICE_BACKUPS_EXTENSION=sql

View File

@@ -0,0 +1,89 @@
#cloud-config
hostname: ${hostname}
local-hostname: ${hostname}
fqdn: ${hostname}.${domain}
manage_etc_hosts: true
users:
- default
- name: ${hostname}
groups: sudo
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- ${ssh_key}
disable_root: true
package_update: true
package_upgrade: false
packages:
- git
- nfs-common
- curl
- jq
mounts:
- [ "192.168.1.12:/main/backups", "/backups", "nfs", "defaults,_netdev,x-systemd.requires=network-online.target", "0", "0" ]
write_files:
- path: /opt/environment/.env
permissions: "0644"
content: |
${env-file-content}
- path: /opt/${hostname}/install-docker.sh
permissions: "0755"
content: |
${install-docker-script}
- path: /usr/local/bin/restore-backup.sh
permissions: "0755"
content: |
${restore-backup-script}
- path: /etc/systemd/system/restore-backup.service
permissions: "0644"
content: |
${restore-backup-service}
- path: /usr/local/bin/backup.sh
permissions: "0755"
content: |
${create-backup-script}
- path: /etc/systemd/system/create-backup.timer
permissions: "0644"
content: |
${create-backup-timer}
- path: /etc/systemd/system/create-backup.service
permissions: "0644"
content: |
${create-backup-service}
- path: /etc/systemd/system/act_runner.service
permissions: "0644"
content: |
${act_runner-service}
- path: /opt/${hostname}/install-runner.sh
permissions: "0755"
content: |
${act_runner-install-script}
- path: /opt/${hostname}/install-service.sh
permissions: "0755"
content: |
${service-install-script}
runcmd:
# Backup setup
- mkdir -p /backups
- mount -t nfs ${proxmox_host_ip}:/main/backups /backups
- systemctl enable --now create-backup.timer
# Docker setup
- /opt/${hostname}/install-docker.sh
# Act_runner install
- /opt/${hostname}/install-runner.sh
- systemctl daemon-reload
- systemctl enable act_runner.service
- systemctl start act_runner.service
# ${hostname} install
- /opt/${hostname}/install-service.sh
final_message: |
Base system ready for ${hostname}

View File

@@ -0,0 +1,7 @@
source /opt/environment/.env
TIMESTAMP=$(date +'%Y-%m-%d_%H%M%S')
# create backup file
ls -1dt $SERVICE_BACKUPS_DIR/$SERVICE_BACKUPS_PREFIX-*.$SERVICE_BACKUPS_EXTENSION | tail -n +5 | xargs -r rm -f

View File

@@ -0,0 +1,5 @@
source /opt/environment/.env
LATEST_BACKUP=$(ls -1 $SERVICE_BACKUPS_DIR/$SERVICE_BACKUPS_PREFIX-*.$SERVICE_BACKUPS_EXTENSION 2>/dev/null | sort | tail -n1)
# Restore backup file

View File

@@ -0,0 +1,41 @@
module "vm" {
source = "../../vm"
name = var.name
hostname = var.hostname
domain = var.domain
vm_id = var.vm_id
node_name = var.node_name
vm_ip_address = var.vm_ip_address
template_id = var.template_id
cores = var.cores
memory = var.memory
disk_size = var.disk_size
ssh_public_key = var.ssh_public_key
proxmox_host_ip = var.proxmox_host_ip
cloudinit_config = templatefile(
"${path.module}/cloud-init/service.yaml",
{
hostname = var.hostname
domain = var.domain
ssh_key = var.ssh_public_key
proxmox_host_ip = var.proxmox_host_ip
restore-backup-script = indent(6, file("${path.module}/lib/scripts/restore-backup.sh"))
restore-backup-service = indent(6, file("${path.module}/../common/services/docker/restore-backup.service"))
create-backup-script = indent(6, file("${path.module}/lib/scripts/create-backup.sh"))
create-backup-service = indent(6, file("${path.module}}/../common/services/docker/create-backup.service"))
create-backup-timer = indent(6, file("${path.module}/../common/services/create-backup.timer"))
act_runner-service = indent(6, file("${path.module}/../common/services/act_runner.service"))
act_runner-install-script = indent(6, file("${path.module}/../common/scripts/install-runner.sh"))
service-install-script = indent(6, file("${path.module}/../common/scripts/install-service-ci.sh"))
install-docker-script = indent(6, file("${path.module}/../common/scripts/install-docker.sh"))
env-file-content = indent(6, file("${path.module}/.env"))
}
)
}

View File

@@ -0,0 +1,9 @@
output "traefik_service" {
value = [{
domain = var.domain
name = var.name
host = "${var.hostname}"
ip = var.vm_ip_address
port = 80
}]
}

View File

@@ -0,0 +1,71 @@
variable "name" {
description = "Virtual Machine name"
type = string
}
variable "vm_id" {
description = "Virtual Machine id"
type = number
}
variable "node_name" {
description = "Proxmox node name"
type = string
default = "mop"
}
variable "cores" {
description = "Number of CPU cores for this virtual machine"
type = number
default = 2
}
variable "memory" {
description = "Memory RAM for this virtual machine"
type = number
default = 2048
}
variable "balloon" {
description = "Minimum vm memory, using ballooning devide to reach Proxmox node memory target."
type = number
default = 1024
}
variable "template_id" {
description = "Virtual machine template ID"
type = number
}
variable "ssh_public_key" {
description = "Public SSH key for cloud-init user"
type = string
}
variable "hostname" {
description = "Virtual Machine hostname (<service-name>)"
type = string
default = "test"
}
variable "domain" {
description = "Virtual Machine domain (example.fr)"
type = string
default = ""
}
variable "disk_size" {
description = "Disk size for the virtual machine"
type = number
default = 10
}
variable "proxmox_host_ip" {
description = "Proxmox host base ip"
type = string
}
variable "vm_ip_address" {
description = "Virtual machine ip"
type = string
}