]> git.openstreetmap.org Git - chef.git/commitdiff
Use declare_resource to avoid need for template_source wart
authorTom Hughes <tom@compton.nu>
Tue, 21 Nov 2017 20:24:23 +0000 (20:24 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 21 Nov 2017 20:24:23 +0000 (20:24 +0000)
13 files changed:
cookbooks/hardware/recipes/default.rb
cookbooks/imagery/recipes/default.rb
cookbooks/imagery/resources/site.rb
cookbooks/memcached/recipes/default.rb
cookbooks/munin/recipes/default.rb
cookbooks/munin/resources/plugin.rb
cookbooks/munin/resources/plugin_conf.rb
cookbooks/nginx/resources/site.rb
cookbooks/nominatim/recipes/default.rb
cookbooks/ohai/resources/plugin.rb
cookbooks/postgresql/recipes/default.rb
cookbooks/squid/resources/fragment.rb
cookbooks/tilecache/recipes/default.rb

index a18a293a04a01b461c5100fb6a0fab9a531632e6..154a793a5614dcf9f91ff3185f33c85361e216fa 100644 (file)
@@ -21,7 +21,7 @@ include_recipe "tools"
 include_recipe "munin"
 
 ohai_plugin "hardware" do
-  template_source "ohai.rb.erb"
+  template "ohai.rb.erb"
 end
 
 case node[:cpu][:"0"][:vendor_id]
index be1965d686550d8ec1dc7ef8060f923f71a4c7a7..814c2258242f94b1c5d62f130d4641725764412c 100644 (file)
@@ -82,7 +82,7 @@ execute "unzip-ostn02-ntv2-data" do
 end
 
 nginx_site "default" do
-  template_source "nginx_default.conf.erb"
+  template "nginx_default.conf.erb"
   directory "/srv/imagery/default"
   restart_nginx false
 end
index d159a7ac36b1c00e4774571fc8b4a790181806ab..9cea98f0a2cdff5c59b84c87f81e55127abdd7c5 100644 (file)
@@ -47,7 +47,7 @@ action :create do
     recursive true
   end
 
-  template "/srv/#{new_resource.site}/index.html" do
+  declare_resource :template, "/srv/#{new_resource.site}/index.html" do
     source "index.html.erb"
     user "root"
     group "root"
@@ -80,7 +80,7 @@ action :create do
     YAML.safe_load(::File.read(path), [Symbol])
   end
 
-  template "/srv/#{new_resource.site}/imagery.js" do
+  declare_resource :template, "/srv/#{new_resource.site}/imagery.js" do
     source "imagery.js.erb"
     user "root"
     group "root"
@@ -100,7 +100,7 @@ action :create do
   end
 
   nginx_site new_resource.site do
-    template_source "nginx_imagery.conf.erb"
+    template "nginx_imagery.conf.erb"
     directory "/srv/imagery/#{new_resource.site}"
     restart_nginx false
     variables new_resource.to_hash.merge(:resolvers => resolvers)
index 93cbde312284084c63ad3f31a46bf1ddcdaced02..7186626c01af5d65ba995f3315152d4414676c04 100644 (file)
@@ -33,7 +33,7 @@ template "/etc/memcached.conf" do
 end
 
 munin_plugin_conf "memcached_multi" do
-  template_source "munin.erb"
+  template "munin.erb"
 end
 
 %w[bytes commands conns evictions items memory].each do |stat|
index 0fddea5a96ee475d275b78230989b6bacecd62dd..9a6b6e696cff818797c4a17309ec0db5f1f4255e 100644 (file)
@@ -92,7 +92,7 @@ else
 end
 
 munin_plugin_conf "df" do
-  template_source "df.erb"
+  template "df.erb"
 end
 
 munin_plugin "df"
@@ -161,7 +161,7 @@ node[:network][:interfaces].each do |ifname, ifattr|
        node[:hardware][:network] &&
        node[:hardware][:network][ifname][:device] =~ /^virtio/
       munin_plugin_conf "if_#{ifname}" do
-        template_source "if.erb"
+        template "if.erb"
         variables :ifname => ifname
       end
     else
@@ -210,7 +210,7 @@ if Dir.glob("/dev/ipmi*").empty?
   end
 else
   munin_plugin_conf "ipmi" do
-    template_source "ipmi.erb"
+    template "ipmi.erb"
   end
 
   munin_plugin "ipmi_fans" do
index 876468f4d0ae4039e19ca7787f14a8b21c2695bf..9a3c07c42d3e69b2ff285a17367b2917c2f2b846 100644 (file)
@@ -40,7 +40,7 @@ action :create do
   if new_resource.conf # ~FC023
     munin_plugin_conf new_resource.plugin do
       cookbook new_resource.conf_cookbook
-      template_source new_resource.conf
+      template new_resource.conf
       variables new_resource.conf_variables
       restart_munin false
     end
index c23efa234d0b92ce24260a2a431c5702a827fb4e..77d02c218ac289a19e35cada5593f7f4ff6b6842 100644 (file)
@@ -21,14 +21,14 @@ default_action :create
 
 property :plugin_conf, :kind_of => String, :name_attribute => true
 property :cookbook, :kind_of => [String, nil]
-property :template_source, :kind_of => String, :required => true
+property :template, :kind_of => String, :required => true
 property :variables, :kind_of => Hash, :default => {}
 property :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true
 
 action :create do
-  template config_file do
+  declare_resource :template, config_file do
     cookbook new_resource.cookbook
-    source new_resource.template_source
+    source new_resource.template
     owner "root"
     group "root"
     mode 0o644
index 8a09e7bdfe29313f53d073314dbab42e1131da87..cc19a6831714b50199379d04479ee3278626bc7b 100644 (file)
@@ -22,14 +22,14 @@ default_action :create
 property :site, :kind_of => String, :name_attribute => true
 property :directory, :kind_of => String
 property :cookbook, :kind_of => String
-property :template_source, :kind_of => String, :required => true
+property :template, :kind_of => String, :required => true
 property :variables, :kind_of => Hash, :default => {}
 property :restart_nginx, :kind_of => [TrueClass, FalseClass], :default => true
 
 action :create do
-  template conf_path do
+  declare_resource :template, conf_path do
     cookbook new_resource.cookbook
-    source new_resource.template_source
+    source new_resource.template
     owner "root"
     group "root"
     mode 0o644
index 6141b65d9df82a93bd1d23843a7f0fe15db17977..05227bb465bcbca205711d54dcf04a829b82c14c 100644 (file)
@@ -371,7 +371,7 @@ template "/etc/logrotate.d/apache2" do
 end
 
 munin_plugin_conf "nominatim" do
-  template_source "munin.erb"
+  template "munin.erb"
   variables :db => node[:nominatim][:dbname],
             :querylog => "#{node[:nominatim][:logdir]}/query.log"
 end
index 0c538953d9340c2d283dcce7da7dd99501eed179..aef9886287ce95f3f30096ac30651456a2312d89 100644 (file)
 default_action :create
 
 property :plugin, :kind_of => String, :name_attribute => true
-property :template_source, :kind_of => String, :required => true
+property :template, :kind_of => String, :required => true
 
 action :create do
   ohai new_resource.plugin do
     action :nothing
   end
 
-  template plugin_path do
-    source new_resource.template_source
+  declare_resource :template, plugin_path do
+    source new_resource.template
     owner "root"
     group "root"
     mode 0o644
@@ -37,7 +37,7 @@ action :create do
 end
 
 action :delete do
-  template plugin_path do
+  file plugin_path do
     action :delete
   end
 end
index 9261e63aa57435c42c43f20395433e7964deca8e..c7141635081181900e24818b7263f3a797a19781 100644 (file)
@@ -99,7 +99,7 @@ service "postgresql" do
 end
 
 ohai_plugin "postgresql" do
-  template_source "ohai.rb.erb"
+  template "ohai.rb.erb"
 end
 
 package "ptop"
index 9182b99bee42f2b13a083bca2465a079b8570c79..a5f259c1b402e8c118b5eaf6a12f83b862bb0858 100644 (file)
 default_action :create
 
 property :fragment, :kind_of => String, :name_attribute => true
-property :template_source, :kind_of => String, :required => true
+property :template, :kind_of => String, :required => true
 property :variables, :kind_of => Hash, :default => {}
 
 action :create do
-  template fragment_path do
-    source new_resource.template_source
+  declare_resource :template, fragment_path do
+    source new_resource.template
     owner "root"
     group "root"
     mode 0o644
index 0ec9dda590596a5230e5a01caf978e32c7428e9f..728d26f49a9ba54206e2f3919b5f31e3485fab56 100644 (file)
@@ -73,7 +73,7 @@ tilecaches.each do |cache|
 end
 
 squid_fragment "tilecache" do
-  template_source "squid.conf.erb"
+  template "squid.conf.erb"
   variables :caches => tilecaches, :renders => tilerenders
 end
 
@@ -122,7 +122,7 @@ ssl_certificate "tile.openstreetmap.org" do
 end
 
 nginx_site "tile-ssl" do
-  template_source "nginx_tile_ssl.conf.erb"
+  template "nginx_tile_ssl.conf.erb"
   variables :resolvers => resolvers, :caches => tilecaches
 end