Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. resource "azurerm_virtual_machine" "proxy_machine" {
  2. count = "${var.proxy_vm_count}"
  3. resource_group_name = "${azurerm_resource_group.resource_group.name}"
  4. name = "${var.prefix}-proxy-machine${count.index}-${var.suffix}"
  5. location = "${var.location}"
  6. availability_set_id = "${azurerm_availability_set.proxy.id}"
  7.  
  8. network_interface_ids = [
  9. "${element(azurerm_network_interface.proxy_network_interface.*.id, count.index)}"
  10. ]
  11.  
  12. primary_network_interface_id = "${element(azurerm_network_interface.proxy_network_interface.*.id, count.index)}"
  13.  
  14. storage_image_reference {
  15. publisher = "OpenLogic"
  16. offer = "CentOS"
  17. sku = "7.3"
  18. version = "latest"
  19. }
  20.  
  21. storage_os_disk {
  22. name = "${var.prefix}-proxy-disk${count.index}-${var.suffix}"
  23. 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"
  24. caching = "ReadWrite"
  25. create_option = "FromImage"
  26. os_type = "linux"
  27. }
  28.  
  29. delete_os_disk_on_termination = true
  30.  
  31. vm_size = "Standard_DS1"
  32.  
  33. os_profile {
  34. computer_name = "${var.vm_hostname}"
  35. admin_username = "${var.vm_admin_username}"
  36. admin_password = "${var.vm_admin_password}"
  37. }
  38.  
  39. os_profile_linux_config {
  40. disable_password_authentication = true
  41.  
  42. ssh_keys {
  43. path = "/home/${var.vm_admin_username}/.ssh/authorized_keys"
  44. key_data = "${var.vm_admin_public_key}"
  45.  
  46. }
  47. }
  48.  
  49. provisioner "remote-exec" {
  50. inline = [
  51. "sudo su",
  52. "systemctl stop firewalld",
  53. "systemctl mask firewalld",
  54. "yum -y install iptables-services",
  55. "systemctl enable iptables",
  56. "echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf",
  57. "sysctl -w net.ipv4.ip_forward=1",
  58. "sysctl -p",
  59. "iptables -X",
  60. "iptables -F",
  61. "iptables -t nat -X",
  62. "iptables -t nat -F",
  63. "iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE",
  64. "service iptables save"
  65. ]
  66. connection {
  67. private_key = "${file(var.vm_admin_private_key)}"
  68. user = "${var.vm_admin_username}"
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement