Compare commits
2
Commits
main
..
ovh-classic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14241d4e18 | ||
|
|
dd0351ad49 |
@@ -8,7 +8,6 @@
|
||||
|
||||
# Ansible
|
||||
ansible/inventory.ini
|
||||
.vault_pass
|
||||
|
||||
# Private Keys & Secrets
|
||||
*.pem
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[defaults]
|
||||
inventory = inventory.ini
|
||||
vault_password_file = .vault_pass
|
||||
host_key_checking = False
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
ansible_user: "debian"
|
||||
|
||||
sysadmin_user: "alessandrovitali"
|
||||
sysadmin_public_ssh_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAm/J+9YG+odym9In9C4iLcrfXlrlPK2TygtI7lBNNpl"
|
||||
@@ -1,9 +0,0 @@
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
65353035363835666333386634353332383639633462326134656533366434373363333636613938
|
||||
3163306136623962346363373030643330343364333139360a376334666363396337613631303663
|
||||
34376561376439353863646561616134636230366435653431643633313130356665313163663136
|
||||
3837396262376433350a646430383332633931383561383939336561616235336232623665316537
|
||||
37353537303138646630393733626262653362636661613336336565636162343835386265343262
|
||||
66323466616364306363313638633630343766313065646135336138396639343536326162393562
|
||||
34303234653937393637643031643066383537363632383663303062303230613135363336326135
|
||||
63366363353663366137
|
||||
@@ -1,3 +0,0 @@
|
||||
coolify_root_username: "alessandrovitali"
|
||||
coolify_root_user_email: "[email protected]"
|
||||
coolify_root_user_password: "{{ vault_coolify_admin_password }}"
|
||||
@@ -1,2 +0,0 @@
|
||||
[coolify]
|
||||
coolify ansible_host=${public_ip}
|
||||
@@ -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
|
||||
@@ -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
@@ -1,61 +1,40 @@
|
||||
# Gather facts
|
||||
data "ovh_cloud_instance_flavors" "flavors" {
|
||||
service_name = var.ovh_service_name
|
||||
region = var.ovh_region
|
||||
# Fetch billing subsidiary details from your OVH account profile
|
||||
data "ovh_me" "myaccount" {}
|
||||
|
||||
# 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
|
||||
resource "local_file" "ansible_inventory" {
|
||||
content = templatefile("${path.module}/../ansible/inventory.tpl", {
|
||||
public_ip = local.public_ip
|
||||
})
|
||||
filename = "${path.module}/../ansible/inventory.ini"
|
||||
# The public IP of a classic VPS must be retrieved via a data source after delivery
|
||||
data "ovh_vps" "vps_1" {
|
||||
service_name = ovh_vps.vps_1.service_name
|
||||
}
|
||||
|
||||
output "public_ip" {
|
||||
description = "The public IPv4 address of the provisioned OVHcloud VM"
|
||||
value = local.public_ip
|
||||
output "vps_public_ip" {
|
||||
value = tolist(data.ovh_vps.vps_1.ips)[0]
|
||||
description = "The public IP address of VPS-1"
|
||||
}
|
||||
|
||||
@@ -3,11 +3,7 @@ terraform {
|
||||
required_providers {
|
||||
ovh = {
|
||||
source = "ovh/ovh"
|
||||
version = "~> 2.19.0"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = "~> 2.9.0"
|
||||
version = ">= 2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-27
@@ -1,11 +1,6 @@
|
||||
variable "project_name" {
|
||||
type = string
|
||||
description = "VM name"
|
||||
}
|
||||
|
||||
variable "ovh_endpoint" {
|
||||
type = string
|
||||
description = "OVH API endpoint"
|
||||
description = "The OVH API endpoint"
|
||||
default = "ovh-eu"
|
||||
}
|
||||
|
||||
@@ -24,30 +19,12 @@ variable "ovh_consumer_key" {
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "ovh_service_name" {
|
||||
variable "ovh_project_id" {
|
||||
type = string
|
||||
description = "OVHcloud Public Cloud Project ID"
|
||||
}
|
||||
|
||||
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"
|
||||
description = "The OVH Public Cloud Project ID (Service Name)"
|
||||
}
|
||||
|
||||
variable "ssh_public_key" {
|
||||
type = string
|
||||
description = "Public SSH key to install on the VM"
|
||||
description = "The public SSH key to install on the VM"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user