Permalink
Browse files

added minimal perlbrew_run LWRP

  • Loading branch information...
1 parent 7bfbe20 commit ad18e518f65b21f93a4e00de9538ff187567ba0d @xdg xdg committed Jan 9, 2012
Showing with 71 additions and 0 deletions.
  1. +41 −0 cookbooks/perlbrew/providers/run.rb
  2. +30 −0 cookbooks/perlbrew/resources/run.rb
View
41 cookbooks/perlbrew/providers/run.rb
@@ -0,0 +1,41 @@
+#
+# Author:: David A. Golden
+# Cookbook Name:: perlbrew
+# Provider:: perlbrew_run
+#
+# Copyright:: 2012, David A. Golden <dagolden@cpan.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/mixin/shell_out'
+require 'chef/mixin/language'
+include Chef::Mixin::ShellOut
+
+# XXX must be a fully qualified 'perl-5.X.Y@libname' style name
+action :run do
+ perlbrew_env = {
+ 'PERLBREW_ROOT' => node['perlbrew']['perlbrew_root'],
+ 'PERLBREW_HOME' => node['perlbrew']['perlbrew_root']
+ }
+ bash new_resource.name do
+ environment new_resource.environment.merge(perlbrew_env)
+ code <<-EOC
+ source #{node['perlbrew']['perlbrew_root']}/etc/bashrc
+ perlbrew use #{new_resource.perlbrew}
+ #{new_resource.command}
+ EOC
+ end
+ new_resource.updated_by_last_action(true)
+end
+
View
30 cookbooks/perlbrew/resources/run.rb
@@ -0,0 +1,30 @@
+#
+# Author:: David A. Golden
+# Cookbook Name:: perlbrew
+# Resource:: perlbrew_run
+#
+# Copyright:: 2012, David A. Golden <dagolden@cpan.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+actions :run
+
+def initialize(*args)
+ super
+ @action = :run
+end
+
+attribute :command, :name_attribute => true, :kind_of => String
+attribute :perlbrew, :kind_of => String, :required => true
+attribute :environment, :kind_of => Hash, :default => {}

0 comments on commit ad18e51

Please sign in to comment.