Last time we looked at what needs to happen should we loose the input mains electricity supply to our newly acquired Uninterruptable Power Supply (UPS). For example during a power cut.
We also got familiar with the hardware and software needed to action a controlled shutdown should it be required. If you’ve not seen that post, catch up now. It’s a great read.
As mentioned, this post is part 2 of a multipart series. Find the other parts here:
- Part 1: Hardware, Requirement, Software, Solution
- Part 2: This part - Connectivity and Software Installation
- Part 3: Scripting for the win… or should that be for the failure?
To recap, we are going to make our Raspberry Pi “the brains of the operation” in our solution.
Overview
Solution (Refresher)
- Mains electricity fails… power cut!
- The UPS signals to the Raspberry Pi that there is a power cut
- The UPS signals its battery charge state to the Raspberry Pi
- The UPS battery charge falls below a predetermined threshold and signals this to the Raspberry Pi
- The Raspberry Pi runs a script to shut down all powered on VMs
- The Raspberry Pi runs a script to shut down the ESXi host
- The Raspberry Pi runs a script to shut itself down
- The UPS stops supplying power from battery and shuts down which also shuts down the modem, router and network switch
Let’s get to it.
Hardware Connectivity
Like this:
- The UPS is connected to the incoming mains electricity supply
- The UPS and Raspberry Pi are connected via a USB cable
- All kit is powered via the UPS
Check Raspberry Pi + APC UPS Connectivity
After connecting the UPS and Raspberry Pi via a USB cable, lets check UPS to RPi USB connectivity:
Yep, one APC UPS found. So far, so good.
Software Installation
Install APC UPS Daemon (apcupsd)
Next, lets install the APC UPS Daemon on the Raspberry Pi:
Once installed, we need to configure apcupsd to work with our UPS. This is achieved via editing the /etc/apcupsd/apcupsd.conf
config file:
Within the file you will find lots of comments detailing each configuration item. Rather than list the whole file comments and all, I’ve listed just our configuration items below:
Next step is to mark apcupsd as configured:
Set to equal yes
:
Finally lets restart the apcupsd service and test to see if apcupsd discovers our UPS:
Nice:
That is apcupsd daemon installed and working.
Install PowerShell Core on Raspberry Pi
Next step is to install PowerShell Core.
There are two packages that we need to install prior to downloading and extracting PowerShell: libssl1.0
and libunwind8
.
We then download a copy of PowerShell for ARM64 and extract.
Finally we link the pwsh executable to /usr/bin
so that it can be launched from any folder on the Raspberry Pi:
OK, lets launch PowerShell to see if it runs OK:
Yep that works!
Install VMware PowerCLI on Raspberry Pi
OK, lets next install PowerCLI using the PowerShell Install-Module
cmdlet and set our PowerCLI configuration options:
Finally, lets take PowerCLI for a little spin and connect to a test lab ESXi host:
Boom! That’s the end of our software installations
Conclusion and Wrap Up
That’ll do it for part two.
In this post we hooked up our hardware, checked UPS and Raspberry Pi connectivity via USB and installed all of our required software. Next time we’ll look at getting everything to work nicely together.
This post is part 2 of a multipart series.
Find the other parts here:
- Part 1: Hardware, Requirement, Software, Solution
- Part 2: This part - Connectivity and Software Installation
- Part 3: Scripting for the win… or should that be for the failure?
Look out for future parts coming soon!
-Chris