These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for does the API encompass Webmin functionality? on the new forum.
Hi Guys
Does the remote API allow the calling of Webmin features? more specifically for the cluster functionality.
I need to write a script which can use the existing Cluster functionality to execute a command on several different servers, I need this script to run after the logs are rotated on 1 of our servers.
Cheers
Howdy K P,
Not directly, though there are two other ways to access the Webmin API remotely, with XML-RPC probably being the most appropriate. It's pretty low-level, though. We're thinking on ways to improve the API situation, and trying to come up with ways to make high-level functionality of the rest of Webmin available as a library.
At this point, for something as simple as what you're doing, you might find using ssh is simpler. Just install keys for all of the "slave" servers that don't require a passphrase on the "master" server, and then run whatever commands you need to run. Something like:
ssh virtualmin@virtualmin.com '/home/virtualmin/bin/updaterepo.sh'
This is what I do to execute our software repository update script whenever I rsync my local repo to the virtualmin.com one. If you don't have to do anything complicated, like modifying configuration files, this might always be the simplest choice.
There's a quick guide to setting up public/private keys here:
http://www.ece.uci.edu/~chou/ssh-key.html
--
Check out the forum guidelines!
Hi Joe
Do you have any examples of using the xml rpc? we appreciate the other approach would be easier (And i'll bare that in mind for a last resort) but the xml rpc may come in handy for other problems aswell (such as restarting apache on the other server s when a new account is created).
Cheers
I don't think are actually are any examples out there in the wild. I'll ask Jamie to add a few pointers and examples to the new Webmin documentation wiki.
--
Check out the forum guidelines!
Hi all,<p>
Webmin's XML-RPC api allows you to call low-level module functions remotely .. basically, the API is the same as if you were writing your own module that was calling functions locally. For example, to list and create aliases you could use a program like this :<p>
[pre]
#!/usr/bin/perl
# Demo program to list mail aliases, and either create or delete one
use Frontier::Client;
use Data::Dumper;
chop($url = `cat url.txt`);
eval {
$server = Frontier::Client->new('url' => $url);
};
$@ && die "Failed to create server : $@";
$conf = $server->call("sendmail::get_sendmailcf");
$afile = $server->call("sendmail::aliases_file", $conf);
$aliases = $server->call("sendmail::list_aliases", $afile);
print "Found ",scalar(@$aliases)," mail aliasesn";
($already) = grep { $_->{'name'} eq 'foobar' } @$aliases;
if ($already) {
print "Alias foobar -> $already->{'values'}->[0] exists, deleting itn";
$server->call("sendmail::delete_alias", $already);
print "Done deletionn";
}
else {
print "Adding alias foobarn";
$alias = { 'name' => 'foobar',
'enabled' => 1,
'values' => [ "jcameron@webmin.com" ],
};
$server->call("sendmail::create_alias", $alias, $afile);
}
[/pre]
This code assumes that a file containing the Webmin URL exists in url.txt, formatted like :<p>
<i>http://root:password@webminserver:10000/xmlrpc.cgi</i><p>
As you can see, this is pretty low-level .. many function calls are needed to perform even a basic task. Virtualmin offers an HTTP-based API that operates at a higher level, but it doesn't yet extend to clustering.<p>
--
Check out the forum guidelines!
Hi Guys
Thanks for the example, I think i may go another route.
The basic problem is we have 3 servers, 1 is a Cluster Manager to create the accounts (configs and home directories etc are stored on a NAS and shared) and the other 2 are the actual load balanced WWW servers.
Both WWW servers write logs to the same location (we're only experimenting with this) but log rotation is handled by the Cluster Manager, so I somehow need to get apache to restart on the WWW's after the log rotation (this also extends to when creating new accounts).
I appreciate this is not what Webmin/Virtualmin is best geared towards - but until we can find a more effective solution I think I'll hack the apachectl on the Cluster Manager so that it automatically restarts apache on the WWW servers (using the SSH method you suggested), this should hopefully resolve both issues.
If you fancy adding some more functionality to better support this type of clustering please let me know, i think we've built a pretty good setup.