Skip to content

adokoy001/Perl-SSH-Task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perl-SSH-Task

A Parallel Remote Command Tool.

SYNOPSIS


# show mini help
 $ perl ssh_task.pl

# show registered servers generated by ./servers.conf
 $ perl ssh_task.pl --server-list

# show registered general tasks generated by ./tasks.conf
 $ perl ssh_task.pl --task-list

# execute registered command for registered remote servers or server labels
 $ perl ssh_task.pl my_server_01 my_secret_command_01
 $ perl ssh_task.pl my_favorit_servers my_secret_command_01

# execute registered command for all registered servers
 $ perl ssh_task.pl all my_secret_command_02

# execute given remote command 
 $ perl ssh_task.pl my_server_01 do "uname -a"

# execute given remote command as sudo
 $ perl ssh_task.pl my_server_01 do_sudo reboot

INSTALLATION and CONFIGURING

Clone this repository.


 $ git clone https://github.com/adokoy001/Perl-SSH-Task.git ./my_ssh_task
 $ cd my_ssh_task

Configure tasks.conf


 $ vim tasks.conf

   #{
   #        server_info => [
   #            ["hostname"],
   #            ["uname -a"],
   #            ["ifconfig"],
   #            ["free"],
   #            ["cat /proc/cpuinfo | grep processor"],
   #            ["uptime"]
   #           ],
   #        upgrade_apt => [
   #            [ {stdin_data => "$servers->{$server_name}->{password}\n"} ,
   #              "sudo -Sk -p '' "."apt-get update"],
   #            [ {stdin_data => "$servers->{$server_name}->{password}\n"} ,
   #              "sudo -Sk -p '' "."apt-get upgrade -y"]
   #           ],
   #        .
   #        .
   #        .
   #}

Define tasks into tasks.conf as shown as(Perl style). It should be array reference of array reference.

You can execute any command with sudo by using stdin_data option and password parameter $servers->{$server_name}->{password}.

Configure servers.conf


 $ vim servers.conf

   #{
   #    my_server_name_01 => {
   #        label => ['any_label','internal','development','my_favorite'],
   #        host => 'localhost',
   #        port => 22,
   #        user => 'myname',
   #        password => 'mypassword',
   #        sudo_password => 'sudo_mypassword',
   #        general_task => {
   #            server_info => 'server_info',
   #            upgrade => 'upgrade_apt',
   #            reboot => 'reboot'
   #           },
   #        specified_task => {
   #            test_1 => [["~/.plenv/shims/perl -v"]],
   #            test_1 => [["~/.plenv/shims/perl global"]]
   #           }
   #       },
   #       .
   #       .
   #       .
   #}

Configure servers.conf.

  • label : You can select target servers a given label at execute.
  • host : hostname or IP address
  • port : SSH port
  • user : login user name
  • password : login password. Set undef or delete this key when you use public key authentication.
  • sudo_password : password for sudo.
  • general_task : Named available task from tasks.conf
  • specified_task : Literally defined tasks only for this server

Configure config.conf if needed


 $ vim config.conf

   #{
   #    max_fork_num => 20,
   #    servers_conf_file => './servers.conf',
   #    tasks_conf_file => './tasks.conf',
   #    StrictHostKeyChecking => 'yes',
   #}

  • max_fork_num : Maximum number of simultaneous processing
  • servers_conf_file : Config file name for servers
  • tasks_conf_file : Config file name for tasks
  • StrictHostKeyChecking : Useful but dangerous OpenSSH option. If this value set no, warning for first time ssh connection will be ignored and '~/.ssh/known_hosts' will be updated automatically.

Install Required Perl Modules if needed


 $ cpanm --installdeps .

About

A Parallel Remote Command Tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages