these are instructions for automating the suspend and shutdown of ESXi VMs and host in case of a power failure. works with APC/Schneider SmartUPS 750xl and ESXi 5.5u1
-
make a new VM and install Ubuntu-Server on it
-
install apcupsd
# apt-get install apcupsd
-
configure
/etc/apcupsd/apcupsd.conf
-
enable apcupsd
# vim /etc/default/apcupsd
ISCONFIGURED=yes
-
restart apcupsd
# service apcupsd restart
-
enable SSH on ESXi
configuration-tab - security profile - properties (right upper corner)
-
copy
shutdown_esxi.sh
on ESXi into datastore e.g./vmfs/volumes/MyDataStore/scripts
-
make the file executable
# chmod +x shutdown_esxi.sh
-
configure passwordless ssh access on ESXi
make keys on ubuntu server (as root, because apcupsd runs under root)
# ssh-keygen -i /root/.ssh/id_rsa-ups -t rsa -b 4096 -N ""
copy key to ESXi server
# cat /root/.ssh/id_rsa-ups.pub | ssh root@TARGET_IP "cat >> /etc/ssh/keys-root/authorized_keys"
now automated, passwordless login should work from the ubuntu server. Test using this command:
# ssh root@TARGET_IP /bin/true ; echo $?
(the first time it asks to store esxi's key in local database, answer with "yes")
-
configure an apcupsd helper script to run remote script on esxi copy
doshutdown
to/etc/apcupsd
(you mustn't rename it, otherwise apcupsd won't run it automatically) make it executable# chmod +x doshutdown
-
restart apcupsd
# service apcupsd restart