Rex

file für Datei hochladen s. nächster Link: http://search.cpan.org/~jfried/Rex-0.43.5/lib/Rex/Commands/File.pm

http://www.rexify.org/api/Rex/Commands/File.pm.html

http://www.rexify.org/api/Rex/Commands/Fs.pm.html

http://wiki.ubuntuusers.de/SSH

Beispiel Rexfile:

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa user@server

# Test für Warnung in der Ausgabe
Rex::Logger::info("TEST-WARNUNG", "warn");
# User mit sudo-Rechten und dessen ssh-Keys
user "user";
private_key "/home/local_user/.ssh/id_rsa";
public_key "/home/local_user/.ssh/id_rsa.pub";
auth_key;
# Alles mit sudo-Rechten ausführen
sudo_password "test123";
sudo TRUE;
group clients => "berny";
task "upload", group => "clients", sub {
say "Kopiere my_testfile auf Clients";
# file "</remote_path/upload_file>", source => "</local_path/to/upload_file>";
file "/etc/my_testfile",
source => "my_testfile";
};
task "mkdir", group => "clients", sub {
say "mkdir testdir";
mkdir( "/home/user/testdir" );
};

Rexfile um quagga in einem user-Account konfigurierbar zu machen:

user "user"; private_key "/home/local_user/.ssh/id_rsa"; public_key "/home/local_user/.ssh/id_rsa.pub"; auth_key; sudo_password "<PASSWORD>"; sudo TRUE; group clients => "berny"; group testclient => "berny"; # Ziel-User und Rechte für den quagga-Ordner my $user = "keinpasswort"; my $dmode = "777"; # Vollzugriff auf den Ordner my $fmode = "666"; # Volle Schreib-/Leserechte auf die Konfig-Dateien task "mkquagga", group => "testclient", sub { say "quagga-Ordner anlegen!"; mkdir( "/home/".$user."/quagga", owner => $user, group => $user, mode => $dmode, ); say "confs in /etc/quagga erzeugen!"; run "touch /etc/quagga/zerbra.conf"; run "touch /etc/quagga/ripd.conf"; run "touch /etc/quagga/ospfd.conf"; say "daemons aktivieren"; sed "ospfd=no", "ospfd=yes", "/etc/quagga/daemons"; sed "ripd=no", "ripd=yes", "/etc/quagga/daemons"; sed "zebra=no", "zebra=yes", "/etc/quagga/daemons"; say "Neue config-Pfade setzen!"; sed "zebra_options=\" --daemon -A 127.0.0.1\"", "zebra_options=\" --daemon -A 127.0.0.1 -f /home/".$user."/quagga/zebra.conf\"", "/etc/quagga/debian.conf"; sed "ripd_options=\" --daemon -A 127.0.0.1\"", "ripd_options=\" --daemon -A 127.0.0.1 -f /home/".$user."/quagga/ripd.conf\"", "/etc/quagga/debian.conf"; sed "ospfd_options=\" --daemon -A 127.0.0.1\"", "ospfd_options=\" --daemon -A 127.0.0.1 -f /home/".$user."/quagga/ospfd.conf\"", "/etc/quagga/debian.conf"; say "sample configs kopieren"; cp ( "/usr/share/doc/quagga/examples/zebra.conf.sample", "/home/".$user."/quagga/zebra.conf" ); cp ( "/usr/share/doc/quagga/examples/ospfd.conf.sample", "/home/".$user."/quagga/ospfd.conf" ); cp ( "/usr/share/doc/quagga/examples/ripd.conf.sample", "/home/".$user."/quagga/ripd.conf" ); say "Rechte setzen"; chmod $fmode, "/home/".$user."/quagga/*"; chown $user, "/home/".$user."/quagga/*"; chgrp $user, "/home/".$user."/quagga/*"; }; task "rmdirquagga", group => "testclient", sub { say "quagga-Ordner löschen"; rmdir( "/home/".$user."/quagga"); };