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 June 19, 2023 22:00
Preview file changes with Rex
use Rex -feature => [ '1.4', 'exec_autodie' ];
use Rex::Hook::File::Diff; # show diff of file changes by Rex
use if $ENV{PREVIEW}, 'Rex::Hook::File::Impostor'; # use extra hooks if PREVIEW is true
desc 'Demonstrate file preview';
task 'demo', sub {
file '/tmp/rex_file_preview_demo', content => scalar localtime();
};
@ferki
ferki / .bashrc
Created June 12, 2023 22:02
.bashrc excerpt for gpg settings
#gpg
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye &> /dev/null
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
@ferki
ferki / vim_plugins
Created April 24, 2023 20:05
Vim plugins
ale
auto-pairs
diffchar.vim
eregex.vim
fzf.vim
goyo.vim
gundo.vim
limelight.vim
markdown-preview.nvim
mkdx
@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 ) )
@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 / 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
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 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 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
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';