Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (51 sloc) 1.75 KB
resource "azurerm_virtual_machine" "virtual_machine_web" {
name = "virtual_machine_web"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.terraform_rg.name}"
network_interface_ids = ["${azurerm_network_interface.terraform_network_interface_web.id}"]
vm_size = "${var.vm_size_web}"
delete_os_disk_on_termination = true
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
storage_os_disk {
name = "osdisk-1"
vhd_uri = "${azurerm_storage_account.terraform_storage.primary_blob_endpoint}${azurerm_storage_container.terraform_storage_container.name}/osdisk-1.vhd"
caching = "ReadWrite"
create_option = "FromImage"
}
os_profile {
computer_name = "web"
admin_username = "${var.vm_username}"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys = [{
path = "/home/${var.vm_username}/.ssh/authorized_keys"
key_data = "${file("/Users/kagarlickij/.ssh/azure_ssh.pub")}"
}]
}
connection {
type = "ssh"
user = "${var.vm_username}"
private_key = "${file("/Users/kagarlickij/.ssh/azure_ssh")}"
agent = true
timeout = "1m"
host = "${azurerm_public_ip.terraform_public_ip_web.fqdn}"
}
provisioner "remote-exec" {
inline = [
"sudo apt-get update -y",
"sudo apt-get install python -y",
]
}
provisioner "local-exec" {
command = "sleep 120; ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u '${var.vm_username}' --private-key /Users/kagarlickij/.ssh/azure_ssh -i '${azurerm_public_ip.terraform_public_ip_web.fqdn},' install_nginx.yml"
}
}
output "ip_address" {
value = "${azurerm_public_ip.terraform_public_ip_web.ip_address}"
}
You can’t perform that action at this time.