diff --git a/opdracht-1/ansible-inventory.tmpl b/opdracht-1/ansible-inventory.tmpl index 794cd6c..25085e9 100644 --- a/opdracht-1/ansible-inventory.tmpl +++ b/opdracht-1/ansible-inventory.tmpl @@ -1,2 +1,2 @@ [all] -vm ansible_host=${ip} +vm ansible_host=${ip} ansible_user=${user} ansible_ssh_private_key_file=${private_key_file} \ No newline at end of file diff --git a/opdracht-1/main.tf b/opdracht-1/main.tf index 308dab3..a249713 100644 --- a/opdracht-1/main.tf +++ b/opdracht-1/main.tf @@ -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" } diff --git a/opdracht-1/variables.tf b/opdracht-1/variables.tf index ac86407..07d9677 100644 --- a/opdracht-1/variables.tf +++ b/opdracht-1/variables.tf @@ -35,6 +35,11 @@ variable "azure_location" { default = "westeurope" } +variable "azure_user" { + description = "User that will gain access to the Azure vm's" + default = "iac" +} + variable "prefix" { description = "The Prefix used for all resources" default = "week-3-opdracht-1"