Browse files

apt: use cookbook_file or remote_file for key

Provide alternative to distribute gpg key via cookbook_files
  • Loading branch information...
1 parent 52d8585 commit 22cdaa83a583ec4af92af788bd7815b94397f8cd Brandon Philips committed with jtimberman May 26, 2011
Showing with 19 additions and 6 deletions.
  1. +19 −6 apt/providers/repository.rb
View
25 apt/providers/repository.rb
@@ -26,13 +26,26 @@
command "apt-key adv --keyserver #{new_resource.keyserver} --recv #{new_resource.key}"
action :nothing
end.run_action(:run)
- elsif new_resource.key && (new_resource.key =~ /http/)
+ elsif new_resource.key
key_name = new_resource.key.split(/\//).last
- remote_file "#{Chef::Config[:file_cache_path]}/#{key_name}" do
- source new_resource.key
- mode "0644"
- action :nothing
- end.run_action(:create)
+ target = "#{Chef::Config[:file_cache_path]}/#{key_name}"
+
+ if (new_resource.key =~ /http/)
+ r = remote_file target do
+ source new_resource.key
+ mode "0644"
+ action :nothing
+ end
+ else
+ r = cookbook_file target do
+ source new_resource.key
+ mode "0644"
+ action :nothing
+ end
+ end
+
+ r.run_action(:create_if_missing)
+
execute "install-key #{key_name}" do
command "apt-key add #{Chef::Config[:file_cache_path]}/#{key_name}"
action :nothing

0 comments on commit 22cdaa8

Please sign in to comment.