In general, I am not really a developer. My background is in computer systems and networks. But, every “computer person” has been faced with performing the same menial task over and over again. This made me think, “The has got to be a better way of doing this.” And there was.
It was at this point that I discovered/invented/coined the phrase Infrastructure Automation. Infrastructure automation takes its cues from several different areas. It has obvious connection to software development and system management but it is equally influenced by the hacker and open-some communities as well.
What is Infrastructure Automation?
Infrastructure automation is the process of using software or scripts to perform menial or repetitive tasks on computers, network systems, or other programmable/configurable device. The idea is that you can automate some of these tasks so that you can get to performing more interesting duties.
Infrastructure Automation Example
One of the best ways to understand the concept of infrastructure automation is through an example. Where I work, we require updates to an application each month. These updates include critical data that enables management to make decisions about the direction the company is going. The application developers would send out these updates each month via disk or it could be downloaded from their website.
There were two problems associated with this system:
- The disks would take from four to six weeks for delivery (where have I heard that before?)
- There was no way of knowing when the application would be available for download from their website
Initially, to resolve this problem, I would daily do to the developer’s website and look for a new version. Unfortunately, a few times they forgot to update the page on the website and It never indicated that a new version was available. Also, I had better things to do than go to their website each day looking at the same line of text (Don’t we all?).
(Superman music here) Infrastructure Automation To The Rescue! I wrote a small script in AutoIt that checked the download location on the developer’s website each day. If it found a new version of the application, it would download the application to my system and then notify me with a pop-up and an e-mail indicating that a new version was available. Way better than the daily visit to the website!
Scripting Tools
There are several different scripting systems available out there. This will provide an overview of some of the scripting systems available either with your operating system or available for free or open source. Some are cross-platform (i.e. they can be used on different operating systems) while others are platform specific (i.e. they will only work on Windows or Linux).
This is not meant to be an exhaustive list. Rather, these are some of the more common and popular ones out there. If you are proficient in a couple of these languages, it will make your life a lot easier!
- AutoIt - AutoIt is my personal favourite. It is freely available on the Internet, has a very active development team, and has the ability to create self-containted executables. While many other scripting languages require that you have the scripting engine already installed on the system, you can distribute an AutoIt executable to any machine and it will run from that machine. The main downside that I see with AutoIt is that it is designed with for Windows only but it might be possible to run some compiled scripts on Linux using Wine.
- BASH - BASH is an acronym for Bourne-Again SHell and it is the basis of many GNU systems including Linux. BASH scripts can be thought of as the Linux equivalent of batch files but BASH has a lot more flexibility built directly into it. BASH is a must for pretty much any Linux/Unix administrator.
- Batch Files - Batch files have been around since the early days of DOS and are still widely used today. There are two different flavours, depending on whether you are using a DOS/9x based version (e.g. Windows 98) or an NT based version (e.g. Windows XP). Batch files tend to be pretty limited in what they can do but I have seen some pretty creative things done with them.
- JScript - JScript is the Microsoft implementation of javascript. If you are familiar with the java language, you should be able to pick this up quite quickly. Works best with the Microsoft Windows Scripting Host (WSH) and in conjunction with Internet Explorer.
- KiXtart - KiXtart originated from Microsoft in the Netherlands. It was initially designed as a log on script processor that would configure end-users’ computers with appropriate settings for the network. It has, since then, turned into a very powerful tool that enables administrators to more easily manage their computer systems.
- Perl - Perl is a cross-platform language that has gained a lot of popularity with the Linux community and is often refered to as the duct-tape of the Internet. It is extremely powerful and can perform a multitude of administrative tasks. But, be warned, as with any powerful tool, there are a lot of options that can make it a bit daunting to the new user.
- Python - Python, like Perl, is a cross-platform language. It also is very popular with the Linux communities. A lot of complete applications are completely written in Python as well. This means the quick script you wrote that has now become so important to your company can be turned into a real application. Definitely worth a look!
- VBScript - VBScript is a sibling language to JScript. It was designed to work with WSH to enable administrators to monitor and modify systems. It is also a core component is Microsoft Active Server Pages (ASP). VBScript has become the primary scripting language used by many people. In fact, I did almost everything in VBScript prior to discovering AutoIt.
Sample Scripts
Just to give you a feel for how these different scripting languages work, I have put together a quick script in each language so that you can compare them. This script will ask the user their name and then respond with “Hello, Name. Pleased to meet you.”
AutoIt
$Name = InputBox("Name", "Please enter your name:") MsgBox(0,"Hello!","Hello, " & $Name & ". Pleased to meet you.")
Download this code: hello.au3
BASH
#!/bin/bash echo -n "Please enter your name: " read Name echo "Hello, $Name. Pleased to meet you."
Download this code: hello.sh
Batch File
@ECHO OFF ECHO Please enter your name COPY CON USRINPUT.TMP CLS ECHO Hello, TYPE USRINPUT.TMP ECHO . ECHO Pleased to meet you. del USRINPUT.TMP
Download this code: hello.bat
Note: You need to press F6 and then the ENTER key to enter your name for this script.
JScript
function InputBox(text, value) { var oIE = WScript.CreateObject("InternetExplorer.Application"); oIE.navigate("about:blank"); oIE.Visible = 0; while (oIE.Busy) {} var obj = oIE.Document.Script; var input = obj.prompt(text, value); oIE.Quit(); return input; } var Name = InputBox("Please enter your name:", ""); WScript.Echo("Hello, "+Name+". Pleased to meet you.");
Download this code: hello.js
Note: This user the Internet Explorer object in order to create an input prompt.
Kixtart
? "Please enter your name: "
GETS $Name
MessageBox("Hello, " + $Name + ". Pleased to meet you.", "Hello!")
Download this code: hello.kix
Perl
#! usr/bin/perl print "Please enter your name:"; $age = <>; print "Hello, $age. Pleased to meet you.";
Download this code: hello.pl
Python
name = raw_input("Please enter your name: ") print "Hello, %s. Pleased to meet you." % name
Download this code: hello.py
VBScript
Name = InputBox("Please enter your name:","Name")
MsgBox("Hello, " & Name & ". Pleased to meet you.")
Download this code: hello.vbs
Conclusion
With the number of different infrastructure automation tools available today, it would be prudent for any systems administrator to learn at least one of the above mentioned scripting languages. It enables you to be more productive and concentrate on the tasks that truly require your attention.
| Trackback link - http://www.dailycupoftech.com/infrastructure-automation-primer/trackback/ |
|


March 28th, 2007 at 5:18 pm
Folder Recursion in AutoIt FreeNAS Basic Configuration FreeNAS System and Skill Requirements Have Your Lost USB Drive Ask For Help How To Be A Better Blogger HowTo Backup Your Website Files HowTo Install FreeNAS Infrastructure Automation Primer InstaCalc Contest Installing AutoIt Installing TrueCrypt Installing Ubuntu Desktop Series Installing Ubuntu Desktop Part 1 Installing Ubuntu Desktop Part 2 Installing Ubuntu Desktop Part 3 Is Internet Explorer 7 Spying on Me?