Information Technology Reference
In-Depth Information
12.6.3 Compiled Languages
Compiled languages can be a good choice for large-scale automation. Automation written
in a compiled language typically scales better than the same automation written in a script-
ing language.
Compiled languages often used by system administrators include C, C++, and Go. As
described earlier, compiled languages are usually statically typed and catch more errors at
compile time.
12.6.4 Configuration Management Languages
Configurationmanagement(CM)languagesaredomain-specificlanguages(DSLs)created
specifically for system administration tasks. CM systems are created for maintaining the
configuration of machines, from low-level settings such as the network configuration to
high-level settings such as which services should run and their configuration files.
Configuration languages are declarative. That is, the programmer writes code that de-
scribes how the world should be and the language figures out which changes are needed
to achieve that goal. As discussed in Section 10.1.3 (page 213), some CM systems are de-
signed around convergent orchestration (bringing the system to a desired state) while oth-
ers favor directed orchestration (the ability to follow a multistep plan of action).
TwopopularCMsystemsareCFEngineandPuppet. Listing12.1 and Listing12.2 illus-
tratehowtospecifyasymboliclinkinCFEngineandPuppet,respectively. Listing12.3 and
Listing 12.4 show the equivalent tasks in Python and Perl, languages that are imperative
(not declarative). Notice that first two simply specify the desired state: the link name and
its destination. The Python and Perl versions, in contrast, need to check if the link already
exists, correct it if it is wrong, create it if it doesn't exist, and handle error conditions. A
high level of expertise is needed to know that such edge cases exist, to handle them prop-
erly, and to test the code under various conditions. This is very tricky and difficult to get
exactly right. The CM languages simply specify the desired state and leverage the fact that
the creator of the CM system has the knowledge and experience to do things correctly.
Listing 12.1: Specifying a symbolic link in CFEngine
Click here to view code image
files:
"/tmp/link -to -motd"
link_from => ln_s ("/ etc/motd ");
Search WWH ::




Custom Search