]> git.openstreetmap.org Git - chef.git/commitdiff
Modernise more LWRPs
authorTom Hughes <tom@compton.nu>
Thu, 16 Nov 2017 19:56:45 +0000 (19:56 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 16 Nov 2017 20:34:17 +0000 (20:34 +0000)
24 files changed:
cookbooks/fail2ban/providers/filter.rb [deleted file]
cookbooks/fail2ban/providers/jail.rb [deleted file]
cookbooks/fail2ban/resources/filter.rb
cookbooks/fail2ban/resources/jail.rb
cookbooks/hardware/recipes/default.rb
cookbooks/imagery/recipes/default.rb
cookbooks/imagery/resources/site.rb
cookbooks/memcached/recipes/default.rb
cookbooks/munin/providers/plugin.rb [deleted file]
cookbooks/munin/providers/plugin_conf.rb [deleted file]
cookbooks/munin/recipes/default.rb
cookbooks/munin/resources/plugin.rb
cookbooks/munin/resources/plugin_conf.rb
cookbooks/nginx/providers/site.rb [deleted file]
cookbooks/nginx/resources/site.rb
cookbooks/nominatim/recipes/default.rb
cookbooks/ohai/providers/plugin.rb [deleted file]
cookbooks/ohai/resources/plugin.rb
cookbooks/postgresql/recipes/default.rb
cookbooks/python/resources/package.rb
cookbooks/systemd/resources/path.rb
cookbooks/systemd/resources/service.rb
cookbooks/systemd/resources/tmpfile.rb
cookbooks/tilecache/recipes/default.rb

diff --git a/cookbooks/fail2ban/providers/filter.rb b/cookbooks/fail2ban/providers/filter.rb
deleted file mode 100644 (file)
index 8c1c20e..0000000
+++ /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 (file)
index e12ad22..0000000
+++ /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
index b28e8f6c7aa673ddea0700bda3429f55c4f79851..940716d26af81167d00b9bb51d71699658ba0fa0 100644 (file)
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
-actions :create, :delete
 default_action :create
 
 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]"
 
 def after_created
   notifies :reload, "service[fail2ban]"
index 65d1d3b514617c50d98c39f22db93b2546acd4c3..203a10f9a88598da00e4d0b9c60b3209ed7a2ad7 100644 (file)
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
-actions :create, :delete
 default_action :create
 
 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]"
 
 def after_created
   notifies :reload, "service[fail2ban]"
index 41eae5a5b63c245888978d7fcbb9df6487c87ab9..472db1817a9dc838972684201a3f0b99f790c8ef 100644 (file)
@@ -21,7 +21,7 @@ include_recipe "tools"
 include_recipe "munin"
 
 ohai_plugin "hardware" do
 include_recipe "munin"
 
 ohai_plugin "hardware" do
-  template "ohai.rb.erb"
+  template_source "ohai.rb.erb"
 end
 
 case node[:cpu][:"0"][:vendor_id]
 end
 
 case node[:cpu][:"0"][:vendor_id]
index 814c2258242f94b1c5d62f130d4641725764412c..be1965d686550d8ec1dc7ef8060f923f71a4c7a7 100644 (file)
@@ -82,7 +82,7 @@ execute "unzip-ostn02-ntv2-data" do
 end
 
 nginx_site "default" 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
   directory "/srv/imagery/default"
   restart_nginx false
 end
index 155a43f42cdadc3a56fc2a996fdb36daf34a9b2c..d159a7ac36b1c00e4774571fc8b4a790181806ab 100644 (file)
@@ -100,7 +100,7 @@ action :create do
   end
 
   nginx_site new_resource.site 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)
     directory "/srv/imagery/#{new_resource.site}"
     restart_nginx false
     variables new_resource.to_hash.merge(:resolvers => resolvers)
index 7186626c01af5d65ba995f3315152d4414676c04..93cbde312284084c63ad3f31a46bf1ddcdaced02 100644 (file)
@@ -33,7 +33,7 @@ template "/etc/memcached.conf" do
 end
 
 munin_plugin_conf "memcached_multi" 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|
 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 (file)
index 23b9753..0000000
+++ /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 (file)
index 7f63004..0000000
+++ /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
index 9a6b6e696cff818797c4a17309ec0db5f1f4255e..0fddea5a96ee475d275b78230989b6bacecd62dd 100644 (file)
@@ -92,7 +92,7 @@ else
 end
 
 munin_plugin_conf "df" do
 end
 
 munin_plugin_conf "df" do
-  template "df.erb"
+  template_source "df.erb"
 end
 
 munin_plugin "df"
 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
        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
         variables :ifname => ifname
       end
     else
@@ -210,7 +210,7 @@ if Dir.glob("/dev/ipmi*").empty?
   end
 else
   munin_plugin_conf "ipmi" do
   end
 else
   munin_plugin_conf "ipmi" do
-    template "ipmi.erb"
+    template_source "ipmi.erb"
   end
 
   munin_plugin "ipmi_fans" do
   end
 
   munin_plugin "ipmi_fans" do
index 5b93b8dea257a0fb662a67bd37a072abd77546b4..f62f2ac57c08a2e1da3ba55d105bbfc08b1089b3 100644 (file)
@@ -1,6 +1,6 @@
 #
 # Cookbook Name:: munin
 #
 # Cookbook Name:: munin
