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
Created May 23, 2020 13:20
collect task results to display after the task
use strict;
use warnings;
use Rex -feature => [ '1.4', 'exec_autodie' ];
use Data::Printer;
BEGIN {
use Rex::Shared::Var;
share qw(%results_for);
}
@ferki
ferki / Secret-Store.pod
Last active September 30, 2020 05:35
Secret::Store POD preview

NAME

Secret::Store - A module to interact with secret stores

@ferki
ferki / Rex-Hook-File-Impostor-is-published.md
Last active September 30, 2020 05:40
Rex::Hook::File::Impostor POD preview
@ferki
ferki / Rexfile
Created October 9, 2020 22:05
Rex and Secret::Store
use Rex;
use Secret::Store;
my $store = Secret::Store->new( backend => 'pass' );
sudo_password $store->get('sudo/username');
task 'whoami' => sub {
sudo TRUE;
say run 'whoami';
@ferki
ferki / Rexfile
Created November 30, 2020 18:34
Rex::Hook::File::Diff example
use Rex;
use Rex::Hook::File::Diff;
task 'diff_example', sub {
file '/tmp/diff.example',
content => gmtime();
};
@ferki
ferki / Rexfile
Last active April 22, 2021 09:08
rex reboot
use Rex -feature => [qw(1.4 exec_autodie)];
use Rex::Commands::SimpleCheck;
sayformat "[%h]>\t%s";
task 'reboot', sub {
my $server = connection->server;
my $port = Rex::Config->get_port( server => $server ) || 22;
@ferki
ferki / Rexfile
Created October 19, 2021 17:39
Rex dynamic CMDB with roles
use v5.24; # for postfix dereferencing below
use strict;
use warnings;
use Rex -feature => [ '1.4', 'exec_autodie' ];
use Rex::CMDB;
use File::Spec;
use YAML qw(LoadFile);
@ferki
ferki / Rexfile
Last active February 9, 2023 18:00
rex_on_change_trigger_restarts_shared_var
use 5.012;
use warnings;
use Rex -feature => [ '1.4', 'exec_autodie' ];
BEGIN {
use Rex::Shared::Var;
share qw($should_restart @services_to_restart);
}
@ferki
ferki / Rexfile
Last active February 19, 2023 17:21
Rex run with HEREDOC
use 5.26;
use Rex;
task 'heredoc_run', sub {
run 'foo', command => <<~'EOF',
f=$(cat /tmp/num)
if [ "$f" == 2 ]; then
ls -l / >/tmp/foo.txt
else
ls -l / >/tmp/bar.txt
@ferki
ferki / passthrough_ssh_config_for_net_openssh.diff
Created February 19, 2023 21:13
unsupported WIP: Rex passthrough .ssh/config for Net::OpenSSH backend
diff --git a/lib/Rex/Interface/Connection/OpenSSH.pm b/lib/Rex/Interface/Connection/OpenSSH.pm
index 33f01263..6ecbc462 100644
--- a/lib/Rex/Interface/Connection/OpenSSH.pm
+++ b/lib/Rex/Interface/Connection/OpenSSH.pm
@@ -53,28 +53,16 @@ sub connect {
$self->{__auth_info__} = \%option;
Rex::Logger::debug("Using Net::OpenSSH for connection");
- Rex::Logger::debug( "Using user: " . $user );
- Rex::Logger::debug( Rex::Logger::masq( "Using password: %s", $pass ) )