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

Cookies vs Session vs Local storage

Object detection筆記

My obstacles in becoming a self-taught web developer!

Java Streams — a brief overview

Getting started with android architecture components and MVVM Part-1

Matomo the “free” Google Analytics alternative

Polishing UI: Android StateListAnimator

Find allow per.

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

Best approach to secure the aws credentials in terraform

Future of DevOps : 5 Big Upcoming DevOps Trends in 2022

Continuous Monitoring

Measuring DevOps: Metrics and Key Performance Indicators