Created
May 11, 2014 13:34
-
-
Save krimdomu/b561cce86ef5c41e8b7c to your computer and use it in GitHub Desktop.
different sudo authentication for servers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
if( !exists $args{T} ) { | |
map { $_->{auth}->{sudo_password} = read_password($_); } | |
Rex::Group->get_group('somegr'); | |
} | |
task "test", group => 'somegr', sub { | |
sudo make { say run "id"; }; | |
}; | |
sub read_password { | |
my ($server) = @_; | |
print "Password please ($server): "; | |
ReadMode "noecho"; # don't echo anything | |
my $password = <STDIN>; | |
chomp $password; | |
ReadMode 0; # reset terminal so it echo again | |
print "\n"; # print a newline, for better output visibility | |
return $password; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment