feat: add user and ssh key to ansible inventory

This commit is contained in:
Ditmar Visser
2025-05-28 12:18:25 +00:00
parent 9b0409c170
commit 0a1505259f
3 changed files with 12 additions and 3 deletions

View File

@@ -69,6 +69,7 @@ data "template_file" "azure_cloudinit" {
template = file("${path.module}/cloudinit-azure.yaml")
vars = {
azure-ssh-key = trimspace(data.azurerm_ssh_public_key.azure.public_key)
azure-user = trimspace(var.azure_user)
}
}
@@ -104,12 +105,15 @@ resource "azurerm_linux_virtual_machine" "main" {
locals {
inventory_content = templatefile("${path.module}/ansible-inventory.tmpl", {
ip = azurerm_linux_virtual_machine.main.public_ip_address })
ip = azurerm_linux_virtual_machine.main.public_ip_address,
user = var.azure_user,
private_key_file = var.azure_private_key_path
})
}
resource "local_file" "ansible_inventory" {
content = local.inventory_content
filename = "${path.module}/inventory.ini"
filename = "${path.module}/../opdracht-2/inventory.ini"
}