on espere ca va marcher

This commit is contained in:
2025-12-03 15:22:51 +01:00
parent e67b5bf03c
commit 370e3e3aa2
12 changed files with 419 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
# Provider Google
provider "google" {
project = var.project_id
region = var.region
zone = var.zone
}
# Module IAM
module "iam" {
source = "../../modules/iam"
project_id = var.project_id
}
# Module Compute
module "compute" {
source = "../../modules/compute"
instance_type = var.instance_type
zone = var.zone
frontend_subnet_id = var.frontend_subnet_id
backend_subnet_id = var.backend_subnet_id
database_subnet_id = var.database_subnet_id
}
# Exemple de création d'un template pour Ansible
data "template_file" "ansible_inventory" {
template = <<EOT
[frontend]
${module.compute.frontend_internal_ip} ansible_user=YOUR_SSH_USER
[backend]
${module.compute.backend_internal_ip} ansible_user=YOUR_SSH_USER
[database]
${module.compute.database_internal_ip} ansible_user=YOUR_SSH_USER
EOT
}
# Optionnel : écrire le fichier sur le disque
resource "local_file" "ansible_inventory" {
content = data.template_file.ansible_inventory.rendered
filename = "${path.module}/inventory.ini"
}