aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/terraform/azure/main.tf
diff options
context:
space:
mode:
authorMaros Mullner <mamullne@cisco.com>2020-02-13 10:57:02 +0100
committerPeter Mikus <pmikus@cisco.com>2020-02-17 08:06:13 +0000
commit6bc0123c235171918a6193b1551ed4d4d82c2fec (patch)
treef21b0f8fa6d3ab765bb7c9acc7b549e1e64acc71 /resources/tools/terraform/azure/main.tf
parent997a634a6658d3d07ff84fc54e156ebd805fec74 (diff)
AWS terraform automation scripts
Change-Id: I050fe466dd006d330d1bb29cc6ccba8ae4681f01 Signed-off-by: Maros Mullner <maros.mullner@pantheon.tech>
Diffstat (limited to 'resources/tools/terraform/azure/main.tf')
-rw-r--r--resources/tools/terraform/azure/main.tf84
1 files changed, 46 insertions, 38 deletions
diff --git a/resources/tools/terraform/azure/main.tf b/resources/tools/terraform/azure/main.tf
index 79fa456d23..cae6591031 100644
--- a/resources/tools/terraform/azure/main.tf
+++ b/resources/tools/terraform/azure/main.tf
@@ -357,13 +357,12 @@ resource "azurerm_virtual_machine" "tg" {
}
os_profile {
computer_name = "tg"
- admin_username = "testuser"
- admin_password = "Csit1234"
+ admin_username = "ubuntu"
}
os_profile_linux_config {
disable_password_authentication = false
ssh_keys {
- path = "/home/testuser/.ssh/authorized_keys"
+ path = "/home/ubuntu/.ssh/authorized_keys"
key_data = file("~/.ssh/id_rsa.pub")
}
}
@@ -396,13 +395,12 @@ resource "azurerm_virtual_machine" "dut1" {
}
os_profile {
computer_name = "dut1"
- admin_username = "testuser"
- admin_password = "Csit1234"
+ admin_username = "ubuntu"
}
os_profile_linux_config {
disable_password_authentication = false
ssh_keys {
- path = "/home/testuser/.ssh/authorized_keys"
+ path = "/home/ubuntu/.ssh/authorized_keys"
key_data = file("~/.ssh/id_rsa.pub")
}
}
@@ -435,13 +433,12 @@ resource "azurerm_virtual_machine" "dut2" {
}
os_profile {
computer_name = "dut2"
- admin_username = "testuser"
- admin_password = "Csit1234"
+ admin_username = "ubuntu"
}
os_profile_linux_config {
disable_password_authentication = false
ssh_keys {
- path = "/home/testuser/.ssh/authorized_keys"
+ path = "/home/ubuntu/.ssh/authorized_keys"
key_data = file("~/.ssh/id_rsa.pub")
}
}
@@ -474,8 +471,9 @@ resource "null_resource" "deploy_tg" {
azurerm_network_interface.tg_if1,
azurerm_network_interface.tg_if2 ]
connection {
- user = "testuser"
+ user = "ubuntu"
host = data.azurerm_public_ip.tg_public_ip.ip_address
+ private_key = file("~/.ssh/id_rsa")
}
provisioner "ansible" {
plays {
@@ -485,17 +483,8 @@ resource "null_resource" "deploy_tg" {
}
hosts = ["tg"]
extra_vars = {
- ansible_python_interpreter = "python3"
+ ansible_python_interpreter = "/usr/bin/python3"
azure = true
- remote_net = var.vpc_cidr_d
- tg_if1_mac = azurerm_network_interface.tg_if1.mac_address
- tg_if2_mac = azurerm_network_interface.tg_if2.mac_address
- dut1_if1_mac = azurerm_network_interface.dut1_if1.mac_address
- dut1_if2_mac = azurerm_network_interface.dut1_if2.mac_address
- dut2_if1_mac = azurerm_network_interface.dut2_if1.mac_address
- dut2_if2_mac = azurerm_network_interface.dut2_if2.mac_address
- dut1_if1_ip = azurerm_network_interface.dut1_if1.private_ip_address
- dut2_if2_ip = azurerm_network_interface.dut2_if2.private_ip_address
}
}
}
@@ -506,8 +495,9 @@ resource "null_resource" "deploy_dut1" {
azurerm_network_interface.dut1_if1,
azurerm_network_interface.dut1_if2 ]
connection {
- user = "testuser"
+ user = "ubuntu"
host = data.azurerm_public_ip.dut1_public_ip.ip_address
+ private_key = file("~/.ssh/id_rsa")
}
provisioner "ansible" {
plays {
@@ -517,16 +507,8 @@ resource "null_resource" "deploy_dut1" {
}
hosts = ["sut"]
extra_vars = {
- ansible_python_interpreter = "python3"
+ ansible_python_interpreter = "/usr/bin/python3"
azure = true
- dut1_if1_ip = azurerm_network_interface.dut1_if1.private_ip_address
- dut1_if1_mac = azurerm_network_interface.dut1_if1.mac_address
- dut1_if2_ip = azurerm_network_interface.dut1_if2.private_ip_address
- dut1_if2_mac = azurerm_network_interface.dut1_if2.mac_address
- dut2_if2_ip = azurerm_network_interface.dut2_if1.private_ip_address
- dut2_if1_gateway = azurerm_network_interface.dut2_if1.private_ip_address
- traffic_if1 = var.trex_dummy_cidr_port_0
- traffic_if2 = var.trex_dummy_cidr_port_1
}
}
}
@@ -537,8 +519,9 @@ resource "null_resource" "deploy_dut2" {
azurerm_network_interface.dut2_if1,
azurerm_network_interface.dut2_if2 ]
connection {
- user = "testuser"
+ user = "ubuntu"
host = data.azurerm_public_ip.dut2_public_ip.ip_address
+ private_key = file("~/.ssh/id_rsa")
}
provisioner "ansible" {
plays {
@@ -548,16 +531,41 @@ resource "null_resource" "deploy_dut2" {
}
hosts = ["sut"]
extra_vars = {
- ansible_python_interpreter = "python3"
+ ansible_python_interpreter = "/usr/bin/python3"
azure = true
- dut2_if1_ip = azurerm_network_interface.dut2_if1.private_ip_address
+ }
+ }
+ }
+}
+
+eesource "null_resource" "deploy_topology" {
+ depends_on = [ azurerm_virtual_machine.tg,
+ azurerm_network_interface.tg_if1,
+ azurerm_network_interface.tg_if2,
+ azurerm_virtual_machine.dut1,
+ azurerm_network_interface.dut1_if1,
+ azurerm_network_interface.dut1_if2
+ azurerm_virtual_machine.dut2,
+ azurerm_network_interface.dut2_if1,
+ azurerm_network_interface.dut2_if2 ]
+ provisioner "ansible" {
+ plays {
+ playbook {
+ file_path = "../../testbed-setup/ansible/cloud_topology.yaml"
+ }
+ hosts = ["local"]
+ extra_vars = {
+ ansible_python_interpreter = "/usr/bin/python3"
+ cloud_topology = "azure"
+ tg_if1_mac = azurerm_network_interface.tg_if1.mac_address
+ tg_if2_mac = azurerm_network_interface.tg_if2.mac_address
+ dut1_if1_mac = azurerm_network_interface.dut1_if1.mac_address
+ dut1_if2_mac = azurerm_network_interface.dut1_if2.mac_address
dut2_if1_mac = azurerm_network_interface.dut2_if1.mac_address
- dut2_if2_ip = azurerm_network_interface.dut2_if2.private_ip_address
dut2_if2_mac = azurerm_network_interface.dut2_if2.mac_address
- dut1_if2_ip = azurerm_network_interface.dut1_if2.private_ip_address
- dut1_if2_gateway = azurerm_network_interface.dut1_if2.private_ip_address
- traffic_if1 = var.trex_dummy_cidr_port_0
- traffic_if2 = var.trex_dummy_cidr_port_1
+ tg_public_ip = data.azurerm_public_ip.tg_public_ip.ip_address
+ dut1_public_ip = data.azurerm_public_ip.dut1_public_ip.ip_address
+ dut2_public_ip = data.azurerm_public_ip.dut2_public_ip.ip_address
}
}
}