Sparrowdo - a simple configuration management tool written on Perl6 and consuming sparrow plugins

Hi!

This is the very first ( to take it for a spin ) release of sparrowdo - a simple configuration management tool written on Perl6 and consuming sparrow plugins.

This is where Perl5, Perl6 could make a synergy. Consider a simple example of sparrowdo scenario:

$ cat sparrowfile

use v6;

use Sparrowdo;

task_run  %(
  task => 'install my packages',
  plugin => 'package-generic',
  parameters => %( list => 'git-core carton cpanminus' )
);

task_run  %(
  task => 'install psgi app',
  plugin => 'perl-app',
  parameters => %( 
    'app_source_url' => 'https://github.com/melezhik/web-app.git',
    'git_branch' => 'master',
    'http_port' => 3030
  )
);

All it does is:

  • installing some packages required for further deployment ( git, cpanm, carton )
  • installing perl5 psgi application by fetching source code from remote repository, installing dependencies with cpanfile/carton and running service using Ubic and Starman.

Here we go. On my vagrant Ubuntu 14.04 Trusty box I will have:

$ sparrowdo --ssh_user=vagrant  --ssh_port=2200 --host=127.0.0.1  --verbose 
running sparrow tasks on 127.0.0.1 ... 
running task <install my packages> plg <package-generic> 
parameters:
{list => git-core carton cpanminus}
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow index update"'
get index updates from SparrowHub ... OK
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow project remove sparrowdo"'
project sparrowdo successfully removed

ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow plg install package-generic"'
public@package-generic is uptodate (0.1.1)
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow project create sparrowdo"'
project sparrowdo successfully created

ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow task add sparrowdo install_my_packages package-generic"'
task - set plugin to public@package-generic

task sparrowdo/install_my_packages successfully created

install_my_packages.json                                                                                                                              100%   41     0.0KB/s   00:00    
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow task run sparrowdo install_my_packages --json /tmp/install_my_packages.json"'
# cd /home/vagrant/sparrow/plugins/public/package-generic 
# export PATH=$PATH:local/bin 
# export PERL5LIB=local/lib/perl5:$PERL5LIB 
# strun --root ./ --json /tmp/install_my_packages.json --json /tmp/install_my_packages.json

/tmp/.outthentic/31112/home/vagrant/sparrow/plugins/public/package-generic/story.t .. 
# [/home/vagrant/sparrow/plugins/public/package-generic/modules/apt-get]
# Package: git-core
# Version: 1:2.1.4-2.1
# Status: install ok installed
ok 1 - output match 'Status: install ok installed'
# [/home/vagrant/sparrow/plugins/public/package-generic/modules/apt-get]
# Package: carton
# Version: 1.0.12-1
# Status: install ok installed
ok 2 - output match 'Status: install ok installed'
# [/home/vagrant/sparrow/plugins/public/package-generic/modules/apt-get]
# Package: cpanminus
# Version: 1.7014-1
# Status: install ok installed
ok 3 - output match 'Status: install ok installed'
# [/home/vagrant/sparrow/plugins/public/package-generic]
# done
ok 4 - output match 'done'
1..4
ok
All tests successful.
Files=1, Tests=4,  1 wallclock secs ( 0.01 usr  0.01 sys +  1.28 cusr  0.07 csys =  1.37 CPU)
Result: PASS
running task <install-psgi-app> plg <perl-app> 
parameters:
{app_source_url => https://github.com/melezhik/web-app.git, git_branch => master, http_port => 3030}
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow plg install perl-app"'
public@perl-app is uptodate (0.1.5)
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow project create sparrowdo"'
project sparrowdo already exists - nothing to do here ... 

ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow task add sparrowdo install-psgi-app perl-app"'
task - set plugin to public@perl-app

task sparrowdo/install-psgi-app successfully created

install-psgi-app.json                                                                                                                                 100%  110     0.1KB/s   00:00    
ssh -q -tt -p 2200 vagrant@127.0.0.1 ' sudo bash -c "export LC_ALL=en_US.UTF-8 ; sparrow task run sparrowdo install-psgi-app --json /tmp/install-psgi-app.json"'
# cd /home/vagrant/sparrow/plugins/public/perl-app 
# export PATH=$PATH:local/bin 
# export PERL5LIB=local/lib/perl5:$PERL5LIB 
# strun --root ./ --json /tmp/install-psgi-app.json --json /tmp/install-psgi-app.json

/tmp/.outthentic/31292/home/vagrant/sparrow/plugins/public/perl-app/story.t .. 
# [/home/vagrant/sparrow/plugins/public/perl-app]
# useradd: user 'perl-app' already exists
# Ubic is up to date. (1.59)
# Ubic::Service::Plack is up to date. (1.18)
# Starman is up to date. (0.4014)
# Stopping perl-app... stopped
# Already on 'master'
# Your branch is up-to-date with 'origin/master'.
# Already up-to-date.
# Installing modules using /opt/perl-app/cpanfile (deployment mode)
# Complete! Modules were installed into /opt/perl-app/local
# Starting perl-app... started
# perl-app  running
# install-ok
ok 1 - output match 'Complete! Modules were installed into'
ok 2 - output match 'Starting perl-app... started'
ok 3 - output match 'install-ok'
1..3
ok
All tests successful.
Files=1, Tests=3,  3 wallclock secs ( 0.01 usr  0.02 sys +  0.74 cusr  0.15 csys =  0.92 CPU)
Result: PASS

Asciinema video

A visual example of the sparrowdo scenario could be found here -

asciicast

Volunteers/Contributors needed!!!

Interested in Perl 6 automation for devops? Sparrowdo could be a good greenfield project to start with. Not involved in Perl 6 and use Perl 5 ? - that is fine, sparrowdo USES sparrow plugins which are to be written on Perl5|Bash|Ruby! So why not write a useful plugin to share with? Here is a short list of plugins now - use it as examples and create your own one! And finally sparrow itself is written on Perl5! Just contribute somehow into sparrow/sparrowhub/sparrowdo echo system! Merge requests are welcome!

-- Regards

Alexey

Leave a comment

About melezhik

user-pic Dev & Devops --- Then I beheld all the work of God, that a man cannot find out the work that is done under the sun: because though a man labour to seek it out, yet he shall not find it; yea further; though a wise man think to know it, yet shall he not be able to find it. (Ecclesiastes 8:17)