Rework certificate handling
authorTom Hughes <tom@compton.nu>
Thu, 17 Oct 2013 17:29:23 +0000 (18:29 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 17 Oct 2013 17:38:37 +0000 (18:38 +0100)
cookbooks/apache/recipes/ssl.rb
cookbooks/ssl/attributes/default.rb
cookbooks/ssl/recipes/default.rb
cookbooks/tilecache/metadata.rb
cookbooks/tilecache/recipes/default.rb
roles/tilecache.rb

index 37bf822c549879564fcf5d1a61fbd3689760e535..a31ac0c061ff259df688d4cf4381d7cf94952c8a 100644 (file)
@@ -17,6 +17,8 @@
 # limitations under the License.
 #
 
+node.default[:ssl][:certificate] = node[:ssl][:certificate] | [ "openstreetmap" ]
+
 include_recipe "apache"
 include_recipe "ssl"
 
index c9f1dcd661a780a8bc96aed522e6af10ea9308c2..d7a4147a0b98de16afdbb034ad2f8dbc66a83af9 100644 (file)
@@ -1 +1 @@
-default[:ssl][:certificate] = "openstreetmap"
+default[:ssl][:certificates] = []
index a3a2708c426cf81aa0b20ea8a5ef5117620d915e..81dea8b28f4385f5208ba3d85ee51570f1498fa8 100644 (file)
@@ -29,17 +29,29 @@ cookbook_file "/etc/ssl/certs/rapidssl.pem" do
   backup false
 end
 
-cookbook_file "/etc/ssl/certs/#{node[:ssl][:certificate]}.pem" do
-  owner "root"
-  group "root"
-  mode 0444
-  backup false
-end
+[ "openstreetmap", "tile.openstreetmap" ].each do |certificate|
+  if node[:ssl][:certificates].include?(certificate)
+    cookbook_file "/etc/ssl/certs/#{certificate}.pem" do
+      owner "root"
+      group "root"
+      mode 0444
+      backup false
+    end
 
-file "/etc/ssl/private/#{node[:ssl][:certificate]}.key" do
-  owner "root"
-  group "ssl-cert"
-  mode 0440
-  content keys[node[:ssl][:certificate]].join("\n")
-  backup false
+    file "/etc/ssl/private/#{certificate}.key" do
+      owner "root"
+      group "ssl-cert"
+      mode 0440
+      content keys[certificate].join("\n")
+      backup false
+    end
+  else
+    file "/etc/ssl/certs/#{certificate}.pem" do
+      action :delete
+    end
+
+    file "/etc/ssl/private/#{certificate}.key" do
+      action :delete
+    end
+  end
 end
index ce9c0e62ae430da7a84afd335c2a00208374601b..39e123ef1c7d291faef2be5711194dd56dd783bc 100644 (file)
@@ -4,4 +4,5 @@ license           "Apache 2.0"
 description       "Installs and configures a tile cache"
 long_description  IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
 version           "1.0.0"
+depends           "ssl"
 depends           "squid"
index 4015f994104305fa6369d28280691481da9f3ab4..d1486adcf4be06f69bfd92f1f145ae4209a3f811 100644 (file)
@@ -17,6 +17,9 @@
 # limitations under the License.
 #
 
+node.default[:ssl][:certificate] = node[:ssl][:certificate] | [ "tile.openstreetmap" ]
+
+include_recipe "ssl"
 include_recipe "squid"
 
 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
index 3f3f3f08d6a6a49a6a0cf56fa9eca8f01c5da126..daaaddf2c3d2ca87e5e51b461973a5b8cb908136 100644 (file)
@@ -2,9 +2,6 @@ name "tilecache"
 description "Role applied to all tile cache servers"
 
 default_attributes(
-  :ssl => {
-    :certificate => "tile.openstreetmap"
-  },
   :sysctl => {
     :network_conntrack_time_wait => {
       :comment => "Only track completed connections for 30 seconds",
@@ -23,6 +20,5 @@ default_attributes(
 
 run_list(
   "role[geodns]",
-  "recipe[ssl]",
   "recipe[tilecache]"
 )