racadm Script Reset Multiple Dell DRACs/iDRACs

If you are working as a Linux system administrator in an enterprise infrastructure then you might’ve probably come across Dell server hardware at some point in your career. Even if you’re not, you could probably use the script that we are going to share in this article in one form or another to accomplish some level of automation in your day to day routine tasks. racadm script to reset multiple Dell iDrac’s.

racadm Script Reset Multiple Dell DRACs/iDRACs

While working on a large number of systems you may come across numerous scenarios where you need to interact with the Lights Out or Out of Band management interface popularly simply referred to as the server console. The Dell Remote Access Controller or DRAC is an out-of-band management platform on certain Dell servers. The platform may be provided on a separate expansion card, or integrated into the main board; when integrated, the platform is referred to as iDRAC. It uses mostly separate resources to the main server resources and provides a browser-based or command-line interface (or both) for managing and monitoring the server hardware.

The Dell iDRAC web interface has always been tedious to deal with.  However, you can log in to the DRAC via SSH and use the racadm command to perform actions against the physical server.  Because of SSH, it is possible to automate actions that would otherwise take a long time if they were to be done through the web interface.

The name racadm is an acronym for Remote Access Controller Admin and it is a command line tool that allows for remote or local management of Dell Servers via the iDRAC or DRAC.  The Dell Chassis Management Controller (CMC) can also be managed remotely with racadm. However, for the purpose of this article, we’ll limit ourselves to the DRACs only.

Using racadm commands you can view managed system information, perform power operations on the managed system, perform firmware updates, configure settings and more.  Because racadm is run from a command line interface (CLI), system administrators can create scripts that control and update Dell systems in a one-to-many fashion.

racadm command Manage iDrac from CLI

The syntax for racadm commands is as follows:

racadm <subcommand>

In this article, we will share a script that allows you to reset multiple Dell DRACs with a lot of ease. To reset a Dell DRAC/iDRAC, we use the following command:

racadm racreset soft

Given below is the racadm script which allows you to reset multiple Dell DRAC/iDRACs:

#!/bin/bash
echo -e "Enter list of servers whose idrac needs a reset (type quit to end): \n"
while true
do
read NAME
if [ "${NAME}" == "quit" ] ; then
break
fi

echo $NAME >> /tmp/server_list_$$
done

echo "Enter your account name:"
read UNAME
echo "Enter your account password:"
read PASS

for SERVER in `cat /tmp/server_list_$$`
do
expect -c "spawn ssh -o StrictHostKeyChecking=no ${UNAME}@${SERVER} \"racadm racreset soft\"; expect \"password:\";send \"${PASS}\r\";interact"
done

rm /tmp/server_list_$$

Now I’ll explain the functioning of the script

  • Initially, I’ve written an echo statement prompting the user for some input.
  • This is followed by an infinite while loop denoted by ‘while true’.
    Then we are using the read command to take in the server names entered in by the user. If the user types the word quit, then the while loop breaks and the script will stop prompting the user for input.
  • Next, we have another echo statement which takes in the server name entered by the user and inserts it into a file.
  • Next, ask for the user to type in their credentials for the DRAC.
  • Finally, we have a for loop which iterates over the list of servers entered by the user and executes the ‘racadm racreset soft‘ command wrapped within an expect command
  • We can’t dive deep into expect in this article but I’ll briefly explain it’s working. The -c option expect indicates a command line usage instead of the usual script form.  In a nutshell, expect is a programming language whose purpose is to automate prompts/tasks that would otherwise require user interaction. So, in our expect command in the script we type in expect which is the string that would be displayed on the prompt and send indicates the reply to that prompt. The interact command instructs expect to initiate an ssh connection.
  • In the last line of the script, we delete the temporary file that we had created to hold the server names that were entered in by the user.

Conclusion

In this article, we explained what is a Dell DRAC and the racadm command line utility and showed you a script which you could use to reset multiple DRACs in a single command. We also briefly explained the working of the expect language. Although we’ve not gone into detail about using expect in this article we will attempt to do so in future posts. Also, we would like to mention that the expect command that we have used in the script can be tweaked and used to automate a number of tasks that would otherwise require user interaction. We will attempt to share more posts on expect in the future outlining, demonstrating and explaining such uses and examples. racadm script to reset multiple iDrac’s.

Related Articles

Cheat Command – Create and view Interactive Cheat Sheets

virsh command Line utility to manage KVM virtual Machines

HowTo Install and configure KVM Hypervisor in RHEL 7

More Docs

Thanks for your wonderful Support and Encouragement