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 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 / 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 / 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 / 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 / Rexfile
Created August 18, 2015 09:48
get servergroup from parameter
use Rex -base;
use Getopt::Long;
my $buildserver;
GetOptions( 'buildserver=s' => \$buildserver );
group buildserver => $buildserver;
task 'a',
@ferki
ferki / Rexfile
Created August 17, 2015 12:54
passing values between tasks
use Rex -base;
task 'a', sub {
my $output_from_another_task = run_task 'b';
say $output_from_another_task;
};
task 'b', sub {
return 'I can pass scalars at least';
};
$ rex bench
[2015-06-13 15:27:07] <local> INFO - Running task bench on <local>
Benchmark: timing 100 iterations of new_large, new_small, old_large, old_small...
new_large: 2 0.11 0.11 0.62 0.03 100 None @ 114.94/s (n=100)
new_small: 2 0.06 0.16 0.52 0.06 100 None @ 125.00/s (n=100)
old_large: 108 0.17 0.21 101.85 5.35 100 None @ 0.93/s (n=100)
old_small: 2 0.11 0.28 0 0 100 None @ 256.41/s (n=100)
(warning: too few iterations for a reliable count)
Rate old_large new_large new_small old_small
old_large 0.930/s -- -99% -99% -100%
@ferki
ferki / Rexfile
Created May 29, 2015 12:07
initialize as root, setup as normal user
use Rex -base;
user 'deployer';
password 'userpass';
sudo_password 'userpass';
sudo TRUE;
auth for => initialize =>
user => 'root',
password => 'rootpass';
@ferki
ferki / rex.vim
Last active October 27, 2016 14:47
Rex highlighting for vim
# put this file into ~/.vim/after/syntax/perl/rex.vim and then remove this line
syn keyword perlStatementScalar after after_task_finished before before_task_start bios_boot cache cat case checkout command content create_home delete_lines_according_to delete_lines_matching do_task desc download ensure extract group groups_file home initialize is_dir is_file is_symlink key_auth line LOCAL mode needs no_overwrite on_change on_rollback only_if options owner parallelism partition pass_auth password path private_key public_key regexp report repository rm sayformat share size source ssh_key sudo sudo_password transaction type umount unless unlink update_package_db update_system user upload
syn keyword perlStatementList account append_if_no_such_line append_or_amend_line batch chgrp chmod chown clearpart cmdb cp create_user cron_entry file get i_run ln mount mv pkg run run_task say sed service symlink task template
syn keyword perlStatementHash environment set
syn keyword perlString FALSE
use Rex -feature => ['1.0'];
use Rex::Commands::Virtualization;
use Data::Dumper;
#parallelism 10;
use Rex::Group::Lookup::INI;
groups_file "hosts.ini";
user "root";