In this post I want to share my chef cookbook called cpan. Chef is the modern platform for deploy automation and configuration. One of chef great feature - one may create custom recipes to deploy/configure specific applications, written on any languages. When I first met with chef, I had already had some experience on deploying perl applications. I used standard build cycle:
perl Build.PL ./Build ./Build installdeps ./Build test ./Build install
So the idea of integrating perl application install come into my mind in natural way.

With cpan cookbook one may do standard perl build/test/install idioms using chef. Here I am putting some use cases, just to give some sense of what it is. If you like it, you may learn more on http://community.opscode.com/cookbooks/cpan.

Cpan cookbook use cases

Installing application, distributed with tar-ball. Let's say you have already fetch and store tar-ball with others chef resources (the following code is self-explanatory). So you may easily install it into given install base:
remote_file '/tmp/app-0.0.1.tag.gz' source 'http://local.server/app-0.0.1.tag.gz' end execute 'cd /tmp/ && tar -xzf app.tag.gz' cpan_client 'my application' do user 'root' group 'root' install_type 'application' action 'install' install_base '/path/to/your/application/home' cwd '/tmp/app-0.0.1' end
The same thing with your perl5lib paths taking into account ('/home/user/alex/perl5lib/'):
cpan_client 'my application' do user 'root' group 'root' install_type 'application' action 'install' install_base '/path/to/your/application/home' cwd '/tmp/app-0.0.1' inc %w{ /home/user/alex/perl5lib/ } end
If you need just installing arbitrary cpan module, here some examples to start. Install by given link:
cpan_client "http://search.cpan.org/CPAN/authors/id/M/MA/MARKSTOS/CGI. +pm-3.59.tar.gz" do user 'root' group 'root' module_name 'CGI' action 'install' end
Or just rely on your cpan mirrors:
cpan_client 'CGI' do user 'root' group 'root' install_type 'cpan_module' action 'install' end
With cpan cookbooks you may even play with version requirements. Require minimal version:
cpan_client 'CGI' do user 'root' group 'root' version '3.55' install_type 'cpan_module' action 'install' end
Do not install if already installed:
cpan_client 'CGI' do user 'root' group 'root' version '0' install_type 'cpan_module' action 'install' end
Try to upgrade to highest possible version:
cpan_client 'CGI' do user 'root' group 'root' install_type 'cpan_module' action 'install' end
If you install by distributive, you may even require concrete version:
cpan_client 'http://search.cpan.org/CPAN/authors/id/M/MA/MARKSTOS/CGI. +pm-3.59.tar.gz' do user 'root' group 'root' module_name 'CGI' version '=3.59' action 'install' end
Other examples to check out is on http://community.opscode.com/cookbooks/cpan.

In reply to chef cpan cookbook by melezhik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.