Skip to content

Instantly share code, notes, and snippets.

View ferki's full-sized avatar
🆓
I accept new customers

Ferenc Erki ferki

🆓
I accept new customers
View GitHub Profile
@ferki
ferki / Rexfile
Last active April 26, 2016 13:20
ssh tunneling
use Rex -feature => qw(1.3);
user 'my_user_on_target';
#Rex::Config->set_openssh_opt(
# LocalForward => 'localhost:2222 final.target.host:22' );
task 'runs_on_target', 'localhost:20000', sub {
say run 'hostname';
};
@ferki
ferki / nopaste
Created April 20, 2016 14:46
load file into redis
time perl -MRedis::Fast -MPath::Tiny=path -E 'my $redis = Redis::Fast->new; my $fh = path($ARGV[0])->openr_raw; while (my $line = <$fh>) { chomp $line; $redis->rpush("adjust_logs", $line) }' ferki.log
@ferki
ferki / nopaste
Created July 5, 2016 21:42
cmdb test
use Rex -feature => ['1.4'];
use DDP;
task 'a', sub {
my $cmdb = get cmdb;
p $cmdb;
};
@ferki
ferki / Rexfile
Last active July 6, 2016 13:25
dumpcmdb
use Rex -feature => ['1.4'];
use DDP;
desc 'Dump CMDB information';
no_ssh task 'dumpcmdb', sub {
my $params = shift;
my $cmdb = get cmdb( $params->{node}, $params->{host} );
p $cmdb;
};
@ferki
ferki / Rexfile
Created July 6, 2016 13:34
rex custom cmdb
set cmdb => {
type => 'YAML',
path => sub {
my ( $self, $item, $server ) = @_;
return ( "cmdb/$server.yml", "cmdb/default.yml" );
},
merge_behavior => 'LEFT_PRECEDENT',
};
@ferki
ferki / modulelist
Last active October 4, 2016 13:38
rex modules owned by ferki
Rex::Commands::Mkfs
Rex::Cron::FreeBSD
Rex::Helper::File::Spec
Rex::Helper::File::Stat
Rex::Helper::File::Stat::Unix
Rex::Helper::File::Stat::Win32
Rex::Helper::Rexfile::ParamLookup
Rex::Interface::Exec::IOReader
Rex::Pkg::Arch
Rex::Resource::firewall
@ferki
ferki / backup
Last active July 28, 2016 14:59
full system backup and restore with rsync
#!/bin/bash
source=${1:-/}
destination=${2:-/mnt/backup}
rsync --archive \
--hard-links --human-readable --inplace --numeric-ids \
--delete --delete-excluded --progress \
--exclude-from $source/home/ferki/.backup/filter \
$source $destination
use Rex -feature => [ '1.4', 'exec_autodie' ];
user 'myuser';
environment production => sub {
group destination => 'server1';
};
environment staging => sub {
group destination => 'server2';
@ferki
ferki / Rexfile
Last active October 29, 2016 10:41
generate Rex CMDB pathes programmatically
use Rex -feature => [qw(1.4)];
set cmdb => {
type => 'YAML',
path => sub {
my ( $self, $item, $server ) = @_;
my @pathes;
push @pathes, "cmdb/hosts/$server.yml";
push @pathes, "cmdb/items/$item.yml";
@ferki
ferki / Rexfile
Last active May 29, 2017 16:51
Hidden tasks in Rex
task 'hidden', sub {
say q(Ssshh! I'm hiding!);
}, { dont_register => TRUE };