UNSOLVED

nfields03

updated

15 years ago

N

nfields03

11 Posts

0

15442

February 29th, 2012 08:00

Question from chat yesterday (what vars available)

I had a question in the 1.0.1 release chat yesterday that was suggested I post in the forum here to get some input.  I've got about 150 DRAC5 and iDRAC6 servers that I'd like to reconfigure using RACADM in OME.  I'm working on my template configs to apply to the servers, and I wanted to set the DRAC/iDRAC name to match the hostname on the server (instead of 9k4gg1, it would be server1).  I can run the racadm command for a single host successfully, but does anyone have a suggestion on how to use a variable to apply the hostname in the RACADM task in OME?  I know there are a couple like $ip and $n listed in the documentation, but $n didn't work.  

Thanks in advance!

  • DELL-Abhijit P

    Community Manager

    •

    711 Posts

    1404

    0

    Posted February 29th, 2012 11:00

    Hi,

    Thanks for your post and joining the chat yesterday.

    $IP and $NAME are substitution parameters which get replaced with the target IP address or target hostname when the command is run.

    For your specific use case since hostname is going to be different for each iDrac you will have to run the command separately for each one.

    Also setting the hostname of the server and iDrac to be the same might cause problems for discovery if you are using hostname based discovery.

    Having said this, if you want to automate the renaming operation, you could try using generic command line task coupled with a batch file.

    The batch file would be something like:

    Racadm setniccfg –s %1  ( This is not the command to change the hostname but an example where %1 is the IP address of the iDRAC)

    For the command you will specify batch file name and in arguments you would use $IP and that would pass the IP of the target to the %1 in the batch file

    Regards

    Abhijit

  • nfields03

    11 Posts

    1404

    0

    Posted February 29th, 2012 12:00

    Thanks Abhijit, I've dug around it some more and let me see if I can clear up a few things.  I've got the correct fields now, so what I'm looking to do is take the ManagedNodeOS hostname from the DRAC config, for example:

    [ifcRacManagedNodeOs]

    # ifcRacMnOsHostname=server1

    # ifcRacMnOsOsName=Microsoft Windows Server 2008 R2, Standard x64 Edition

    And set it to be the DNS name for the DRAC so that it registers in DNS properly.  

    [cfgLanNetworking]

    cfgDNSRacName=DRACserialnumber

    cfgDNSDomainName=drac.company.com

    The RACADM task only accepts 1 line of input, and I don't think I can chain RACADM commands together.  I could do the batch file, but I can only target that at Servers and not DRACs, so it doesn't pull in the arguments properly...

  • DELL-Abhijit P

    Community Manager

    •

    711 Posts

    1404

    0

    Posted February 29th, 2012 13:00

    Thanks for the clarification.

    By default the command line tasks are applicable to the servers and custom groups. If you have a batch file with racadm commands, you can still use the generic command line task.

    First thing you would do is create a custom group which includes all the DRACs. You can do this by right clicking all devices and selecting New Group and go through the wizard which opens up. You can either choose individual RAC devices or use a query to narrow down you devices. Once you have a custom group for your DRACs, it will show up as available target for commandline task.

    Regards

    Abhijit

  • DELL-Abhijit P

    Community Manager

    •

    711 Posts

    1404

    0

    Posted March 1st, 2012 12:00

    Tips and Tricks is updated with this information.

  • DELL-Abhijit P

    Community Manager

    •

    711 Posts

    1404

    0

    Posted March 1st, 2012 12:00

    Thanks for sharing this. This is really good. I am sure this will help many customers. We will share this in our tips and tricks section on the forum.

    Regards

    Abhijit

  • nfields03

    11 Posts

    1404

    0

    Posted March 1st, 2012 12:00

    Abhijit,

    Thanks for the advice, I decided to cobble together a larger PowerShell script to configure the DRACs from the Leveraging Powershell OME document published by Ben Villaneuva  from Dell and a function borrowed from Ben Short's Dell DRAC Powershell Library (practicaladmin.wordpress.com) to parse some output.  The script can now target the DRAC group, and within the script grab the hostname from the DRAC, then turnaround and use it to configure the name the DRAC registers in DNS along with all the AD authentication stuff.  It's not pretty, but it appears to work so far.  Others are welcome to build on this and share their work as well.

    ##########################################

    function Parse-RACGetOutput ($RACOutput) {

    $arrayobj = @()

    foreach ($line in $RACoutput) {

    if ($line -ne "") {

    $line = $line.Trim("# ")

    $result = $line.Split("=")

    if ($result[0] -ne "") {

    $object = New-Object system.Object

    $object | add-member -MemberType NoteProperty -Name Property -value $result[0]

    $arrayobj += $object

    }

    }

    }

    return $arrayobj

    }

    function RACConfig ($Hosts)

    {

    # Change to path where racadm.exe is located, default location in Windows 2008 R2 with OME

    $RacDir = "&`"C:\Program Files (x86)\Dell\SysMgt\rac5\racadm.exe`""

    # Change username and password for the ones configured on your iDRAC, keep the

    # space after the password to ensure the command runs correctly

    $UserPass = "-u root -p calvin "

    # Change your Domain to match your environment

    $MyDomain = "COMPANY.com"

    # Assemble Command for querying hostname if OMSA is installed

    $QueryHostname = $RacDir + " -r " + $Hosts + " " + $UserPass + "getconfig -g cfgLanNetworking -o cfgDNSRacName"

    $result = Invoke-Expression $QueryHostname | select -skip 3

    $HostName = Parse-RACGetOutput ($result)

    $ShortHost = $HostName.property

    # AD groups that will have admin rights on iDRAC

    $RacGroup1 = "COMPANY-FULL-ADMINS"

    $RacGroup2 = "COMPANY-CONSOLE-ADMINS"

    # Assemble Commands for configuration

    $RacCommands = @("-g cfgLanNetworking -o cfgDNSServer1 1.1.1.1",

    "-g cfgLanNetworking -o cfgDNSServer2 2.2.2.2",

    "-g cfgLanNetworking -o cfgDNSRacName $ShortHost",

    "-g cfgLanNetworking -o cfgDNSDomainName DRAC.COMPANY.COM",

    "-g cfgLanNetworking -o cfgDNSRegisterRac 1",

    "-g cfgLanNetworking -o cfgDNSServersFromDHCP 0",

    "-g cfgLanNetworking -o cfgDNSDomainNameFromDHCP 0",

    "-g cfgActiveDirectory -o cfgADEnable 1",

    "-g cfgActiveDirectory -o cfgADType 2",

    "-g cfgActiveDirectory -o cfgADDcSRVLookupEnable 1",

    "-g cfgActiveDirectory -o cfgADDcSRVLookupDomainName $MyDomain",

    "-g cfgActiveDirectory -o cfgADGcSRVLookupEnable 1",

    "-g cfgActiveDirectory -o cfgADGcRootDomain $MyDomain",

    "-g cfgActiveDirectory -o cfgADCertValidationEnable 1",

    "-g cfgStandardSchema -i 1 -o cfgSSADRoleGroupName $RacGroup1",

    "-g cfgStandardSchema -i 1 -o cfgSSADRoleGroupDomain $MyDomain",

    "-g cfgStandardSchema -i 1 -o cfgSSADRoleGroupPrivilege 0x000001ff",

    "-g cfgStandardSchema -i 1 -o cfgSSADRoleGroupName $RacGroup2",

    "-g cfgStandardSchema -i 1 -o cfgSSADRoleGroupDomain $MyDomain",

    "-g cfgStandardSchema -i 1 -o cfgSSADRoleGroupPrivilege 0x00000071",

    "-g cfgUserDomain -o cfgUserDomainName -i 1 $MyDomain")

    #Export Root Certificate as Base-64 place in directory below

    $RootCert = "C:\temp\COMPANYROOTCA.cer"

    $CertCommand = "-t 2 -f " + $RootCert

    $FullCommand = $RacDir + " -r " + $Hosts + " " + $UserPass

    foreach ($element in $RacCommands) {

    $Run = $FullCommand + " config " + $element

    Write-Host $Run

    Invoke-Expression $Run

    }

    $UploadCert = $FullCommand + " sslcertupload " + $CertCommand

    Write-Host $UploadCert

    Invoke-Expression $UploadCert

    }

    RACConfig ($args[0]);

    #################################################

  • bcshort

    1 Rookie

    •

    53 Posts

    1404

    0

    Posted March 12th, 2012 20:00

    Hi There,

    If you are going to use my library functions, maybe the link to the entire library could be put in the tips and tricks section too? :)

    That way if I go around making bugfix changes to stuff in the library people can benefit from that? ;)

    practicaladmin.wordpress.com/idrac-ps-library

    Cheers

    Ben

  • nfields03

    11 Posts

    1404

    0

    Posted March 13th, 2012 07:00

    Agreed Ben, it's a great set of functions you built, and a good building block for further RACADM scripting.  Maybe even worth the Dell folks putting up a scripting library similar to what's on Microsoft TechNet so we can post scripts?

  • DELL-Abhijit P

    Community Manager

    •

    711 Posts

    1404

    0

    Posted March 13th, 2012 08:00

    Thanks Ben. Updated the Tips and Tricks with link to the library.