Sparrowdo automation. Part 1. Installing cpan packages.

Here I start a series of posts on sparrowdo configuration management tool usage.

Installing sparrowdo

Sparrowdo implies installing software on both master and target host. Following "push" approach one should install a sparrowdo on master host where from he starts a ssh sessions against target hosts to be configurable:

$ ssh 
$ panda install Sparrowdo

Once you install a sparrowdo you need to install a sparrow client on every host where you want to start deployments. Sparrow acts like client to carry out deployment tasks initiated from master host.

$ ssh 
$ cpanm Sparrow
$ yum install curl

Here is simple schema of master -> target hosts interaction:

  |                 |    ssh
  |                 |------------> < host-1 >
  | <master host>   |    ssh
  | {sparrowdo}     |------------------> < host-2 >
  |                 |    ssh 
  |                 |-----------------------> < host-N >
  |                 |

  |             |
  | <host>      |
  |             |
  | {sparrow}   | 
  | {curl}      |
  |             |

That is it. Now you are ready to start your very first deployment with sparrowdo. As the title of the post has we want to install cpan packages.

Sparrowdo scenarios

Sparrowdo scenarios are written in Perl6. Following Sparrowdo API basically all you need is to find a proper sparrow plugin and run it with parameters. Luckily we have a proper one to solve our task - cpan-package. In most cases Sparrowdo way to configure servers is quite simple - find a proper plugins to handle your specific tasks and use them. We could treat sparrow plugins like a useful primitives to accomplish a complex tasks. This conception is very similar to what in chef or puppet is called resources , or in ansible is called modules. In case you miss a plugin to solve your task you are encouraged to create a new one, in easy way, but this series of posts are more focused on sparrowdo end client usage rather on sparrow plugin development.

Ok, let get back to cpan-package plugin, and just use it in our sparrowdo scenario:

$ ssh
$ cat sparrowfile

task_run  %(
  task => 'install some cpan packages',
  plugin => 'cpan-package',
    parameters => %(
    list => 'CGI DBI',
    install-base => '/opt/perl'

The content of sparrowfile is quite self-explanatory. We want to install 2 packages CGI and DBI into /opt/perl install base directory. Here we go!

A few words about ssh setup

A sparrowdo ssh setup implies 2 things so everything works fine:

  • a user from master host has password-less ssh access to target host
  • a user has (password-less) sudo on target host

You may specify user explicitly when run sparrowdo scenario or current user would be used implicitly when connecting by ssh to target host. From the master host now we run:

$ sparrowdo -h

He is what I have for my test target box:

$ sparrowdo --host=
running sparrow tasks on ...
running task <install some cpan packages> plg <cpan-package>
parameters: {install-base => /opt/perl, list => CGI DBI}
/tmp/.outthentic/5385/opt/sparrow/plugins/public/cpan-package/story.t ..
# [/opt/sparrow/plugins/public/cpan-package/modules/cpanm]
# install CGI into /opt/perl ...
# Successfully installed HTML-Parser-3.72 (upgraded from 3.64)
# Successfully installed Test-Deep-1.120
# Successfully installed Sub-Uplevel-0.25
# Successfully installed Carp-1.38 (upgraded from 1.11)
# Successfully installed Test-Warn-0.30
# Successfully installed CGI-4.31 (upgraded from 3.51)
# 6 distributions installed
# install ok
ok 1 - output match 'install ok'
# [/opt/sparrow/plugins/public/cpan-package/modules/cpanm]
# install DBI into /opt/perl ...
# Successfully installed DBI-1.636
# 1 distribution installed
# install ok
ok 2 - output match 'install ok'
# [/opt/sparrow/plugins/public/cpan-package]
# cpan-package-done
ok 3 - output match 'cpan-package-done'
All tests successful.
Files=1, Tests=3, 91 wallclock secs ( 0.02 usr  0.01 sys + 72.58 cusr  8.26 csys = 80.87 CPU)
Result: PASS

A few things to say here:

  • A sparrowdo reports are TAP reports due to TDD nature of sparrow plugins.
  • You may have extra information here by adding --verbose parameter for sparrowdo client to see a ssh commands details and some other indeterminate steps taken by sparrowdo when deploying your server.

So, keep your eye on following sparrowdo presentations.



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)