Skip to content

Commit

Permalink
apt: use cookbook_file or remote_file for key
Browse files Browse the repository at this point in the history
Provide alternative to distribute gpg key via cookbook_files
  • Loading branch information
Brandon Philips authored and jtimberman committed Mar 8, 2012
1 parent 52d8585 commit 22cdaa8
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions apt/providers/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22cdaa8

Please sign in to comment.