From 03b7d5e985a34d01dccfd03dc11488015e97f7df Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 21 Nov 2017 20:24:23 +0000 Subject: [PATCH] Use declare_resource to avoid need for template_source wart --- cookbooks/hardware/recipes/default.rb | 2 +- cookbooks/imagery/recipes/default.rb | 2 +- cookbooks/imagery/resources/site.rb | 6 +++--- cookbooks/memcached/recipes/default.rb | 2 +- cookbooks/munin/recipes/default.rb | 6 +++--- cookbooks/munin/resources/plugin.rb | 2 +- cookbooks/munin/resources/plugin_conf.rb | 6 +++--- cookbooks/nginx/resources/site.rb | 6 +++--- cookbooks/nominatim/recipes/default.rb | 2 +- cookbooks/ohai/resources/plugin.rb | 8 ++++---- cookbooks/postgresql/recipes/default.rb | 2 +- cookbooks/squid/resources/fragment.rb | 6 +++--- cookbooks/tilecache/recipes/default.rb | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index a18a293a0..154a793a5 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -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] diff --git a/cookbooks/imagery/recipes/default.rb b/cookbooks/imagery/recipes/default.rb index be1965d68..814c22582 100644 --- a/cookbooks/imagery/recipes/default.rb +++ b/cookbooks/imagery/recipes/default.rb @@ -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 diff --git a/cookbooks/imagery/resources/site.rb b/cookbooks/imagery/resources/site.rb index d159a7ac3..9cea98f0a 100644 --- a/cookbooks/imagery/resources/site.rb +++ b/cookbooks/imagery/resources/site.rb @@ -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) diff --git a/cookbooks/memcached/recipes/default.rb b/cookbooks/memcached/recipes/default.rb index 93cbde312..7186626c0 100644 --- a/cookbooks/memcached/recipes/default.rb +++ b/cookbooks/memcached/recipes/default.rb @@ -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| diff --git a/cookbooks/munin/recipes/default.rb b/cookbooks/munin/recipes/default.rb index 0fddea5a9..9a6b6e696 100644 --- a/cookbooks/munin/recipes/default.rb +++ b/cookbooks/munin/recipes/default.rb @@ -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 diff --git a/cookbooks/munin/resources/plugin.rb b/cookbooks/munin/resources/plugin.rb index 876468f4d..9a3c07c42 100644 --- a/cookbooks/munin/resources/plugin.rb +++ b/cookbooks/munin/resources/plugin.rb @@ -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 diff --git a/cookbooks/munin/resources/plugin_conf.rb b/cookbooks/munin/resources/plugin_conf.rb index c23efa234..77d02c218 100644 --- a/cookbooks/munin/resources/plugin_conf.rb +++ b/cookbooks/munin/resources/plugin_conf.rb @@ -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 diff --git a/cookbooks/nginx/resources/site.rb b/cookbooks/nginx/resources/site.rb index 8a09e7bdf..cc19a6831 100644 --- a/cookbooks/nginx/resources/site.rb +++ b/cookbooks/nginx/resources/site.rb @@ -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 diff --git a/cookbooks/nominatim/recipes/default.rb b/cookbooks/nominatim/recipes/default.rb index 6141b65d9..05227bb46 100644 --- a/cookbooks/nominatim/recipes/default.rb +++ b/cookbooks/nominatim/recipes/default.rb @@ -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 diff --git a/cookbooks/ohai/resources/plugin.rb b/cookbooks/ohai/resources/plugin.rb index 0c538953d..aef988628 100644 --- a/cookbooks/ohai/resources/plugin.rb +++ b/cookbooks/ohai/resources/plugin.rb @@ -20,15 +20,15 @@ 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 diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 9261e63aa..c71416350 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -99,7 +99,7 @@ service "postgresql" do end ohai_plugin "postgresql" do - template_source "ohai.rb.erb" + template "ohai.rb.erb" end package "ptop" diff --git a/cookbooks/squid/resources/fragment.rb b/cookbooks/squid/resources/fragment.rb index 9182b99be..a5f259c1b 100644 --- a/cookbooks/squid/resources/fragment.rb +++ b/cookbooks/squid/resources/fragment.rb @@ -20,12 +20,12 @@ 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 diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index 0ec9dda59..728d26f49 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -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 -- 2.39.5