feat: add user and ssh key to ansible inventory
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user