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 master.host
$ 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 target.host
$ cpanm Sparrow
$ yum install curl
Here is simple schema of master -> target hosts interaction:
+-----------------+
| | ssh
| |------------> < host-1 > 192.168.0.1
| <master host> | ssh
| {sparrowdo} |------------------> < host-2 > 192.168.0.2
| | ssh
| |-----------------------> < host-N > 192.168.0.3
| |
+-----------------+
+-------------+
| |
| <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 master.host
$ 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 target.host
He is what I have for my test target box:
$ sparrowdo --host=192.168.0.1
running sparrow tasks on 192.168.0.1 ...
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'
1..3
ok
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.
Regards.
Alexey
Leave a comment