Chef - Write Chef recipes in Perl instead of Ruby.


Chef documentation  | view source Contained in the Chef distribution.

Index


NAME

Top

Chef - Write Chef recipes in Perl instead of Ruby.

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

VERSION

Top

Version 0.01

WARNING

Top

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

Top

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

Top

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

FUNCTIONS

Top

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

Top

Adam Jacob, <adam at opscode.com>

SOURCE

Top

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

BUGS

Top

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

SUPPORT

Top

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/

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Chef documentation  | view source Contained in the Chef distribution.