nysus has asked for the wisdom of the Perl Monks concerning the following question:
I've been studying the Rex module. Rex allows you to manage remote servers over ssh using a configuration file. It uses a crude "DSL," or "domain specific language" for adding tasks through a configuration file. Here's a sample of the configuration file:
set user => "root"; group "frontend" => "server1", "server2", "server3", "server4"; group "local" => "mango", "debian01"; desc "Show uptime"; task "uptime", group => "local", sub { run "uptime"; }; desc "Show free space"; task "show_disk_free", sub { run "df -h"; }; desc "Upload file"; task "upload", "mango", sub { upload "/tmp/test.txt", "/tmp/test.txt"; };
The idea behind this DSL is straightforward. Each keyword is a call to a function and the arguments are separated by commas. I'm not even sure if this is the true definition of a DSL but that's what they call it in their documentation.
Anyway, I've never seen anything like this before and I'm wondering if there are any advantages to this approach to a configuration file. Are there any big advantages/disadvantages to this approach? And why not just use something more universal like JSON? My experience with config files is limited to writing my own Simple::Config files and .ini files with Dist::Zilla. So I'm interested in learning more about best practices for setting up config files. Thanks.
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks
|
|---|