2 Commits
Author SHA1 Message Date
alessandrovitali 14241d4e18 fix(tf): add required_version 2026-08-13 13:44:50 +02:00
alessandrovitali dd0351ad49 feat: terraform configuration for classic VPS 2026-08-13 13:23:05 +02:00
11 changed files with 36 additions and 124 deletions
-1
View File
@@ -8,7 +8,6 @@
# Ansible # Ansible
ansible/inventory.ini ansible/inventory.ini
.vault_pass
# Private Keys & Secrets # Private Keys & Secrets
*.pem *.pem
-4
View File
@@ -1,4 +0,0 @@
[defaults]
inventory = inventory.ini
vault_password_file = .vault_pass
host_key_checking = False
-5
View File
@@ -1,5 +0,0 @@
---
ansible_user: "debian"
sysadmin_user: "alessandrovitali"
sysadmin_public_ssh_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAm/J+9YG+odym9In9C4iLcrfXlrlPK2TygtI7lBNNpl"
-9
View File
@@ -1,9 +0,0 @@
$ANSIBLE_VAULT;1.1;AES256
65353035363835666333386634353332383639633462326134656533366434373363333636613938
3163306136623962346363373030643330343364333139360a376334666363396337613631303663
34376561376439353863646561616134636230366435653431643633313130356665313163663136
3837396262376433350a646430383332633931383561383939336561616235336232623665316537
37353537303138646630393733626262653362636661613336336565636162343835386265343262
66323466616364306363313638633630343766313065646135336138396639343536326162393562
34303234653937393637643031643066383537363632383663303062303230613135363336326135
63366363353663366137
-3
View File
@@ -1,3 +0,0 @@
coolify_root_username: "alessandrovitali"
coolify_root_user_email: "[email protected]"
coolify_root_user_password: "{{ vault_coolify_admin_password }}"
-2
View File
@@ -1,2 +0,0 @@
[coolify]
coolify ansible_host=${public_ip}
-9
View File
@@ -1,9 +0,0 @@
## ansible/setup.yml
- name: Setup coolify machine
hosts: all
roles:
- role: studio.ansible.base
- role: studio.ansible.users
- role: studio.ansible.security
- role: studio.ansible.coolify
-7
View File
@@ -1,7 +0,0 @@
## ansible/requirements.yml
collections:
- name: studio.ansible
source: https://git.studiovita.li/studio/ansible.git ## HTTPS
type: git
version: feat/coolify
+31 -52
View File
@@ -1,61 +1,40 @@
# Gather facts # Fetch billing subsidiary details from your OVH account profile
data "ovh_cloud_instance_flavors" "flavors" { data "ovh_me" "myaccount" {}
service_name = var.ovh_service_name
region = var.ovh_region # Provision the Classic VPS
resource "ovh_vps" "vps_1" {
display_name = "coolify"
ovh_subsidiary = data.ovh_me.myaccount.ovh_subsidiary # Country of billing entity (e.g. "CH", "DE")
plan = [
{
duration = "P1M" # Monthly subscription ("P1M")
plan_code = "vps-le-2-2-40" # Starter plan model (Adjust depending on current catalog)
pricing_mode = "default"
# Datacenter configuration
configuration = [
{
label = "vps_datacenter"
value = "LIM" # Limburg (DE)
},
{
label = "vps_os"
value = "ubuntu-22.04"
} }
data "ovh_cloud_instance_images" "images" {
service_name = var.ovh_service_name
region = var.ovh_region
}
resource "ovh_cloud_ssh_key" "ansible" {
service_name = var.ovh_service_name
name = "ansible-key"
public_key = var.ssh_public_key
}
# Provision a d2-2 Public Cloud instance
resource "ovh_cloud_instance" "coolify" {
service_name = var.ovh_service_name
region = var.ovh_region
name = var.project_name
ssh_key_name = ovh_cloud_ssh_key.ansible.name
flavor_id = one([
for flavor in data.ovh_cloud_instance_flavors.flavors.flavors :
flavor.id if flavor.name == var.ovh_flavor_name
])
image_id = one([
for image in data.ovh_cloud_instance_images.images.images :
image.id if image.name == var.image_name
])
networks = [
{ auto_assign_public_ip = true },
] ]
} }
# Fetch provisioned VM's public IPv4
locals {
public_ip = one(flatten([
for net in ovh_cloud_instance.coolify.current_state.networks : [
for addr in net.addresses : addr.ip
if addr.type == "FIXED" && addr.version == 4
] ]
]))
public_ssh_key = var.ssh_public_key
} }
# Write IP to Ansible inventory # The public IP of a classic VPS must be retrieved via a data source after delivery
resource "local_file" "ansible_inventory" { data "ovh_vps" "vps_1" {
content = templatefile("${path.module}/../ansible/inventory.tpl", { service_name = ovh_vps.vps_1.service_name
public_ip = local.public_ip
})
filename = "${path.module}/../ansible/inventory.ini"
} }
output "public_ip" { output "vps_public_ip" {
description = "The public IPv4 address of the provisioned OVHcloud VM" value = tolist(data.ovh_vps.vps_1.ips)[0]
value = local.public_ip description = "The public IP address of VPS-1"
} }
+1 -5
View File
@@ -3,11 +3,7 @@ terraform {
required_providers { required_providers {
ovh = { ovh = {
source = "ovh/ovh" source = "ovh/ovh"
version = "~> 2.19.0" version = ">= 2.0.0"
}
local = {
source = "hashicorp/local"
version = "~> 2.9.0"
} }
} }
} }
+4 -27
View File
@@ -1,11 +1,6 @@
variable "project_name" {
type = string
description = "VM name"
}
variable "ovh_endpoint" { variable "ovh_endpoint" {
type = string type = string
description = "OVH API endpoint" description = "The OVH API endpoint"
default = "ovh-eu" default = "ovh-eu"
} }
@@ -24,30 +19,12 @@ variable "ovh_consumer_key" {
sensitive = true sensitive = true
} }
variable "ovh_service_name" { variable "ovh_project_id" {
type = string type = string
description = "OVHcloud Public Cloud Project ID" description = "The OVH Public Cloud Project ID (Service Name)"
}
variable "ovh_region" {
type = string
description = "OVHcloud region code"
default = "DE1" # Frankfurt, Germany
}
variable "ovh_flavor_name" {
type = string
description = "VM flavor name"
default = "d2-2"
}
variable "image_name" {
type = string
description = "OS distribution image name to boot the VM from"
default = "Debian 13"
} }
variable "ssh_public_key" { variable "ssh_public_key" {
type = string type = string
description = "Public SSH key to install on the VM" description = "The public SSH key to install on the VM"
} }