Skip to content

Commit

Permalink
Add 'cpanm_options' attribute to recipe and LWRP.
Browse files Browse the repository at this point in the history
With this new attribute, it's possible to specify options for cpanm.
  • Loading branch information
fcuny committed Nov 14, 2012
1 parent 2a39151 commit bee5a4c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cookbooks/perlbrew/README.md
Expand Up @@ -25,6 +25,7 @@ Attributes
* `node['perlbrew']['perlbrew_root'] = "/opt/perlbrew"` - Sets the `PERLBREW_ROOT` environment variable
* `node['perlbrew']['perls'] = []` - An array of perls to install, e.g. `["perl-5.14.2", "perl-5.12.3"]`
* `node['perlbrew']['install_options'] = ''` - A string of command line options for `perlbrew install`, e.g. `-D usethreads` for building all perls with threads
* `node['perlbrew']['cpanm_options'] = ''` - A string of command line options for `cpanm`, e.g. `--notest` for installing modules without running tests

Recipes
=======
Expand Down Expand Up @@ -133,6 +134,8 @@ Attributes:
modules (REQUIRED)
* :modules - an array of module names to pass to cpanm. Any legal input
to cpanm is allowed.
* :options - a string of options to pass to cpanm. Any legal options to
cpanm is allowed.

perlbrew_run
------------
Expand Down
1 change: 1 addition & 0 deletions cookbooks/perlbrew/attributes/default.rb
Expand Up @@ -25,4 +25,5 @@
# default command line options for "perlbrew install" if no LWRP options
# attribute is given
default['perlbrew']['install_options'] = ''
default['perlbrew']['cpanm_options'] = ''

3 changes: 2 additions & 1 deletion cookbooks/perlbrew/providers/cpanm.rb
Expand Up @@ -27,8 +27,9 @@
'PERLBREW_ROOT' => node['perlbrew']['perlbrew_root'],
'PERLBREW_HOME' => node['perlbrew']['perlbrew_root']
}
options = new_resource.options ? new_resource.options : node['perlbrew']['cpanm_options']
new_resource.modules([new_resource.name]) unless new_resource.modules.length > 0
p = perlbrew_run "cpanm #{new_resource.modules.join(' ')}" do
p = perlbrew_run "cpanm #{options} #{new_resource.modules.join(' ')}" do
perlbrew new_resource.perlbrew
action :nothing
end
Expand Down
1 change: 1 addition & 0 deletions cookbooks/perlbrew/resources/cpanm.rb
Expand Up @@ -20,6 +20,7 @@

actions :run

attribute :options, :kind_of => String
attribute :perlbrew, :kind_of => String, :required => true
attribute :modules, :kind_of => Array, :default => []

Expand Down

0 comments on commit bee5a4c

Please sign in to comment.