From: Tom Hughes Date: Thu, 16 Nov 2017 19:56:45 +0000 (+0000) Subject: Modernise more LWRPs X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/e5f294d3dc676675b2803915571c28337468c3b3?hp=19aeb7bfffb852ab8be005c004b1ef8e555a5b77;ds=sidebyside Modernise more LWRPs --- diff --git a/cookbooks/fail2ban/providers/filter.rb b/cookbooks/fail2ban/providers/filter.rb deleted file mode 100644 index 8c1c20e44..000000000 --- a/cookbooks/fail2ban/providers/filter.rb +++ /dev/null @@ -1,51 +0,0 @@ -# -# Cookbook Name:: fail2ban -# Provider:: fail2ban_filter -# -# Copyright 2015, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def whyrun_supported? - true -end - -use_inline_resources - -action :create do - if new_resource.source - remote_file "/etc/fail2ban/filter.d/#{new_resource.name}.conf" do - source new_resource.source - owner "root" - group "root" - mode 0o644 - end - else - template "/etc/fail2ban/filter.d/#{new_resource.name}.conf" do - cookbook "fail2ban" - source "filter.erb" - owner "root" - group "root" - mode 0o644 - variables :failregex => new_resource.failregex, - :ignoreregex => new_resource.ignoreregex - end - end -end - -action :delete do - file "/etc/fail2ban/filter.d/#{new_resource.name}.conf" do - action :delete - end -end diff --git a/cookbooks/fail2ban/providers/jail.rb b/cookbooks/fail2ban/providers/jail.rb deleted file mode 100644 index e12ad22ef..000000000 --- a/cookbooks/fail2ban/providers/jail.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# Cookbook Name:: fail2ban -# Provider:: fail2ban_jail -# -# Copyright 2015, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def whyrun_supported? - true -end - -use_inline_resources - -action :create do - template "/etc/fail2ban/jail.d/50-#{new_resource.name}.conf" do - cookbook "fail2ban" - source "jail.erb" - owner "root" - group "root" - mode 0o644 - variables :name => new_resource.name, - :filter => new_resource.filter, - :logpath => new_resource.logpath, - :protocol => new_resource.protocol, - :ports => new_resource.ports, - :maxretry => new_resource.maxretry, - :ignoreips => new_resource.ignoreips - end -end - -action :delete do - file "/etc/fail2ban/jail.d/50-#{new_resource.name}.conf" do - action :delete - end -end diff --git a/cookbooks/fail2ban/resources/filter.rb b/cookbooks/fail2ban/resources/filter.rb index b28e8f6c7..940716d26 100644 --- a/cookbooks/fail2ban/resources/filter.rb +++ b/cookbooks/fail2ban/resources/filter.rb @@ -17,13 +17,39 @@ # limitations under the License. # -actions :create, :delete default_action :create -attribute :name, :kind_of => String, :name_attribute => true -attribute :source, :kind_of => String -attribute :failregex, :kind_of => [String, Array] -attribute :ignoreregex, :kind_of => [String, Array] +property :filter, :kind_of => String, :name_attribute => true +property :source, :kind_of => String +property :failregex, :kind_of => [String, Array] +property :ignoreregex, :kind_of => [String, Array] + +action :create do + if new_resource.source + remote_file "/etc/fail2ban/filter.d/#{new_resource.filter}.conf" do + source new_resource.source + owner "root" + group "root" + mode 0o644 + end + else + template "/etc/fail2ban/filter.d/#{new_resource.filter}.conf" do + cookbook "fail2ban" + source "filter.erb" + owner "root" + group "root" + mode 0o644 + variables :failregex => new_resource.failregex, + :ignoreregex => new_resource.ignoreregex + end + end +end + +action :delete do + file "/etc/fail2ban/filter.d/#{new_resource.filter}.conf" do + action :delete + end +end def after_created notifies :reload, "service[fail2ban]" diff --git a/cookbooks/fail2ban/resources/jail.rb b/cookbooks/fail2ban/resources/jail.rb index 65d1d3b51..203a10f9a 100644 --- a/cookbooks/fail2ban/resources/jail.rb +++ b/cookbooks/fail2ban/resources/jail.rb @@ -17,16 +17,38 @@ # limitations under the License. # -actions :create, :delete default_action :create -attribute :name, :kind_of => String, :name_attribute => true -attribute :filter, :kind_of => String -attribute :logpath, :kind_of => String -attribute :protocol, :kind_of => String -attribute :ports, :kind_of => Array, :default => [] -attribute :maxretry, :kind_of => Integer -attribute :ignoreips, :kind_of => Array +property :jail, :kind_of => String, :name_attribute => true +property :filter, :kind_of => String +property :logpath, :kind_of => String +property :protocol, :kind_of => String +property :ports, :kind_of => Array, :default => [] +property :maxretry, :kind_of => Integer +property :ignoreips, :kind_of => Array + +action :create do + template "/etc/fail2ban/jail.d/50-#{new_resource.jail}.conf" do + cookbook "fail2ban" + source "jail.erb" + owner "root" + group "root" + mode 0o644 + variables :name => new_resource.jail, + :filter => new_resource.filter, + :logpath => new_resource.logpath, + :protocol => new_resource.protocol, + :ports => new_resource.ports, + :maxretry => new_resource.maxretry, + :ignoreips => new_resource.ignoreips + end +end + +action :delete do + file "/etc/fail2ban/jail.d/50-#{new_resource.jail}.conf" do + action :delete + end +end def after_created notifies :reload, "service[fail2ban]" diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 41eae5a5b..472db1817 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 "ohai.rb.erb" + template_source "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 814c22582..be1965d68 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 "nginx_default.conf.erb" + template_source "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 155a43f42..d159a7ac3 100644 --- a/cookbooks/imagery/resources/site.rb +++ b/cookbooks/imagery/resources/site.rb @@ -100,7 +100,7 @@ action :create do end nginx_site new_resource.site do - template "nginx_imagery.conf.erb" + template_source "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 7186626c0..93cbde312 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 "munin.erb" + template_source "munin.erb" end %w[bytes commands conns evictions items memory].each do |stat| diff --git a/cookbooks/munin/providers/plugin.rb b/cookbooks/munin/providers/plugin.rb deleted file mode 100644 index 23b9753d8..000000000 --- a/cookbooks/munin/providers/plugin.rb +++ /dev/null @@ -1,76 +0,0 @@ -# -# Cookbook Name:: munin -# Provider:: munin_plugin -# -# Copyright 2013, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def whyrun_supported? - true -end - -use_inline_resources - -action :create do - link_action = case target_path - when nil then :delete - else :create - end - - link plugin_path do - action link_action - to target_path - end - - if new_resource.conf # ~FC023 - munin_plugin_conf new_resource.name do - cookbook new_resource.conf_cookbook - template new_resource.conf - variables new_resource.conf_variables - restart_munin false - end - end -end - -action :delete do - link plugin_path do - action :delete - end - - if new_resource.conf # ~FC023 - munin_plugin_conf new_resource.name do - action :delete - restart_munin false - end - end -end - -def plugin_path - "/etc/munin/plugins/#{new_resource.name}" -end - -def target_path - if ::File.exist?(target) - target - elsif ::File.exist?("/usr/local/share/munin/plugins/#{target}") - "/usr/local/share/munin/plugins/#{target}" - elsif ::File.exist?("/usr/share/munin/plugins/#{target}") - "/usr/share/munin/plugins/#{target}" - end -end - -def target - new_resource.target || new_resource.name -end diff --git a/cookbooks/munin/providers/plugin_conf.rb b/cookbooks/munin/providers/plugin_conf.rb deleted file mode 100644 index 7f63004bd..000000000 --- a/cookbooks/munin/providers/plugin_conf.rb +++ /dev/null @@ -1,45 +0,0 @@ -# -# Cookbook Name:: munin -# Provider:: munin_plugin_conf -# -# Copyright 2013, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def whyrun_supported? - true -end - -use_inline_resources - -action :create do - template config_file do - cookbook new_resource.cookbook - source new_resource.template - owner "root" - group "root" - mode 0o644 - variables new_resource.variables.merge(:name => new_resource.name) - end -end - -action :delete do - file config_file do - action :delete - end -end - -def config_file - "/etc/munin/plugin-conf.d/#{new_resource.name}" -end diff --git a/cookbooks/munin/recipes/default.rb b/cookbooks/munin/recipes/default.rb index 9a6b6e696..0fddea5a9 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 "df.erb" + template_source "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 "if.erb" + template_source "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 "ipmi.erb" + template_source "ipmi.erb" end munin_plugin "ipmi_fans" do diff --git a/cookbooks/munin/resources/plugin.rb b/cookbooks/munin/resources/plugin.rb index 5b93b8dea..f62f2ac57 100644 --- a/cookbooks/munin/resources/plugin.rb +++ b/cookbooks/munin/resources/plugin.rb @@ -1,6 +1,6 @@ # # Cookbook Name:: munin -# Resource:: munin_plugin +# Provider:: munin_plugin # # Copyright 2013, OpenStreetMap Foundation # @@ -8,7 +8,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -17,15 +17,68 @@ # limitations under the License. # -actions :create, :delete default_action :create -attribute :name, :kind_of => String, :name_attribute => true -attribute :target, :kind_of => String -attribute :conf, :kind_of => String -attribute :conf_cookbook, :kind_of => String -attribute :conf_variables, :kind_of => Hash, :default => {} -attribute :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true +property :plugin, :kind_of => String, :name_attribute => true +property :target, :kind_of => String +property :conf, :kind_of => String +property :conf_cookbook, :kind_of => String +property :conf_variables, :kind_of => Hash, :default => {} +property :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true + +action :create do + link_action = case target_path + when nil then :delete + else :create + end + + link plugin_path do + action link_action + to target_path + end + + if new_resource.conf # ~FC023 + munin_plugin_conf new_resource.plugin do + cookbook new_resource.conf_cookbook + template_source new_resource.conf + variables new_resource.conf_variables + restart_munin false + end + end +end + +action :delete do + link plugin_path do + action :delete + end + + if new_resource.conf # ~FC023 + munin_plugin_conf new_resource.plugin do + action :delete + restart_munin false + end + end +end + +action_class do + def plugin_path + "/etc/munin/plugins/#{new_resource.plugin}" + end + + def target_path + if ::File.exist?(target) + target + elsif ::File.exist?("/usr/local/share/munin/plugins/#{new_resource.target}") + "/usr/local/share/munin/plugins/#{new_resource.target}" + elsif ::File.exist?("/usr/share/munin/plugins/#{new_resource.target}") + "/usr/share/munin/plugins/#{new_resource.target}" + end + end + + def target + new_resource.target || new_resource.plugin + end +end def after_created notifies :restart, "service[munin-node]" if restart_munin && node[:recipes].include?("munin") diff --git a/cookbooks/munin/resources/plugin_conf.rb b/cookbooks/munin/resources/plugin_conf.rb index ce4c80739..c23efa234 100644 --- a/cookbooks/munin/resources/plugin_conf.rb +++ b/cookbooks/munin/resources/plugin_conf.rb @@ -17,14 +17,36 @@ # limitations under the License. # -actions :create, :delete default_action :create -attribute :name, :kind_of => String, :name_attribute => true -attribute :cookbook, :kind_of => [String, nil] -attribute :template, :kind_of => String, :required => true -attribute :variables, :kind_of => Hash, :default => {} -attribute :restart_munin, :kind_of => [TrueClass, FalseClass], :default => true +property :plugin_conf, :kind_of => String, :name_attribute => true +property :cookbook, :kind_of => [String, nil] +property :template_source, :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 + cookbook new_resource.cookbook + source new_resource.template_source + owner "root" + group "root" + mode 0o644 + variables new_resource.variables.merge(:name => new_resource.plugin_conf) + end +end + +action :delete do + file config_file do + action :delete + end +end + +action_class do + def config_file + "/etc/munin/plugin-conf.d/#{new_resource.plugin_conf}" + end +end def after_created notifies :restart, "service[munin-node]" if restart_munin diff --git a/cookbooks/nginx/providers/site.rb b/cookbooks/nginx/providers/site.rb deleted file mode 100644 index 2417c4f4e..000000000 --- a/cookbooks/nginx/providers/site.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Cookbook Name:: nginx -# Provider:: nginx_site -# -# Copyright 2015, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def whyrun_supported? - true -end - -use_inline_resources - -action :create do - template conf_path do - cookbook new_resource.cookbook - source new_resource.template - owner "root" - group "root" - mode 0o644 - variables new_resource.variables.merge(:name => new_resource.name, :directory => directory) - end -end - -action :delete do - file conf_path do - action :delete - end -end - -def conf_path - "/etc/nginx/conf.d/#{new_resource.name}.conf" -end - -def directory - new_resource.directory || "/var/www/#{new_resource.name}" -end diff --git a/cookbooks/nginx/resources/site.rb b/cookbooks/nginx/resources/site.rb index e48e7b80d..8a09e7bdf 100644 --- a/cookbooks/nginx/resources/site.rb +++ b/cookbooks/nginx/resources/site.rb @@ -17,15 +17,41 @@ # limitations under the License. # -actions :create, :delete default_action :create -attribute :name, :kind_of => String, :name_attribute => true -attribute :directory, :kind_of => String -attribute :cookbook, :kind_of => String -attribute :template, :kind_of => String, :required => true -attribute :variables, :kind_of => Hash, :default => {} -attribute :restart_nginx, :kind_of => [TrueClass, FalseClass], :default => true +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 :variables, :kind_of => Hash, :default => {} +property :restart_nginx, :kind_of => [TrueClass, FalseClass], :default => true + +action :create do + template conf_path do + cookbook new_resource.cookbook + source new_resource.template_source + owner "root" + group "root" + mode 0o644 + variables new_resource.variables.merge(:name => new_resource.site, :directory => directory) + end +end + +action :delete do + file conf_path do + action :delete + end +end + +action_class do + def conf_path + "/etc/nginx/conf.d/#{new_resource.site}.conf" + end + + def directory + new_resource.directory || "/var/www/#{new_resource.site}" + end +end def after_created notifies :restart, "service[nginx]" if restart_nginx diff --git a/cookbooks/nominatim/recipes/default.rb b/cookbooks/nominatim/recipes/default.rb index 05227bb46..6141b65d9 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 "munin.erb" + template_source "munin.erb" variables :db => node[:nominatim][:dbname], :querylog => "#{node[:nominatim][:logdir]}/query.log" end diff --git a/cookbooks/ohai/providers/plugin.rb b/cookbooks/ohai/providers/plugin.rb deleted file mode 100644 index f51fc79f6..000000000 --- a/cookbooks/ohai/providers/plugin.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Cookbook Name:: ohai -# Provider:: ohai_plugin -# -# Copyright 2015, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -def whyrun_supported? - true -end - -use_inline_resources - -action :create do - ohai new_resource.name do - action :nothing - end - - template plugin_path do - source new_resource.template - owner "root" - group "root" - mode 0o644 - notifies :reload, "ohai[#{new_resource.name}]" - end -end - -action :delete do - template plugin_path do - action :delete - end -end - -def plugin_path - "/etc/chef/ohai/#{new_resource.name}.rb" -end diff --git a/cookbooks/ohai/resources/plugin.rb b/cookbooks/ohai/resources/plugin.rb index 4dcfaf68d..0c538953d 100644 --- a/cookbooks/ohai/resources/plugin.rb +++ b/cookbooks/ohai/resources/plugin.rb @@ -17,8 +17,33 @@ # limitations under the License. # -actions :create, :delete default_action :create -attribute :name, :kind_of => String, :name_attribute => true -attribute :template, :kind_of => String, :required => true +property :plugin, :kind_of => String, :name_attribute => true +property :template_source, :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 + owner "root" + group "root" + mode 0o644 + notifies :reload, "ohai[#{new_resource.plugin}]" + end +end + +action :delete do + template plugin_path do + action :delete + end +end + +action_class do + def plugin_path + "/etc/chef/ohai/#{new_resource.plugin}.rb" + end +end diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index c71416350..9261e63aa 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 "ohai.rb.erb" + template_source "ohai.rb.erb" end package "ptop" diff --git a/cookbooks/python/resources/package.rb b/cookbooks/python/resources/package.rb index d6431c87d..e2cab899a 100644 --- a/cookbooks/python/resources/package.rb +++ b/cookbooks/python/resources/package.rb @@ -25,12 +25,12 @@ property :python_version, :kind_of => String action :install do if version.nil? - execute "pip-install-#{name}" do + execute "pip-install-#{new_resource.package_name}" do command "#{pip_command} install #{new_resource.package_name}" not_if "#{pip_command} show #{new_resource.package_name}" end else - execute "pip-install-#{name}" do + execute "pip-install-#{new_resource.package_name}" do command "#{pip_command} install #{new_resource.package_name}==#{new_resource.version}" not_if "#{pip_command} show #{new_resource.package_name} | fgrep -q #{new_resource.version}" end @@ -38,12 +38,14 @@ action :install do end action :remove do - execute "pip-uninstall-#{name}" do + execute "pip-uninstall-#{new_resource.package_name}" do command "#{pip_command} uninstall #{new_resource.package_name}" only_if "#{pip_command} show #{new_resource.package_name}" end end -def pip_command - "pip#{python_version}" +action_class do + def pip_command + "pip#{new_resource.python_version}" + end end diff --git a/cookbooks/systemd/resources/path.rb b/cookbooks/systemd/resources/path.rb index 115ee9f6e..0bff3ecff 100644 --- a/cookbooks/systemd/resources/path.rb +++ b/cookbooks/systemd/resources/path.rb @@ -35,7 +35,7 @@ property :directory_mode, Integer action :create do path_variables = new_resource.to_hash - template "/etc/systemd/system/#{path}.path" do + template "/etc/systemd/system/#{new_resource.path}.path" do cookbook "systemd" source "path.erb" owner "root" @@ -44,25 +44,25 @@ action :create do variables path_variables end - execute "systemctl-reload-#{path}.path" do + execute "systemctl-reload-#{new_resource.path}.path" do action :nothing command "systemctl daemon-reload" user "root" group "root" - subscribes :run, "template[/etc/systemd/system/#{path}.path]" + subscribes :run, "template[/etc/systemd/system/#{new_resource.path}.path]" end end action :delete do - file "/etc/systemd/system/#{path}.path" do + file "/etc/systemd/system/#{new_resource.path}.path" do action :delete end - execute "systemctl-reload-#{path}.path" do + execute "systemctl-reload-#{new_resource.path}.path" do action :nothing command "systemctl daemon-reload" user "root" group "root" - subscribes :run, "file[/etc/systemd/system/#{path}.path]" + subscribes :run, "file[/etc/systemd/system/#{new_resource.path}.path]" end end diff --git a/cookbooks/systemd/resources/service.rb b/cookbooks/systemd/resources/service.rb index 87dd05486..62641291a 100644 --- a/cookbooks/systemd/resources/service.rb +++ b/cookbooks/systemd/resources/service.rb @@ -61,7 +61,7 @@ action :create do service_variables = new_resource.to_hash if environment_file.is_a?(Hash) - template "/etc/default/#{service}" do + template "/etc/default/#{new_resource.service}" do cookbook "systemd" source "environment.erb" owner "root" @@ -70,10 +70,10 @@ action :create do variables :environment => environment_file end - service_variables[:environment_file] = "/etc/default/#{service}" + service_variables[:environment_file] = "/etc/default/#{new_resource.service}" end - template "/etc/systemd/system/#{service}.service" do + template "/etc/systemd/system/#{new_resource.service}.service" do cookbook "systemd" source "service.erb" owner "root" @@ -82,30 +82,30 @@ action :create do variables service_variables end - execute "systemctl-reload-#{service}.service" do + execute "systemctl-reload-#{new_resource.service}.service" do action :nothing command "systemctl daemon-reload" user "root" group "root" - subscribes :run, "template[/etc/systemd/system/#{service}.service]" + subscribes :run, "template[/etc/systemd/system/#{new_resource.service}.service]" end end action :delete do - file "/etc/default/#{service}" do + file "/etc/default/#{new_resource.service}" do action :delete only_if { environment_file.is_a?(Hash) } end - file "/etc/systemd/system/#{service}.service" do + file "/etc/systemd/system/#{new_resource.service}.service" do action :delete end - execute "systemctl-reload-#{service}.service" do + execute "systemctl-reload-#{new_resource.service}.service" do action :nothing command "systemctl daemon-reload" user "root" group "root" - subscribes :run, "file[/etc/systemd/system/#{service}.service]" + subscribes :run, "file[/etc/systemd/system/#{new_resource.service}.service]" end end diff --git a/cookbooks/systemd/resources/tmpfile.rb b/cookbooks/systemd/resources/tmpfile.rb index 413877013..91ede2c14 100644 --- a/cookbooks/systemd/resources/tmpfile.rb +++ b/cookbooks/systemd/resources/tmpfile.rb @@ -52,6 +52,8 @@ action :delete do end end -def unit_name - path.sub(%r{^/}, "").gsub(%r{/}, "-") +action_class do + def unit_name + path.sub(%r{^/}, "").gsub(%r{/}, "-") + end end diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index 728d26f49..a69b6ed8d 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -122,7 +122,7 @@ ssl_certificate "tile.openstreetmap.org" do end nginx_site "tile-ssl" do - template "nginx_tile_ssl.conf.erb" + template_source "nginx_tile_ssl.conf.erb" variables :resolvers => resolvers, :caches => tilecaches end