-# Resource:: munin_plugin
+# Provider:: munin_plugin
 #
 # Copyright 2013, OpenStreetMap Foundation
 #
 #
 # 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
 #
 # 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,
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
-actions :create, :delete
 default_action :create
 
 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")
 
 def after_created
   notifies :restart, "service[munin-node]" if restart_munin && node[:recipes].include?("munin")
index ce4c80739ad5779ec550baa78bfaa722391808b2..c23efa234d0b92ce24260a2a431c5702a827fb4e 100644 (file)
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
-actions :create, :delete
 default_action :create
 
 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
 
 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 (file)
index 2417c4f..0000000
+++ /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
index e48e7b80d2ade6a24e69ca626bbd9c6412c66cc5..8a09e7bdfe29313f53d073314dbab42e1131da87 100644 (file)
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
-actions :create, :delete
 default_action :create
 
 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
 
 def after_created
   notifies :restart, "service[nginx]" if restart_nginx
index 05227bb465bcbca205711d54dcf04a829b82c14c..6141b65d9df82a93bd1d23843a7f0fe15db17977 100644 (file)
@@ -371,7 +371,7 @@ template "/etc/logrotate.d/apache2" do
 end
 
 munin_plugin_conf "nominatim" 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
   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 (file)
index f51fc79..0000000
+++ /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
index 4dcfaf68de2f0cef9cf17df1dafeb93f8b5d0ebd..0c538953d9340c2d283dcce7da7dd99501eed179 100644 (file)
 # limitations under the License.
 #
 
 # limitations under the License.
 #
 
-actions :create, :delete
 default_action :create
 
 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
index c7141635081181900e24818b7263f3a797a19781..9261e63aa57435c42c43f20395433e7964deca8e 100644 (file)
@@ -99,7 +99,7 @@ service "postgresql" do
 end
 
 ohai_plugin "postgresql" do
 end
 
 ohai_plugin "postgresql" do
-  template "ohai.rb.erb"
+  template_source "ohai.rb.erb"
 end
 
 package "ptop"
 end
 
 package "ptop"
index d6431c87da8714116d29f5e0101b6ac5469a096b..e2cab899ae5630f909ce6d1798e800a6c3ca123e 100644 (file)
@@ -25,12 +25,12 @@ property :python_version, :kind_of => String
 
 action :install do
   if version.nil?
 
 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
       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
       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
 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
 
     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
 end
index 115ee9f6e47211c00fcf1f0bf589f7c52f8ff679..0bff3ecffec6dfb7538828dcb516a98873efacc9 100644 (file)
@@ -35,7 +35,7 @@ property :directory_mode, Integer
 action :create do
   path_variables = new_resource.to_hash
 
 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"
     cookbook "systemd"
     source "path.erb"
     owner "root"
@@ -44,25 +44,25 @@ action :create do
     variables path_variables
   end
 
     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"
     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
   end
 end
 
 action :delete do
-  file "/etc/systemd/system/#{path}.path" do
+  file "/etc/systemd/system/#{new_resource.path}.path" do
     action :delete
   end
 
     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"
     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
   end
 end
index 87dd05486d690e3491659bbd4aab53394980acdc..62641291ad606d601c4d2e23e50405bdbe9067b7 100644 (file)
@@ -61,7 +61,7 @@ action :create do
   service_variables = new_resource.to_hash
 
   if environment_file.is_a?(Hash)
   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"
       cookbook "systemd"
       source "environment.erb"
       owner "root"
@@ -70,10 +70,10 @@ action :create do
       variables :environment => environment_file
     end
 
       variables :environment => environment_file
     end
 
-    service_variables[:environment_file] = "/etc/default/#{service}"
+    service_variables[:environment_file] = "/etc/default/#{new_resource.service}"
   end
 
   end
 
-  template "/etc/systemd/system/#{service}.service" do
+  template "/etc/systemd/system/#{new_resource.service}.service" do
     cookbook "systemd"
     source "service.erb"
     owner "root"
     cookbook "systemd"
     source "service.erb"
     owner "root"
@@ -82,30 +82,30 @@ action :create do
     variables service_variables
   end
 
     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"
     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
   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
 
     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
 
     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"
     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
   end
 end
index 4138770134741e74bc4953e7ce91daa611ccfe0e..91ede2c149c6fd1371bc0ebdf7bf7a188a48fe10 100644 (file)
@@ -52,6 +52,8 @@ action :delete do
   end
 end
 
   end
 end
 
-def unit_name
-  path.sub(%r{^/}, "").gsub(%r{/}, "-")
+action_class do
+  def unit_name
+    path.sub(%r{^/}, "").gsub(%r{/}, "-")
+  end
 end
 end
index 728d26f49a9ba54206e2f3919b5f31e3485fab56..a69b6ed8dda6e6d0966ed7cd9a4156e935fc2996 100644 (file)
@@ -122,7 +122,7 @@ ssl_certificate "tile.openstreetmap.org" do
 end
 
 nginx_site "tile-ssl" 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
 
   variables :resolvers => resolvers, :caches => tilecaches
 end