The commit rephrases the README to focus on Cloud-Init setup and removes unused Ansible code, making Tailscale configuration automatic. Subject line: Replace Ansible with automated Cloud-Init configuration Body: Refactors infrastructure bootstrapping to leverage Cloud-Init instead of Ansible for initial VM setup, particularly with respect to Tailscale installation and authentication. This simplifies the architecture by: - Removing manual post-provisioning Ansible steps - Automating Tailscale setup via Cloud-Init - Updating documentation to reflect new workflow
27 lines
844 B
HCL
27 lines
844 B
HCL
# Fichier: terraform/prod/02-cloud-init.tf
|
|
|
|
resource "proxmox_virtual_environment_file" "cloud_config" {
|
|
for_each = var.virtual_machines
|
|
|
|
node_name = var.target_node
|
|
datastore_id = "local"
|
|
content_type = "snippets"
|
|
|
|
source_raw {
|
|
data = templatefile("${path.module}/../../cloud-init/user-data.yml.tftpl", {
|
|
# Variables pour définir les informations de l'utilisateur
|
|
username = lookup(each.value, "username", var.default_vm_user)
|
|
ssh_key = file(var.admin_ssh_public_key_path)
|
|
|
|
# Variables pour définir les informations de la VM
|
|
hostname = "${each.key}.${var.domain_suffix}"
|
|
|
|
# Nouvelles variables pour Tailscale
|
|
vm_name = each.key # Le nom de la VM (ex: "web-01")
|
|
tailscale_auth_key = var.tailscale_auth_key
|
|
})
|
|
|
|
file_name = "${each.key}-cloud-init.yml"
|
|
}
|
|
}
|