Skip to content

Instantly share code, notes, and snippets.

@jesseloudon
Created November 9, 2020 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesseloudon/57f6bf82e21688291d2fd4f136a0d941 to your computer and use it in GitHub Desktop.
Save jesseloudon/57f6bf82e21688291d2fd4f136a0d941 to your computer and use it in GitHub Desktop.
ansible on azure part 2
variable "vmName" {
type = string
description = "virtual machine name w/ technician's initials as a suffix"
default = "ansibledev-yourinitials"
}
variable "vmSize" {
type = string
description = "virtual machine size"
default = "Standard_B2s"
}
variable "vmAdminName" {
type = string
description = "virtual machine admin name"
default = "ansibleadmin"
}
variable "vmSrcImageReference" {
type = map
description = "virtual machine source image reference"
default = {
"publisher" = "Canonical"
"offer" = "UbuntuServer"
"sku" = "18.04-LTS"
"version" = "latest"
}
}
resource "azurerm_linux_virtual_machine" "vm1" {
name = var.vmName
resource_group_name = azurerm_resource_group.rg1.name
location = azurerm_resource_group.rg1.location
size = var.vmSize
admin_username = var.vmAdminName
network_interface_ids = [
azurerm_network_interface.nic1.id
]
admin_ssh_key {
username = var.vmAdminName
public_key = tls_private_key.vm1key.public_key_openssh
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = var.vmSrcImageReference["publisher"]
offer = var.vmSrcImageReference["offer"]
sku = var.vmSrcImageReference["sku"]
version = var.vmSrcImageReference["version"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment