NAME

Chef - Write Chef recipes in Perl instead of Ruby.

Learn more about Chef - http://wiki.opscode.com/display/chef

VERSION

Version 0.01

WARNING

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)

SYNOPSIS

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.

EXPORT

We export two functions in to your namespace, resource and node.

FUNCTIONS

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.

resource

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).

AUTHOR

Adam Jacob, <adam at opscode.com>

SOURCE

You can find the source on GitHub at http://github.com/adamhjk/chef-perl

BUGS

Please report bugs to http://tickets.opscode.com.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Chef

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

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.