Recently we had a requirement to check SMTP of two diffrent servers and run a script if both servers failed. i googled around for the tool but ended up putting together this script.
Its not the most prettiest but it works, and im sure you guys will make something much better out of it.
# Define the host names here for the servers that needs to be monitored
$servers = "relay1.host.com","relay2.host.com"
# Define port number
$tcp_port = "25"
# Loop through each host to get an individual result.
ForEach($srv in $servers) {
$tcpClient = New-Object System.Net.Sockets.TCPClient
$tcpClient.Connect($srv,$tcp_port)
$connectState = $tcpClient.Connected
If($connectState -eq $true) {
Write-Host "$srv is online"
}
Else {
Write-Host "$srv is offline"
}
$tcpClient.Dispose()
}
If something is wrong or if you think there is a better way please free feel to comment and let everyone know. its all about community after all.
Update 4/18/2016 –
Updated the script with the one provided by Donald Gray – Thanks a lot : )
DISCLAIMER: No copyright infringement intended. This article is for entertainment and educational purposes only,
Alright!! now that’s out of the way I’m going to keep this short and simple
Scope : –
Install OpenVPN client
import profile with username and password
connect to your preferred VPN server
Use case : –
- Secure your fireTV traffic using any OpenVPN supported VPN services=
- Connect to your home file server/NAS and stream files when traveling via your FireTV or Firestick using your own VPN server (not covered in this article)
- Watch Streaming services when traveling using your own VPN server (not covered in this article)
Project Summary
Hardware – FireTV 4K Latest firmware
Platform – Windows 10 Enterprise
in this guide im using ADB to install OpenVPN client on my fireTV and use that to connect to the NORDVPN service
All Project files are located on C:NoRDVPN
Files Needed (Please download these files to your workstation before proceeding)
OpenVPN client APK – http://plai.de/android/
NORDVPN OpenVPN configuration files – https://nordvpn.com/ovpn/
ADBLink – http://jocala.com
01. Enable Developer mode on Fire tv
http://www.aftvnews.com/how-to-enable-adb-debugging-on-an-amazon-fire-tv-or-fire-tv-stick/
- From the Fire TV or Fire TV Stick’s home screen, scroll to “Settings”.

- Next, scroll to the right and select “Device”.

- Next, scroll down and select “Developer options”.

- Then select “ADB debugging” to turn the option to “ON”.

- Click on “File Manager” on adbLink
- Create a folder (I’m going to call it NORD_VPN)
- Installed OpenVPN on the FireTV system
- Customized the VPN configuration files
- Copied the VPN configuration files to the Root of the SDcard on the FireTV system
Select and launch OpenVPN Client
Use the + sign to add a profile
Click Import
Browse and Select the ovpn configuration file using the browser
Issue
Received the following error from the Azure AD stating that Password Synchronization was not working on the tenant.

When i manually initiate a delta sync, i see the following logs
"The Specified Domain either does not exist or could not be contacted"
(click to enlarge)
Checked the following
- Restarted ADsync Services
- Resolve the ADDS Domain FQDN and DNS – Working
- Test required ports for AD-sync using portqry – issues with the Primary ADDS server defined on the DNS values
Root Cause
Turns out the Domain controller Defined as the primary DNS value was pointing was going thorough updates, its responding on the DNS but doesn’t return any data (Brown-out state)
Assumption
when checking DNS since the DNS server is connecting, Windows doesn’t check the secondary and tertiary servers defined under DNS servers.
This might happen if you are using a ADDS server via a S2S tunnel/MPLS when the latency goes high
Resolution
Check make sure your ADDS-DNS servers defined on AD-SYNC server are alive and responding
in my case i just updated the “Primary” DNS value with the umbrella Appliance IP (this act as a proxy and handle the fail-over)
What is VSX?
VSX is a cluster technology that allows the two VSX switches to run with independent control planes (OSPF/BGP) and present themselves as different routers in the network. In the datapath, however, they function as a single router and support active-active forwarding.
VSX allows you to mitigate inherent issues with a shared control plane that comes with traditional stacking while maintaining all the benefits

- Control plane: Inter-Switch-Link and Keepalive
- Data plane L2: MCLAGs
- Data plane L3: Active gateway
This is a very similar technology compared to Dell VLT stacking with Dell OS10
Basic feature Comparison with Dell VLT Stacking
| Dell VLT Stacking | Aruba VSX | |
| Supports Multi chassis Lag | ✅ | ✅ |
| independent control planes | ✅ | ✅ |
| All active-gateway configuration (L3 load balancing) | ✅(VLT Peer routing) | ✅(VSX Active forwarding) |
| Layer 3 Packet load balancing | ✅ | ✅ |
| Can Participate in Spanning tree MST/RSTP | ✅ | ✅ |
| Gateway IP Redundancy | ✅VRRP | ✅(VSX Active Gateway or VRRP) |
Setup Guide
What you need?
- 10/25/40/100GE Port for the interswitch link
- VSX supported switch, VSX is only supported on switches above CX6300 SKU
| Switch Series | VSX |
| CX 6200 series | X |
| CX 6300 series | X |
| CX 6400 series | ✅ |
| CX 8200 series | ✅ |
| CX 8320/8325 series | ✅ |
| CX 8360 series | ✅ |
For this guide im using a 8325 series switch
Dry run
- Setup LAG interface for the inter-switch link (ISL)
- Create the VSX cluster
- Setup a keepalive link and a new VRF for the keepalive traffic
Setup LAG interface for the inter-switch link (ISL)
In order to form the VSX cluster, we need a LAG interface for the inter switch communication

Naturally i pick the fastest ports on the switch to create this 10/25/40/100GE
Depending on what switch you have, The ISL bandwidth can be a limitation/Bottleneck, Account for this factor when designing a VSX based solution
Utilize VSX-Activeforwarding or Active gateways to mitigate this
Create the LAG interface
This is a regular Port channel no special configurations, you need to create this on both switches
- Native VLAN needs to be the default VLAN
- Trunk port and All VLANs allowed
CORE01# interface lag 256 no shutdown description VSX-LAG no routing vlan trunk native 1 tag vlan trunk allowed all lacp mode active exit ------------------------------- CORE02# interface lag 256 no shutdown description VSX-LAG no routing vlan trunk native 1 tag vlan trunk allowed all lacp mode active exit
Add/Assign the physical ports to the LAG interface
I’m using two 100GE ports for the ISL LAG

CORE01# interface 1/1/55 no shutdown lag 256 exit interface 1/1/56 no shutdown lag 256 exit ------------------------------- CORE02# interface 1/1/55 no shutdown lag 256 exit interface 1/1/56 no shutdown lag 256 exit
Do the same configuration on the VSX Peer switch (Second Switch)
Connect the cables via DAC/Optical and confirm the Port-channel health
CORE01# sh lag 256 System-ID : b8:d4:e7:d5:36:00 System-priority : 65534 Aggregate lag256 is up Admin state is up Description : VSX-LAG Type : normal MAC Address : b8:d4:e7:d5:36:00 Aggregated-interfaces : 1/1/55 1/1/56 Aggregation-key : 256 Aggregate mode : active Hash : l3-src-dst LACP rate : slow Speed : 200000 Mb/s Mode : trunk ------------------------------------------------------------------- CORE02# sh lag 256 System-ID : b8:d4:e7:d5:f3:00 System-priority : 65534 Aggregate lag256 is up Admin state is up Description : VSX-LAG Type : normal MAC Address : b8:d4:e7:d5:f3:00 Aggregated-interfaces : 1/1/55 1/1/56 Aggregation-key : 256 Aggregate mode : active Hash : l3-src-dst LACP rate : slow Speed : 200000 Mb/s Mode : trunk
Form the VSX Cluster
under the configuration mode, go in to the VSX context by entering “vsx” and issue the following commands on both switches
CORE01#
vsx
inter-switch-link lag 256
role primary
linkup-delay-timer 30
-------------------------------
CORE02#
vsx
inter-switch-link lag 256
role secondary
linkup-delay-timer 30
Check the VSX Status
CORE01# sh vsx status VSX Operational State --------------------- ISL channel : In-Sync ISL mgmt channel : operational Config Sync Status : In-Sync NAE : peer_reachable HTTPS Server : peer_reachable Attribute Local Peer ------------ -------- -------- ISL link lag256 lag256 ISL version 2 2 System MAC b8:d4:e7:d5:36:00 b8:d4:e7:d5:f3:00 Platform 8325 8325 Software Version GL.10.06.0001 GL.10.06.0001 Device Role primary secondary ---------------------------------------- CORE02# sh vsx status VSX Operational State --------------------- ISL channel : In-Sync ISL mgmt channel : operational Config Sync Status : In-Sync NAE : peer_reachable HTTPS Server : peer_reachable Attribute Local Peer ------------ -------- -------- ISL link lag256 lag256 ISL version 2 2 System MAC b8:d4:e7:d5:f3:00 b8:d4:e7:d5:36:00 Platform 8325 8325 Software Version GL.10.06.0001 GL.10.06.0001 Device Role secondary primary
Setup the Keepalive Link
its recommended to set up a Keepalive link to avoid Split-brain scenarios if the ISL goes down, We are trying to prevent both switches from thinking they are the active devices creating STP loops and other issues on the network
This is not a must-have, it’s nice to have, As of Aruba CX OS 10.06.x you need to sacrifice one of your data ports for this
Dell OS10 VLT archives this via the OOBM network ports, Supposedly Keepalive over OOBM is something Aruba is working on for future releases
Few things to note
- It’s recommended using a routed port in a separate VRF for the keepalive link
- can use a 1Gbps link for this if needed
Provision the port and VRF
CORE01# vrf KEEPALIVE interface 1/1/48 no shutdown vrf attach KEEPALIVE description VSX-keepalive-Link ip address 192.168.168.1/24 exit ----------------------------------------- CORE02# vrf KEEPALIVE interface 1/1/48 no shutdown vrf attach KEEPALIVE description VSX-keepalive-Link ip address 192.168.168.2/24 exit
Define the Keepalive link
Note – Remember to define the vrf id in the keepalive statement
Thanks /u/illumynite for pointing that out
CORE01#
vsx
inter-switch-link lag 256
role primary
keepalive peer 192.168.168.2 source 192.168.168.1 vrf KEEPALIVE
linkup-delay-timer 30
-----------------------------------------
CORE02#
vsx
inter-switch-link lag 256
role secondary
keepalive peer 192.168.168.1 source 192.168.168.2 vrf KEEPALIVE
linkup-delay-timer 30
Next up…….
- VSX MC-LAG
- VSX Active forwarding
- VSX Active gateway
References
AOS-CX 10.06 Virtual SwitchingExtension (VSX) Guide
As always if you notice any mistakes please do let me know in the comments
So recently I ran into this annoying error message with Exchange 2016 CU11 Update.
Environment info-
- Exchange 2016 upgrade from CU8 to CU11
- Exchange binaries are installed under D:\Microsoft\Exchange_Server_V15\..
Microsoft.PowerShell.Commands.GetItemCommand.ProcessRecord()". [12/04/2018 16:41:43.0233] [1] [ERROR] Cannot find path 'D:\Microsoft\Exchange_Server_V15\UnifiedMessaging\grammars' because it does not exist.
[12/04/2018 16:41:43.0233] [1] [ERROR-REFERENCE] Id=UnifiedMessagingComponent___99d8be02cb8d413eafc6ff15e437e13d Component=EXCHANGE14:\Current\Release\Shared\Datacenter\Setup
[12/04/2018 16:41:43.0234] [1] Setup is stopping now because of one or more critical errors. [12/04/2018 16:41:43.0234] [1] Finished executing component tasks.
[12/04/2018 16:41:43.0318] [1] Ending processing Install-UnifiedMessagingRole
[12/04/2018 16:44:51.0116] [0] CurrentResult setupbase.maincore:396: 0 [12/04/2018 16:44:51.0118] [0] End of Setup
[12/04/2018 16:44:51.0118] [0] **********************************************
Root Cause
Ran the Setup again and it failed with the same error
while going though the log files i notice that the setup looks for this file path while configuring the "Mailbox role: Unified Messaging service" (Stage 6 on the GUI installer)
$grammarPath = join-path $RoleInstallPath "UnifiedMessaging\grammars\*";
There was no folder present with the name grammars under the Path specified on the error
just to confirm, i checked another server on CU8 and the grammars folder is there.
Not sure why the folder got removed, it may have happened during the first run of the CU11 setup that failed,
Resolution
My first thought was to copy the folder from an existing CU8 server. but just to avoid any issues (since exchange is sensitive to file versions)
I created an empty folder with the name "grammars" under D:\Microsoft\Exchange_Server_V15\UnifiedMessaging\
Ran the setup again and it continued the upgrade process and completed without any issues...¯\_(ツ)_/¯
[12/04/2018 18:07:50.0416] [2] Ending processing Set-ServerComponentState
[12/04/2018 18:07:50.0417] [2] Beginning processing Write-ExchangeSetupLog
[12/04/2018 18:07:50.0420] [2] Install is complete. Server state has been set to Active.
[12/04/2018 18:07:50.0421] [2] Ending processing Write-ExchangeSetupLog
[12/04/2018 18:07:50.0422] [1] Finished executing component tasks.
[12/04/2018 18:07:50.0429] [1] Ending processing Start-PostSetup
[12/04/2018 18:07:50.0524] [0] CurrentResult setupbase.maincore:396: 0
[12/04/2018 18:07:50.0525] [0] End of Setup
[12/04/2018 18:07:50.0525] [0] **********************************************
Considering cost of this software M$ really have to be better about error handling IMO, i have run in to silly issues like this way too many times since Exchange 2010.
Im going to base this off my VRF Setup and Route leaking article and continue building on top of it
Lets say we need to advertise connected routes within VRFs using IGP to an upstream or downstream iP address this is one of many ways to get to that objective
For this example we are going to use BGP to collect connected routes and advertise that over OSPF

Setup the BGP process to collect connected routes
router bgp 65000 router-id 10.252.250.6 ! address-family ipv4 unicast ! neighbor 10.252.250.1 ! vrf Tenant01_VRF ! address-family ipv4 unicast redistribute connected ! vrf Tenant02_VRF ! address-family ipv4 unicast redistribute connected ! vrf Tenant03_VRF ! address-family ipv4 unicast redistribute connected ! vrf Shared_VRF ! address-family ipv4 unicast redistribute connected
Setup OSPF to Redistribute the routes collected via BGP
router ospf 250 vrf Shared_VRF area 0.0.0.0 default-cost 0 redistribute bgp 65000
interface vlan250 mode L3 description OSPF_Routing no shutdown ip vrf forwarding Shared_VRF ip address 10.252.250.6/29 ip ospf 250 area 0.0.0.0 ip ospf mtu-ignore ip ospf priority 10
Testing and confirmation
Local OSPF Database

Remote device

This is a guide to show you how to enroll your servers/desktops to allow powershell remoting (WINRM) over HTTPS
Assumptions
- You have a working Root CA on the ADDS environment – Guide
- CRL and AIA is configured properly – Guide
- Root CA cert is pushed out to all Servers/Desktops – This happens by default
Contents
- Setup CA Certificate template
- Deploy Auto-enrolled Certificates via Group Policy
- Powershell logon script to set the WinRM listener
- Deploy the script as a logon script via Group Policy
- Testing
1 – Setup CA Certificate template to allow Client Servers/Desktops to checkout the certificate from the CA
Connect to the The Certification Authority Microsoft Management Console (MMC)
Navigate to Certificate Templates > Manage

On the “Certificate templates Console” window > Select Web Server > Duplicate Template

Under the new Template window Set the following attributes
General – Pick a Name and Validity Period – This is up to you

Compatibility – Set the compatibility attributes (You can leave this on the default values, It up to you)

Subject Name – Set ‘Subject Name’ attributes (Important)

Security – Add “Domain Computers” Security Group and Set the following permissions
- Read – Allow
- Enroll – Allow
- Autoenroll – Allow

Click “OK” to save and close out of “Certificate template console”
Issue to the new template
Go back to the “The Certification Authority Microsoft Management Console” (MMC)
Under templates (Right click the empty space) > Select New > Certificate template to Issue

Under the Enable Certificate template window > Select the Template you just created

Allow few minutes for ADDS to replicate and pick up the changes with in the forest
2 – Deploy Auto-enrolled Certificates via Group Policy
Create a new GPO
Windows Settings > Security Settings > Public Key Policies/Certificate Services Client – Auto-Enrollment Settings

Link the GPO to the relevant OU with in your ADDS environment
Note – You can push out the root CA cert as a trusted root certificate with this same policy if you want to force computers to pick up the CA cert,
Testing
If you need to test it gpupdate/force or reboot your test machine, The Server VM/PC will pickup a certificate from ADCS PKI
3 – Powershell logon script to set the WINRM listener
Dry run
- Setup the log file
- Check for the Certificate matching the machines FQDN Auto-enrolled from AD CS
- If exist
- Set up the HTTPS WInRM listener and bind the certificate
- Write log
- else
- Write log
#Malinda Rathnayake- 2020
#
#variable
$Date = Get-Date -Format "dd_MM_yy"
$port=5986
$SessionRunTime = Get-Date -Format "dd_yyyy_HH-mm"
#
#Setup Logs folder and log File
$ScriptVersion = '1.0'
$locallogPath = "C:\_Scripts\_Logs\WINRM_HTTPS_ListenerBinding"
#
$logging_Folder = (New-Item -Path $locallogPath -ItemType Directory -Name $Date -Force)
$ScriptSessionlogFile = New-Item $logging_Folder\ScriptSessionLog_$SessionRunTime.txt -Force
$ScriptSessionlogFilePath = $ScriptSessionlogFile.VersionInfo.FileName
#
#Check for the the auto-enrolled SSL Cert
$RootCA = "Company-Root-CA" #change This
$hostname = ([System.Net.Dns]::GetHostByName(($env:computerName))).Hostname
$certinfo = (Get-ChildItem -Path Cert:\LocalMachine\My\ |? {($_.Subject -Like "CN=$hostname") -and ($_.Issuer -Like "CN=$RootCA*")})
$certThumbprint = $certinfo.Thumbprint
#
#Script-------------------------------------------------------
#
#Remove the existing WInRM Listener if there is any
Get-ChildItem WSMan:\Localhost\Listener | Where -Property Keys -eq "Transport=HTTPS" | Remove-Item -Recurse -Force
#
#If the client certificate exists Setup the WinRM HTTPS listener with the cert else Write log
if ($certThumbprint){
#
New-Item -Path WSMan:\Localhost\Listener -Transport HTTPS -Address * -CertificateThumbprint $certThumbprint -HostName $hostname -Force
#
netsh advfirewall firewall add rule name="Windows Remote Management (HTTPS-In)" dir=in action=allow protocol=TCP localport=$port
#
Add-Content -Path $ScriptSessionlogFilePath -Value "Certbinding with the HTTPS WinRM HTTPS Listener Completed"
Add-Content -Path $ScriptSessionlogFilePath -Value "$certinfo.Subject"}
else{
Add-Content -Path $ScriptSessionlogFilePath -Value "No Cert matching the Server FQDN found, Please run gpupdate/force or reboot the system"
}
Script is commented with Explaining each section (should have done functions but i was pressed for time, never got around to do it, if you do fix it up and improve this please let me know in the comments :D)
5 – Deploy the script as a logon script via Group Policy
Setup a GPO and set this script as a logon Powershell script
Im using a user policy with GPO Loop-back processing set to Merge applied to the server OU

Testing
To confirm WinRM is listening on HTTPS, type the following commands:
winrm enumerate winrm/config/listener

Winrm get http://schemas.microsoft.com/wbem/wsman/1/config

Sources that helped me
Here’s a is a quick guide to get you started with a “Ansible core lab” using Vagrant.
Alright lets get started
TLDR Version
- Install Vagrant
- Install Virtual-box
- Create project folder and CD in to it
Vagrant init
- Vagrantfile – link
- Vagrant Provisioning Shell Script to Deploy Ansible – link
- Install the vagrant-vbguest plugin to deploy missing
vagrant plugin install vagrant-vbguest
- Bring up the Vagrant environment
Vagrant up
Install Vagrant and Virtual box
For this demo we are using windows 10 1909 but you can use the same guide for MAC OSX
Windows
Download Vagrant and virtual box and install it the good ol way –
https://www.vagrantup.com/downloads.html https://www.virtualbox.org/wiki/Downloads https://www.vagrantmanager.com/downloads/
Install the vagrant-vbguest plugin (We need this with newer versions of Ubuntu)
vagrant plugin install vagrant-vbguest
Or Using chocolatey
choco install vagrant
choco install virtualbox
choco install vagrant-manager
Install the vagrant-vbguest plugin (We need this with newer versions of Ubuntu)
vagrant plugin install vagrant-vbguest
MAC OSX – using Brewcask
Install virtual box
$ brew cask install virtualbox
Now install Vagrant either from the website or use homebrew for installing it.
$ brew cask install vagrant
Vagrant-Manager is a nice way to manage all your virtual machines in one place directly from the menu bar.
$ brew cask install vagrant-manager
Install the vagrant-vbguest plugin (We need this with newer versions of Ubuntu)
vagrant plugin install vagrant-vbguest
Setup the Vagrant Environment
Open Powershell
to get started lets check our environment
vagrant version

Create a project directory and Initialize the environment
for the project directory im using D:\vagrant
Open powershell and run
mkdir D:\vagrant cd D:\vagrant
Initialize the environment under the project folder
vagrant init

this will create Two Items

.vagrant – Hidden folder holding Base Machines and meta data
Vagrantfile – Vagrant config file
Lets Create the Vagrantfile to deploy the VMs
https://www.vagrantup.com/docs/vagrantfile/
The syntax of Vagrantfiles is Ruby this gives us a lot of flexibility to program in logic when building your files
Im using Atom to edit the vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "controller" do |controller|
controller.vm.box = "ubuntu/trusty64"
controller.vm.hostname = "LAB-Controller"
controller.vm.network "public_network", bridge: "Intel(R) I211 Gigabit Network Connection", ip: "172.17.10.120"
controller.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
controller.vm.provision :shell, path: 'Ansible_LAB_setup.sh'
end
(1..3).each do |i|
config.vm.define "vls-node#{i}" do |node|
node.vm.box = "ubuntu/trusty64"
node.vm.hostname = "vls-node#{i}"
node.vm.network "public_network", bridge: "Intel(R) I211 Gigabit Network Connection" ip: "172.17.10.12#{i}"
node.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
end
end
end
You can grab the code from my Repo
https://github.com/malindarathnayake/Ansible_Vagrant_LAB/blob/master/Vagrantfile
Let’s talk a little bit about this code and unpack this
Vagrant API version

Vagrant uses API versions for its configuration file, this is how it can stay backward compatible. So in every Vagrantfile we need to specify which version to use. The current one is version 2 which works with Vagrant 1.1 and up.
Provisioning the Ansible VM

This will
- Provision the controller Ubuntu VM
- Create a bridged network adapter
- Set the host-name – LAB-Controller
- Set the static IP – 172.17.10.120/24
- Run the Shell script that installs Ansible using apt-get install (We will get to this below)
Lets start digging in…
Specifying the Controller VM Name, base box and hostname

Vagrant uses a base image to clone a virtual machine quickly. These base images are known as “boxes” in Vagrant, and specifying the box to use for your Vagrant environment is always the first step after creating a new Vagrantfile.
You can find different base boxes from app.vagrantup.com
Or you can create custom base boxes for pretty much anything including “CiscoVIRL(CML)” images – keep an eye out for the next article on this
Network configurations

controller.vm.network "public_network", bridge: "Intel(R) I211 Gigabit Network Connection", ip: "your IP"
in this case, we are asking it to create a bridged adapter using the Intel(R) I211 NIC and set the IP address you defined on under IP attribute
You can the relavant interface name using
get-netadapter

You can also create a host-only private network
controller.vm.network :private_network, ip: "10.0.0.10"
for more info checkout the network section in the KB
https://www.vagrantup.com/docs/networking/
Define the provider and VM resources

We declaring virtualbox(we installed this earlier) as the provider and setting VM memory to 2048
You can get more granular with this, refer to the below KB
https://www.vagrantup.com/docs/virtualbox/configuration.html
Define the shell script to customize the VM config and install the Ansible Package

Now this is where we define the provisioning shell script
this script installs Ansible and set the host file entries to make your life easier
In case you are wondering VLS stands for V=virtual,L – linux S – server.
I use this naming scheme for my VMs. Feel free to use anything you want; make sure it matches what you defined on the Vagrantfile under node.vm.hostname
!/bin/bash sudo apt-get update sudo apt-get install software-propetise-common -y sudo apt-add-repository ppa:ansible/ansible sudo apt-get update sudo apt-get install ansible -y echo " 172.17.10.120 LAB-controller 172.17.10.121 vls-node1 172.17.10.122 vls-node2 172.17.10.123 vls-node3" >> /etc/hosts
create this file and save it as Ansible_LAB_setup.sh in the Project folder
in this case I’m going to save it under D:\vagrant
You can also do this inline with a script block instead of using a separate file
https://www.vagrantup.com/docs/provisioning/basic_usage.html
Provisioning the Member servers for the lab

We covered most of the code used above, the only difference here is we are using each method to create 3 VMs with the same template (I’m lazy and it’s more convenient)
This will create three Ubuntu VMs with the following Host-names and IP addresses, you should update these values to match you LAN, or use a private Adapter
vls-node1 – 172.17.10.121
vls-node2 – 172.17.10.122
vls-node1 – 172.17.10.123
So now that we are done with explaining the code, let’s run this
Building the Lab environment using Vagrant
Issue the following command to check your syntax
Vagrant status
Issue the following command to bring up the environment
Vagrant up

If you get this message Reboot in to UEFI and make sure virtualization is enabled
Intel – VT-D
AMD Ryzen – SVM
If everything is kumbaya you will see vagrant firing up the deployment

It will provision 4 VMs as we specified
Notice since we have the “vagrant-vbguest” plugin installed, it will reinstall the relevant guest tools along with the dependencies for the OS
==> vls-node3: Machine booted and ready! [vls-node3] No Virtualbox Guest Additions installation found. rmmod: ERROR: Module vboxsf is not currently loaded rmmod: ERROR: Module vboxguest is not currently loaded Reading package lists... Building dependency tree... Reading state information... Package 'virtualbox-guest-x11' is not installed, so not removed The following packages will be REMOVED: virtualbox-guest-utils* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 5799 kB disk space will be freed. (Reading database ... 61617 files and directories currently installed.) Removing virtualbox-guest-utils (6.0.14-dfsg-1) ... Processing triggers for man-db (2.8.7-3) ... (Reading database ... 61604 files and directories currently installed.) Purging configuration files for virtualbox-guest-utils (6.0.14-dfsg-1) ... Processing triggers for systemd (242-7ubuntu3.7) ... Reading package lists... Building dependency tree... Reading state information... linux-headers-5.3.0-51-generic is already the newest version (5.3.0-51.44). linux-headers-5.3.0-51-generic set to manually installed.
Check the status
Vagrant status


Testing
Connecting via SSH to your VMs
vagrant ssh controller
“Controller” is the VMname we defined before not the hostname, You can find this by running Vagrant status on posh or your terminal
We are going to connect to our controller and check everything


Little bit more information on the networking side
Vagrant Adds two interfaces, for each VM
NIC 1 – Nat’d in to the host (control plane for Vagrant to manage the VMs)

NIC 2 – Bridged adapter we provisioned in the script with the IP Address

Default route is set via the Private(NAT’d) interface (you cant change it)

Netplan configs
Vagrant creates a custom netplan yaml for interface configs


Destroy/Tear-down the environment
vagrant destroy -f
https://www.vagrantup.com/intro/getting-started/teardown.html
I hope this helped someone. when I started with Vagrant a few years back it took me a few tries to figure out the system and the logic behind it, this will give you a basic understanding on how things are plugged together.
let me know in the comments if you see any issues or mistakes.
Until Next time…..































