Chef - Write Chef recipes in Perl instead of Ruby.
Learn more about Chef - http://wiki.opscode.com/display/chef
Version 0.01
This is a proof of concept - it shows the path for future integration, but all the steps are not complete. What remains:
* You cannot write Attribute or Definition files in Perl. * At the moment, all your Perl recipes must live in the same cookbook. * There is very little error handling. (ah, who am I kidding - there is none)
Example:
use Chef; resource file => '/tmp/foo', sub { my $r = shift; $r->owner('adam'); $r->action('create'); }; resource file => '/tmp/' . node->{attributes}->{hostname} . "_created_with_perl", sub { my $r = shift; $r->action('create'); };
Would create a file called /tmp/foo, and one called /tmp/HOSTNAME_created_with_perl. (Where HOSTNAME is, well, your hostname).
To use this module, you will need to install Chef, place the included cookbook in your cookbook repository, and place your perl based recipes in files/default/perl_recipes.
We export two functions in to your namespace, resource and node.
Returns the Chef::Node object. This allows you to see what recipes are applied to this node via:
node->{recipes} # Returns an array of recipe names
Also allows you to access all the nodes attributes via:
node->{attributes} # Returns all the nodes attributes
Any changes you make to the node object do not currently persist back in to Chef. (ie: you cannot use them in subsequent recipes.) This is likely to change once integration is complete.
Create a new Chef Resource. Valid resources are listed at:
L<http://wiki.opscode.com/display/chef/Resources>
An example of translating from the ruby version to perl:
# The ruby version package "sudo" do action :install end # Make sure sudo is always at the latest version resource package => "sudo", sub { my $r = shift; $r->action("upgrade"); }
Essentially, you create new resources by calling this method with the resource type (package, remote_file, etc.), resource name ("sudo", "/tmp/foo"), and a subroutine which recives a Chef::Resource object. You can then set attributes of the resource via that object. (Hence, my $r = shift).
Adam Jacob, <adam at opscode.com>
<adam at opscode.com>
You can find the source on GitHub at http://github.com/adamhjk/chef-perl
Please report bugs to http://tickets.opscode.com.
You can find documentation for this module with the perldoc command.
perldoc Chef
You can also look for information at:
Opscodes Ticket Tracking System:
http://tickets.opscode.com
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Chef
CPAN Ratings
http://cpanratings.perl.org/d/Chef
Search CPAN
http://search.cpan.org/dist/Chef/
Copyright 2009 Opscode, Inc., all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Chef, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Chef
CPAN shell
perl -MCPAN -e shell install Chef
For more information on module installation, please visit the detailed CPAN module installation guide.