Using the ESXi esxcli command to power off a virtual machine
The esxcli command can be used locally or remotely to power off a virtual machine running on ESXi 5.x or later. For more information, see the esxcli vm Commands section in the vSphere Command-Line Interface Reference.
Open a console session where the esxcli tool is available, either in the ESXi Shell, the vSphere Management Assistant (vMA), or the location where the vSphere Command-Line Interface (vCLI) is installed.
Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file by running this command:esxcli vm process list
Power off the virtual machine from the list by running this command:esxcli vm process kill --type= [soft,hard,force] --world-id= WorldNumberNotes:
Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
alternate power off command syntax is: esxcli vm process kill -t [ soft,hard,force] -w WorldNumber
Repeat Step 2 and validate that the virtual machine is no longer running.
Using the ESXi command-line utility vim-cmd to power off the virtual machine
Get a list of all registered virtual machines, identified by their VMID, Display Name, and path to the .vmx configuration file by running this command:vim-cmd vmsvc/getallvms
Get the current state of a virtual machine by running this command:vim-cmd vmsvc/power.getstate VMID
Shutdown the virtual machine using the VMID found in Step 2 and run this command:vim-cmd vmsvc/power.shutdown VMIDNote: If the virtual machine fails to shut down, run this command:vim-cmd vmsvc/power.off VMID
Note: this article is for my quick reference, VMware KB reference (https://kb.vmware.com/s/article/1014165)
Run playbook with Ansible: (-f switch allow the execution to be performed on multiple hosts parallel)
$ ansible-playbook telnetPlaybook.yaml -f 10
Ansible Modules (-m): These are few but there is huge list.
command – execute commands and this is default module of Ansible.
copy – copy files
shell – use remote shell to execute
file – file operations
ping – ping remote hosts
yum – Redhat package manager
git – use GIT
user – user creation, manipulation
service – manage services
My office environment like many others are providing us Internet via proxy, on Windows Machine/Servers as they are part of domain the policy is pushed and as you login with your domain account you will find it available.
However on Linux servers I always go ahead with doing the following:
And whenever the servers were required to reboot the proxy used to wipe out.
This time I made sure to make it static and plan to push it via Ansible to all the Linux babies I love.
Logged in from root account:
Save the file – Re-initialize the shell or logout and login back. You will not have to re-add it back again.
One of my monitor display was bothering my eyes, therefore I decided to change the colors being displayed on the monitor I am using, especially for the directory as it was dark blue and I had to dig myself inside the screen to actually read in that color. (my eyes are not week but I love small fonts)
I was not sure how to do it but knew it can be changed as I studied them long time ago, did some research and found out there are multiple ways to perform it.
As my environment is an Ansible lab therefore it did not click me to just change it for a specific user therefore I changed in environment base:
This is what I did: (from root user)
vim /etc/DIR_COLORS DIR 01;96
Just above DIR value, I found out FILE parameter but it was commented, so i edited it to
vim /etc/DIR_COLORS FILE 01;91
Now my terminal is displaying 96 = turquoise as DIR and 91 = light red as FILE and I like it !!
For you reference color codes:
0 = default colour 1 = bold 4 = underlined 5 = flashing text 7 = reverse field 31 = red 32 = green 33 = orange 34 = blue 35 = purple 36 = cyan 37 = grey 40 = black background 41 = red background 42 = green background 43 = orange background 44 = blue background 45 = purple background 46 = cyan background 47 = grey background 90 = dark grey 91 = light red 92 = light green 93 = yellow 94 = light blue 95 = light purple 96 = turquoise 100 = dark grey background 101 = light red background 102 = light green background 103 = yellow background 104 = light blue background 105 = light purple background 106 = turquoise background
I did not try it but if you are interested in changing it for specific user you can try this:
cp /etc/DIR_COLORS to $HOME/.dir_colors
once copied, edit you local copy i.e .dir_colors and play with it.
Don’t forget you need to re-initialize the shell or logout and login back for changes to take affect.