Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- resource "azurerm_virtual_machine" "proxy_machine" {
- count = "${var.proxy_vm_count}"
- resource_group_name = "${azurerm_resource_group.resource_group.name}"
- name = "${var.prefix}-proxy-machine${count.index}-${var.suffix}"
- location = "${var.location}"
- availability_set_id = "${azurerm_availability_set.proxy.id}"
- network_interface_ids = [
- "${element(azurerm_network_interface.proxy_network_interface.*.id, count.index)}"
- ]
- primary_network_interface_id = "${element(azurerm_network_interface.proxy_network_interface.*.id, count.index)}"
- storage_image_reference {
- publisher = "OpenLogic"
- offer = "CentOS"
- sku = "7.3"
- version = "latest"
- }
- storage_os_disk {
- name = "${var.prefix}-proxy-disk${count.index}-${var.suffix}"
- vhd_uri = "${element(azurerm_storage_account.proxy_storage_account.*.primary_blob_endpoint, count.index)}${element(azurerm_storage_container.proxy_storage_container.*.name, count.index)}/proxydisk.vhd"
- caching = "ReadWrite"
- create_option = "FromImage"
- os_type = "linux"
- }
- delete_os_disk_on_termination = true
- vm_size = "Standard_DS1"
- os_profile {
- computer_name = "${var.vm_hostname}"
- admin_username = "${var.vm_admin_username}"
- admin_password = "${var.vm_admin_password}"
- }
- os_profile_linux_config {
- disable_password_authentication = true
- ssh_keys {
- path = "/home/${var.vm_admin_username}/.ssh/authorized_keys"
- key_data = "${var.vm_admin_public_key}"
- }
- }
- provisioner "remote-exec" {
- inline = [
- "sudo su",
- "systemctl stop firewalld",
- "systemctl mask firewalld",
- "yum -y install iptables-services",
- "systemctl enable iptables",
- "echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf",
- "sysctl -w net.ipv4.ip_forward=1",
- "sysctl -p",
- "iptables -X",
- "iptables -F",
- "iptables -t nat -X",
- "iptables -t nat -F",
- "iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE",
- "service iptables save"
- ]
- connection {
- private_key = "${file(var.vm_admin_private_key)}"
- user = "${var.vm_admin_username}"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement