Skip to content

Instantly share code, notes, and snippets.

@krimdomu
krimdomu / devenv.lock
Created December 5, 2023 17:23
Python, psycopg2 glibc problem
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1701187605,
"narHash": "sha256-NctguPdUeDVLXFsv6vI1RlEiHLsXkeW3pgZe/mwn1BU=",
"owner": "cachix",
"repo": "devenv",
"rev": "a7c4dd8f4eb1f98a6b8f04bf08364954e1e73e4f",
use Rex::Commands::SimpleCheck;
sub wait_for_system_to_come_back {
my ($server) = @_;
# give some time for the reboot
Rex::Logger::info("Waiting for system reboot of $server...");
sleep 30;
while ( !is_port_open $server, 22 ) {
@krimdomu
krimdomu / gist:cd47fd764c8a3b8fc5a7
Created March 2, 2015 19:45
get servers of a task
my ($task) = Rex::TaskList->create()->get_task('taskname');
my @servers_raw = @{ $task->{server} };
my @servers = map { $_->get_servers } @servers_raw;
print Dumper \@servers;
@krimdomu
krimdomu / gist:199483a6dc5b8698a0de
Created August 26, 2014 17:51
test yaml for syntax
###
### USAGE: perl test-yaml.pl file.yml
###
use strict;
use warnings;
use Data::Dumper;
use YAML;
@krimdomu
krimdomu / gist:98086b9629ba815bbfc5
Created July 24, 2014 12:44
check if we are running in a batch
task "one", sub {
if(in_batch()) {
say "in batch";
}
};
task "two", sub {};
sub in_batch {
return Rex::Args->is_opt('b');
@krimdomu
krimdomu / gist:96fa06fa4d393c69d974
Created June 30, 2014 12:26
encryption with openssl
package Rex::Ext::Encryption::OpenSSL;
use Rex -base;
use Carp;
use Crypt::OpenSSL::RSA;
use MIME::Base64;
require Exporter;
use base qw(Exporter);
use vars qw(@EXPORT);
@krimdomu
krimdomu / gist:46efdc68b4067e9b792c
Created June 26, 2014 18:27
patch system and reboot
use Rex -feature => ['0.45'];
use Rex::Commands::SimpleCheck;
user "root";
password "box";
group servers => "10.211.55.168", "10.211.55.169";
# this task is flagged with "no_ssh". so it won't create a ssh connection
# to the server, but the connection() method works as usual
@krimdomu
krimdomu / gist:426c16867f8ec1d5abcb
Created May 28, 2014 11:14
full stop rex execution
use POSIX ":sys_wait_h";
use Rex -feature => ['exit_status'];
group "servers", "localhost", "127.0.1.2";
task test => group => servers => sub {
my $output = run "hostname";
say $output;
@krimdomu
krimdomu / gist:b561cce86ef5c41e8b7c
Created May 11, 2014 13:34
different sudo authentication for servers
use Rex -feature => ['use_server_auth'];
use Term::ReadKey;
user "sudouser";
password "test";
group somegr => "10.211.55.28", "10.211.55.61";
# get the CLI parameters
my %args = Rex::Args->getopts;
@krimdomu
krimdomu / daemonize
Last active August 29, 2015 14:00
daemonize a script/programm
#!/usr/bin/perl
# USAGE: daemonize --user root --group root --pid_file /var/run/mydaemon.pid --command /usr/local/bin/myscript
use strict;
use warnings;
use Net::Server::Daemonize 'daemonize';
use Getopt::Long;
use File::Basename;