Hybrid and Multi-Cloud Overlay — Part 4— Challenges — Terraform, Ansible, Packer and vSphere

sudo ovs-vsctl set bridge l2-br stp_enable=true
"vmx_data": {
"ethernet0.networkName": "backend",
"ethernet1.networkName": "{{user `ESXI_MGMT_PG`}}",
"ethernet0.present": "TRUE",
"ethernet0.startConnected": "TRUE",
"ethernet0.virtualDev": "e1000",
"ethernet0.addressType": "generated",
"ethernet0.generatedAddressOffset": "0",
"ethernet0.wakeOnPcktRcv": "FALSE",
"ethernet1.present": "TRUE",
"ethernet1.startConnected": "TRUE",
"ethernet1.virtualDev": "e1000",
"ethernet1.addressType": "static",
"ethernet1.address": "{{user `VSPHERE_ROUTER_FRONT_INTF_MAC`}}",
"ethernet1.generatedAddressOffset": "1",
"ethernet1.wakeOnPcktRcv": "FALSE"
}
"provisioners": [  
{
"type": "shell",
"inline": [
"ifconfig | sed -e '0,/RUNNING/d' | sed -ne 's/.*inet \\(.*\\) netmask.*/\\1/gp' | sed -n '1p' >> {{user `ESXI_CLIENT1_NAME`}}.txt"
],
"execute_command": "sudo -E -S bash '{{ .Path }}'",
"only": ["{{user `ESXI_CLIENT1_NAME`}}"]
},
{
"type": "file",
"source": "{{user `ESXI_CLIENT1_NAME`}}.txt",
"destination": "{{user `ESXI_CLIENT1_NAME`}}.txt",
"direction" : "download",
"only": ["{{user `ESXI_CLIENT1_NAME`}}"]
}
]
"keep_registered": "true"
resource "null_resource" "poweron" {
depends_on = [vsphere_host_port_group.backend]
connection {
type = "ssh"
user = var.VSPHERE_USER
password = var.VSPHERE_PASSWORD
host = var.ESXI_HOST
}
provisioner "remote-exec" {
inline = [
"vim-cmd vmsvc/power.on $(vim-cmd vmsvc/getallvms | grep ${var.ESXI_ROUTER_NAME} | awk '{print $1}')",
"vim-cmd vmsvc/power.on $(vim-cmd vmsvc/getallvms | grep ${var.ESXI_CLIENT1_NAME} | awk '{print $1}')",
"echo ${var.VM_SSH_KEY_FILE} >> test",
]
}
}
- name: PowerOff Router
ignore_errors: yes
shell:
vim-cmd vmsvc/power.off $(vim-cmd vmsvc/getallvms | grep {{ESXI_ROUTER_NAME}} | awk '{print $1}')

- name: PowerOff Client1
ignore_errors: yes
shell:
vim-cmd vmsvc/power.off $(vim-cmd vmsvc/getallvms | grep {{ESXI_CLIENT1_NAME}} | awk '{print $1}')

- name: Destroy Router
ignore_errors: yes
shell:
vim-cmd vmsvc/destroy $(vim-cmd vmsvc/getallvms | grep {{ESXI_ROUTER_NAME}} | awk '{print $1}')
- name: Destroy Client1
ignore_errors: yes
shell:
vim-cmd vmsvc/destroy $(vim-cmd vmsvc/getallvms | grep {{ESXI_CLIENT1_NAME}} | awk '{print $1}')
Part 4 — Video blog

--

--

--

Freelancer with 16 years of experience in Hybrid & multi-cloud, security, networking & Infrastructure. Working with C-level execs. Founder zerolatency.solutions

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Accident Lawyer Sandy Utah

accident lawyer sandy utah

Important notice of space race

Forecast Weather using Python

Clean your code beyond code clean!

What a hell is programming?

GrowthBook 1.1.0 — Android SDK, UI Improvements, and more

Vonage API Q4 Releases — a Look Back

Build your own API Gateway from scratch

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ramesh Rajendran

Ramesh Rajendran

Freelancer with 16 years of experience in Hybrid & multi-cloud, security, networking & Infrastructure. Working with C-level execs. Founder zerolatency.solutions

More from Medium

Automate E-Arşiv Invoice organizing process with Python

IBM Cloud Pak for Data Installation

Practical sustainability in AWS cloud

The Paralysis of Choice in Cloud Development