The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Chef - Write Chef recipes in Perl instead of Ruby.

Learn more about 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)



  use Chef;
  resource file => '/tmp/foo', sub {
    my $r = shift;
  resource file => '/tmp/' . node->{attributes}->{hostname} . "_created_with_perl", sub {
    my $r = shift;

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:


An example of translating from the ruby version to perl:

  # The ruby version
  package "sudo" do
    action :install

  # Make sure sudo is always at the latest version
  resource package => "sudo", sub {
    my $r = shift;

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>


You can find the source on GitHub at


Please report bugs to


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

    perldoc Chef

You can also look for information at:



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.