feat: add user and ssh key to ansible inventory
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
[all]
|
||||
vm ansible_host=${ip}
|
||||
vm ansible_host=${ip} ansible_user=${user} ansible_ssh_private_key_file=${private_key_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"
|
||||
}
|
||||
|
||||
|
||||
|
@ -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"
|
||||
|
Reference in New Issue
Block a user