From 0e470cd36fc1fc6c4ec6494b1a5bef57d5a9ac1d Mon Sep 17 00:00:00 2001 From: Sergey Cheparev Date: Mon, 14 Apr 2014 13:05:40 +0200 Subject: [PATCH 1/2] Added install_requirements action --- providers/pip.rb | 14 ++++++++++++++ resources/pip.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/providers/pip.rb b/providers/pip.rb index 328bbf5..ebf8e18 100644 --- a/providers/pip.rb +++ b/providers/pip.rb @@ -76,6 +76,15 @@ def whyrun_supported? end end +action :install_requirements do + description = "Installing packages from #{new_resource}" + converge_by(description) do + Chef::Log.info("Installing packages from #{new_resource}") + install_requirements_packages() + new_resource.updated_by_last_action(true) + end +end + def removing_package? if current_resource.version.nil? false # nothing to remove @@ -150,6 +159,11 @@ def remove_package(version) pip_cmd('uninstall') end +def install_requirements_packages() + new_resource.options "#{new_resource.options} -r" + pip_cmd('install') +end + def pip_cmd(subcommand, version='') options = { :timeout => new_resource.timeout, :user => new_resource.user, :group => new_resource.group } environment = Hash.new diff --git a/resources/pip.rb b/resources/pip.rb index 1475b3a..0084583 100644 --- a/resources/pip.rb +++ b/resources/pip.rb @@ -18,7 +18,7 @@ # limitations under the License. # -actions :install, :upgrade, :remove, :purge +actions :install, :upgrade, :remove, :purge, :install_requirements default_action :install if defined?(default_action) # Chef > 10.8 # Default action for Chef <= 10.8 From 3d57107c82be068d67dfe75d2023ada3f5e220ff Mon Sep 17 00:00:00 2001 From: Sergey Cheparev Date: Mon, 14 Apr 2014 13:52:38 +0200 Subject: [PATCH 2/2] Added `install_requirements` attribute to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dd0b046..d436662 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Install packages using the new hotness in Python package management...[`pip`](ht - :user: User to run pip as, for using with virtualenv - :group: Group to run pip as, for using with virtualenv - :purge: Purge a pip package (this usually entails removing configuration files as well as the package itself). With pip packages this behaves the same as `:remove` +- :install_requirements: Install requirements from the requirements file #### Attribute Parameters