Compare commits
8
Commits
ovh-classic
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18d076fefd | ||
|
|
40dc6a945f | ||
|
|
e4e45755a9 | ||
|
|
d7fc8d2531 | ||
|
|
116f2777a1 | ||
|
|
8255ac97e2 | ||
|
|
21bcd4ab41 | ||
|
|
614a529af5 |
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
# Ansible
|
# Ansible
|
||||||
ansible/inventory.ini
|
ansible/inventory.ini
|
||||||
|
.vault_pass
|
||||||
|
|
||||||
# Private Keys & Secrets
|
# Private Keys & Secrets
|
||||||
*.pem
|
*.pem
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = inventory.ini
|
||||||
|
vault_password_file = .vault_pass
|
||||||
|
host_key_checking = False
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
ansible_user: "debian"
|
||||||
|
|
||||||
|
sysadmin_user: "alessandrovitali"
|
||||||
|
sysadmin_public_ssh_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAm/J+9YG+odym9In9C4iLcrfXlrlPK2TygtI7lBNNpl"
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
|
65353035363835666333386634353332383639633462326134656533366434373363333636613938
|
||||||
|
3163306136623962346363373030643330343364333139360a376334666363396337613631303663
|
||||||
|
34376561376439353863646561616134636230366435653431643633313130356665313163663136
|
||||||
|
3837396262376433350a646430383332633931383561383939336561616235336232623665316537
|
||||||
|
37353537303138646630393733626262653362636661613336336565636162343835386265343262
|
||||||
|
66323466616364306363313638633630343766313065646135336138396639343536326162393562
|
||||||
|
34303234653937393637643031643066383537363632383663303062303230613135363336326135
|
||||||
|
63366363353663366137
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
coolify_root_username: "alessandrovitali"
|
||||||
|
coolify_root_user_email: "[email protected]"
|
||||||
|
coolify_root_user_password: "{{ vault_coolify_admin_password }}"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[coolify]
|
||||||
|
coolify ansible_host=${public_ip}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
## 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
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
## ansible/requirements.yml
|
||||||
|
|
||||||
|
collections:
|
||||||
|
- name: studio.ansible
|
||||||
|
source: https://git.studiovita.li/studio/ansible.git ## HTTPS
|
||||||
|
type: git
|
||||||
|
version: feat/coolify
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# Gather facts
|
||||||
|
data "ovh_cloud_instance_flavors" "flavors" {
|
||||||
|
service_name = var.ovh_service_name
|
||||||
|
region = var.ovh_region
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
]
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "public_ip" {
|
||||||
|
description = "The public IPv4 address of the provisioned OVHcloud VM"
|
||||||
|
value = local.public_ip
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.0.0"
|
||||||
|
required_providers {
|
||||||
|
ovh = {
|
||||||
|
source = "ovh/ovh"
|
||||||
|
version = "~> 2.19.0"
|
||||||
|
}
|
||||||
|
local = {
|
||||||
|
source = "hashicorp/local"
|
||||||
|
version = "~> 2.9.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "ovh" {
|
||||||
|
endpoint = var.ovh_endpoint
|
||||||
|
application_key = var.ovh_application_key
|
||||||
|
application_secret = var.ovh_application_secret
|
||||||
|
consumer_key = var.ovh_consumer_key
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
variable "project_name" {
|
||||||
|
type = string
|
||||||
|
description = "VM name"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ovh_endpoint" {
|
||||||
|
type = string
|
||||||
|
description = "OVH API endpoint"
|
||||||
|
default = "ovh-eu"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ovh_application_key" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ovh_application_secret" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ovh_consumer_key" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ovh_service_name" {
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ssh_public_key" {
|
||||||
|
type = string
|
||||||
|
description = "Public SSH key to install on the VM"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user