From ea0715b4be41a1d1600bba7a1f5d0b988708579f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 6 Feb 2015 00:44:36 +0000 Subject: [PATCH] Fix some foodcritic complaints --- cookbooks/apache/providers/conf.rb | 8 +- cookbooks/exim/recipes/default.rb | 15 ++- cookbooks/forum/metadata.rb | 1 + cookbooks/hardware/attributes/default.rb | 4 +- cookbooks/mediawiki/README.md | 34 ++++++ cookbooks/mediawiki/README.rdoc | 8 -- .../definitions/mediawiki_extension.rb | 8 +- .../mediawiki/definitions/mediawiki_site.rb | 14 +-- cookbooks/mediawiki/metadata.rb | 6 +- cookbooks/memcached/recipes/default.rb | 26 +---- cookbooks/munin/recipes/default.rb | 20 ++-- cookbooks/mysql/recipes/default.rb | 100 ++---------------- cookbooks/networking/recipes/default.rb | 2 +- cookbooks/openssh/recipes/default.rb | 10 +- cookbooks/otrs/recipes/default.rb | 4 +- cookbooks/piwik/recipes/default.rb | 4 +- cookbooks/taginfo/recipes/default.rb | 58 ++-------- cookbooks/tilecache/recipes/default.rb | 2 +- cookbooks/wiki/README.md | 34 ++++++ cookbooks/wiki/README.rdoc | 8 -- cookbooks/wiki/metadata.rb | 3 +- 21 files changed, 139 insertions(+), 230 deletions(-) create mode 100644 cookbooks/mediawiki/README.md delete mode 100644 cookbooks/mediawiki/README.rdoc create mode 100644 cookbooks/wiki/README.md delete mode 100644 cookbooks/wiki/README.rdoc diff --git a/cookbooks/apache/providers/conf.rb b/cookbooks/apache/providers/conf.rb index da339b955..489be8b84 100644 --- a/cookbooks/apache/providers/conf.rb +++ b/cookbooks/apache/providers/conf.rb @@ -21,13 +21,13 @@ def whyrun_supported? true end -action :create do +action :create do # ~FC017 if node[:lsb][:release].to_f >= 14.04 create_conf end end -action :enable do +action :enable do # ~FC017 if node[:lsb][:release].to_f >= 14.04 enable_conf else @@ -35,7 +35,7 @@ action :enable do end end -action :disable do +action :disable do # ~FC017 if node[:lsb][:release].to_f >= 14.04 disable_conf else @@ -43,7 +43,7 @@ action :disable do end end -action :delete do +action :delete do # ~FC017 if node[:lsb][:release].to_f >= 14.04 delete_conf end diff --git a/cookbooks/exim/recipes/default.rb b/cookbooks/exim/recipes/default.rb index da8ba5c9c..099e047c6 100644 --- a/cookbooks/exim/recipes/default.rb +++ b/cookbooks/exim/recipes/default.rb @@ -144,12 +144,11 @@ else end end -if node[:exim][:smarthost_via] - firewall_rule "deny-outbound-smtp" do - action :reject - source "fw" - dest "net" - proto "tcp:syn" - dest_ports "smtp" - end +firewall_rule "deny-outbound-smtp" do + action :reject + source "fw" + dest "net" + proto "tcp:syn" + dest_ports "smtp" + only_if { node[:exim][:smarthost_via] } end diff --git a/cookbooks/forum/metadata.rb b/cookbooks/forum/metadata.rb index 5e4be143f..797c0cb8c 100644 --- a/cookbooks/forum/metadata.rb +++ b/cookbooks/forum/metadata.rb @@ -6,4 +6,5 @@ description "Installs and configures a roundup server" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" depends "apache" +depends "git" depends "mysql" diff --git a/cookbooks/hardware/attributes/default.rb b/cookbooks/hardware/attributes/default.rb index c0a805b26..54c8956a3 100644 --- a/cookbooks/hardware/attributes/default.rb +++ b/cookbooks/hardware/attributes/default.rb @@ -8,7 +8,7 @@ if node[:dmi] && node[:dmi][:system] case dmi.system.product_name when "ProLiant DL360 G6", "ProLiant DL360 G7" - default[:hardware][:sensors]["power_meter-*"][:power]["power1"] = { :ignore => true } + default[:hardware][:sensors][:"power_meter-*"][:power][:"power1"] = { :ignore => true } end end end @@ -16,7 +16,7 @@ end if Chef::Util.compare_versions(node[:kernel][:release], [3, 3]) < 0 default[:hardware][:modules] |= ["microcode"] - if node[:cpu]["0"][:vendor_id] == "GenuineIntel" + if node[:cpu][:"0"][:vendor_id] == "GenuineIntel" default[:hardware][:modules] |= ["coretemp"] end end diff --git a/cookbooks/mediawiki/README.md b/cookbooks/mediawiki/README.md new file mode 100644 index 000000000..205739199 --- /dev/null +++ b/cookbooks/mediawiki/README.md @@ -0,0 +1,34 @@ +Cookbook +======== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +Attributes +---------- +TODO: List you cookbook attributes here. + +Usage +----- +TODO: Write usage instructions for each cookbook. + +Contributing +------------ +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +License and Authors +------------------- +Authors: TODO: List authors diff --git a/cookbooks/mediawiki/README.rdoc b/cookbooks/mediawiki/README.rdoc deleted file mode 100644 index 3de2ec7a3..000000000 --- a/cookbooks/mediawiki/README.rdoc +++ /dev/null @@ -1,8 +0,0 @@ -= DESCRIPTION: - -= REQUIREMENTS: - -= ATTRIBUTES: - -= USAGE: - diff --git a/cookbooks/mediawiki/definitions/mediawiki_extension.rb b/cookbooks/mediawiki/definitions/mediawiki_extension.rb index c5d1ec856..764a59832 100644 --- a/cookbooks/mediawiki/definitions/mediawiki_extension.rb +++ b/cookbooks/mediawiki/definitions/mediawiki_extension.rb @@ -56,11 +56,11 @@ define :mediawiki_extension, :action => [:enable], :variables => {} do user node[:mediawiki][:user] group node[:mediawiki][:group] ignore_failure repository.start_with?("git://github.com/wikimedia/mediawiki-extensions") - notifies :run, resources(:execute => "#{mediawiki_directory}/maintenance/update.php") + notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]" end end - if template + if template # ~FC023 template "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do cookbook "mediawiki" source template @@ -68,7 +68,7 @@ define :mediawiki_extension, :action => [:enable], :variables => {} do group node[:mediawiki][:group] mode 0664 variables template_variables - notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php") + notifies :create, "template[#{mediawiki_directory}/LocalSettings.php]" end end @@ -79,6 +79,6 @@ define :mediawiki_extension, :action => [:enable], :variables => {} do mode 0664 content " "#{mediawiki_directory}/LocalSettings.php") + notifies :create, "template[#{mediawiki_directory}/LocalSettings.php]" end end diff --git a/cookbooks/mediawiki/definitions/mediawiki_site.rb b/cookbooks/mediawiki/definitions/mediawiki_site.rb index d565bed64..017d77b30 100644 --- a/cookbooks/mediawiki/definitions/mediawiki_site.rb +++ b/cookbooks/mediawiki/definitions/mediawiki_site.rb @@ -106,27 +106,27 @@ define :mediawiki_site, :action => [:create, :enable] do group node[:mediawiki][:group] end - directory "#{site_directory}" do + directory site_directory do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0775 end - directory "#{mediawiki[:directory]}" do + directory mediawiki[:directory] do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0775 end - git "#{mediawiki[:directory]}" do + git mediawiki[:directory] do action :sync repository mediawiki_repository reference mediawiki_reference # depth 1 user node[:mediawiki][:user] group node[:mediawiki][:group] - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/update.php") + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/install.php]", :immediately + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/update.php]" end # Safety catch if git doesn't update but install.php hasn't run @@ -137,7 +137,7 @@ define :mediawiki_site, :action => [:create, :enable] do not_if do File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php") end - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/install.php]", :immediately action :create end @@ -166,7 +166,7 @@ define :mediawiki_site, :action => [:create, :enable] do group node[:mediawiki][:group] mode 0664 variables :name => name, :database_params => database_params, :mediawiki => mediawiki - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/update.php") + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/update.php]" end template "/etc/cron.d/mediawiki-#{cron_name}" do diff --git a/cookbooks/mediawiki/metadata.rb b/cookbooks/mediawiki/metadata.rb index 53b069d01..602db82c9 100644 --- a/cookbooks/mediawiki/metadata.rb +++ b/cookbooks/mediawiki/metadata.rb @@ -1,9 +1,11 @@ +name "mediawiki" maintainer "OpenStreetMap Administrators" maintainer_email "admins@openstreetmap.org" license "Apache 2.0" description "Installs and configures mediawiki" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" -depends "git" depends "memcached" +depends "apache" depends "mysql" +depends "git" diff --git a/cookbooks/memcached/recipes/default.rb b/cookbooks/memcached/recipes/default.rb index 8ef4cec1f..875985733 100644 --- a/cookbooks/memcached/recipes/default.rb +++ b/cookbooks/memcached/recipes/default.rb @@ -36,26 +36,8 @@ munin_plugin_conf "memcached_multi" do template "munin.erb" end -munin_plugin "memcached_multi_bytes" do - target "memcached_multi_" -end - -munin_plugin "memcached_multi_commands" do - target "memcached_multi_" -end - -munin_plugin "memcached_multi_conns" do - target "memcached_multi_" -end - -munin_plugin "memcached_multi_evictions" do - target "memcached_multi_" -end - -munin_plugin "memcached_multi_items" do - target "memcached_multi_" -end - -munin_plugin "memcached_multi_memory" do - target "memcached_multi_" +%w(bytes commands conns evictions items memory).each do |stat| + munin_plugin "memcached_multi_#{stat}" do + target "memcached_multi_" + end end diff --git a/cookbooks/munin/recipes/default.rb b/cookbooks/munin/recipes/default.rb index 79c58df58..28c05006b 100644 --- a/cookbooks/munin/recipes/default.rb +++ b/cookbooks/munin/recipes/default.rb @@ -33,16 +33,14 @@ servers = search(:node, "recipes:munin\\:\\:server") servers.each do |server| server.interfaces(:role => :external) do |interface| - if interface[:zone] - firewall_rule "accept-munin-#{server}" do - action :accept - family interface[:family] - source "#{interface[:zone]}:#{interface[:address]}" - dest "fw" - proto "tcp:syn" - dest_ports "munin" - source_ports "1024:" - end + firewall_rule "accept-munin-#{server}" do + action :accept + family interface[:family] + source "#{interface[:zone]}:#{interface[:address]}" + dest "fw" + proto "tcp:syn" + dest_ports "munin" + source_ports "1024:" end end end @@ -160,7 +158,7 @@ else end end -munin_plugin "hpasmcli_temp" do +munin_plugin "hpasmcli_temp" do # ~FC005 action :delete end diff --git a/cookbooks/mysql/recipes/default.rb b/cookbooks/mysql/recipes/default.rb index 063526fdc..5ef61b825 100644 --- a/cookbooks/mysql/recipes/default.rb +++ b/cookbooks/mysql/recipes/default.rb @@ -36,94 +36,14 @@ end package "libdbd-mysql-perl" package "libcache-cache-perl" -munin_plugin "mysql_bin_relay_log" do - target "mysql_" -end - -munin_plugin "mysql_commands" do - target "mysql_" -end - -munin_plugin "mysql_connections" do - target "mysql_" -end - -munin_plugin "mysql_files_tables" do - target "mysql_" -end - -munin_plugin "mysql_innodb_bpool" do - target "mysql_" -end - -munin_plugin "mysql_innodb_bpool_act" do - target "mysql_" -end - -munin_plugin "mysql_innodb_insert_buf" do - target "mysql_" -end - -munin_plugin "mysql_innodb_io" do - target "mysql_" -end - -munin_plugin "mysql_innodb_io_pend" do - target "mysql_" -end - -munin_plugin "mysql_innodb_log" do - target "mysql_" -end - -munin_plugin "mysql_innodb_rows" do - target "mysql_" -end - -munin_plugin "mysql_innodb_semaphores" do - target "mysql_" -end - -munin_plugin "mysql_innodb_tnx" do - target "mysql_" -end - -munin_plugin "mysql_myisam_indexes" do - target "mysql_" -end - -munin_plugin "mysql_network_traffic" do - target "mysql_" -end - -munin_plugin "mysql_qcache" do - target "mysql_" -end - -munin_plugin "mysql_qcache_mem" do - target "mysql_" -end - -munin_plugin "mysql_replication" do - target "mysql_" -end - -munin_plugin "mysql_select_types" do - target "mysql_" -end - -munin_plugin "mysql_slow" do - target "mysql_" -end - -munin_plugin "mysql_sorts" do - target "mysql_" -end - -munin_plugin "mysql_table_locks" do - target "mysql_" -end - -munin_plugin "mysql_tmp_tables" do - target "mysql_" +%w( + bin_relay_log commands connections files_tables innodb_bpool + innodb_bpool_act innodb_insert_buf innodb_io innodb_io_pend + innodb_log innodb_rows innodb_semaphores innodb_tnx myisam_indexes + network_traffic qcache qcache_mem replication select_types slow + sorts table_locks tmp_tables +).each do |stat| + munin_plugin "mysql_#{stat}" do + target "mysql_" + end end diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 50fa35cfb..2fc170b80 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -86,7 +86,7 @@ node.interfaces(:role => :internal) do |interface| next unless gateway[:openvpn] gateway[:openvpn][:tunnels].each_value do |tunnel| - if tunnel[:peer][:address] + if tunnel[:peer][:address] # ~FC023 route tunnel[:peer][:address] do netmask "255.255.255.255" gateway interface[:gateway] diff --git a/cookbooks/openssh/recipes/default.rb b/cookbooks/openssh/recipes/default.rb index fce68dbdd..a8af1dece 100644 --- a/cookbooks/openssh/recipes/default.rb +++ b/cookbooks/openssh/recipes/default.rb @@ -44,14 +44,14 @@ hosts = search(:node, "networking:interfaces").sort_by { |n| n[:hostname] }.coll end keys = { - "rsa" => node[:keys][:ssh][:host_rsa_public], - "dsa" => node[:keys][:ssh][:host_dsa_public] + "rsa" => node[:keys][:ssh][:host_rsa_public], # ~FC039 + "dsa" => node[:keys][:ssh][:host_dsa_public] # ~FC039 } - if node[:keys][:ssh][:host_ecdsa_public] - ecdsa_type = node[:keys][:ssh][:host_ecdsa_type] + if node[:keys][:ssh][:host_ecdsa_public] # ~FC039 + ecdsa_type = node[:keys][:ssh][:host_ecdsa_type] # ~FC039 - keys[ecdsa_type] = node[:keys][:ssh][:host_ecdsa_public] + keys[ecdsa_type] = node[:keys][:ssh][:host_ecdsa_public] # ~FC039 end Hash[ diff --git a/cookbooks/otrs/recipes/default.rb b/cookbooks/otrs/recipes/default.rb index a3ebf21f4..18b0c2ea6 100644 --- a/cookbooks/otrs/recipes/default.rb +++ b/cookbooks/otrs/recipes/default.rb @@ -47,13 +47,13 @@ database_user = node[:otrs][:database_user] database_password = passwords[node[:otrs][:database_password]] site = node[:otrs][:site] -remote_file "/tmp/otrs-#{version}.tar.bz2" do +remote_file "#{Chef::Config[:file_cache_path]}/otrs-#{version}.tar.bz2" do source "http://ftp.otrs.org/pub/otrs/otrs-#{version}.tar.bz2" not_if { File.exist?("/opt/otrs-#{version}") } end execute "untar-otrs-#{version}" do - command "tar jxf /tmp/otrs-#{version}.tar.bz2" + command "tar jxf #{Chef::Config[:file_cache_path]}/otrs-#{version}.tar.bz2" cwd "/opt" user "root" group "root" diff --git a/cookbooks/piwik/recipes/default.rb b/cookbooks/piwik/recipes/default.rb index d711930a1..a3eb24ad8 100644 --- a/cookbooks/piwik/recipes/default.rb +++ b/cookbooks/piwik/recipes/default.rb @@ -43,13 +43,13 @@ directory "/opt/piwik-#{version}" do mode "0755" end -remote_file "/tmp/piwik-#{version}.zip" do +remote_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do source "http://builds.piwik.org/piwik-#{version}.zip" not_if { File.exist?("/opt/piwik-#{version}/piwik") } end execute "unzip-piwik-#{version}" do - command "unzip -q /tmp/piwik-#{version}.zip" + command "unzip -q #{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" cwd "/opt/piwik-#{version}" user "root" group "root" diff --git a/cookbooks/taginfo/recipes/default.rb b/cookbooks/taginfo/recipes/default.rb index f1d5bb869..0416e2e5b 100644 --- a/cookbooks/taginfo/recipes/default.rb +++ b/cookbooks/taginfo/recipes/default.rb @@ -145,40 +145,12 @@ node[:taginfo][:sites].each do |site| notifies :restart, "service[apache2]" end - directory "#{directory}/taginfo/web/tmp" do - owner "taginfo" - group "taginfo" - mode 0755 - end - - directory "#{directory}/data" do - owner "taginfo" - group "taginfo" - mode 0755 - end - - directory "#{directory}/data/old" do - owner "taginfo" - group "taginfo" - mode 0755 - end - - directory "#{directory}/download" do - owner "taginfo" - group "taginfo" - mode 0755 - end - - directory "#{directory}/sources" do - owner "taginfo" - group "taginfo" - mode 0755 - end - - directory "#{directory}/planet" do - owner "taginfo" - group "taginfo" - mode 0755 + %w(taginfo/web/tmp bin data data/old download sources planet planet/log planet/replication).each do |dir| + directory "#{directory}/#{dir}" do + owner "taginfo" + group "taginfo" + mode 0755 + end end remote_file "#{directory}/planet/planet.pbf" do @@ -189,18 +161,6 @@ node[:taginfo][:sites].each do |site| mode 0644 end - directory "#{directory}/planet/log" do - owner "taginfo" - group "taginfo" - mode 0755 - end - - directory "#{directory}/planet/replication" do - owner "taginfo" - group "taginfo" - mode 0755 - end - template "#{directory}/planet/replication/configuration.txt" do source "configuration.txt.erb" owner "taginfo" @@ -214,12 +174,6 @@ node[:taginfo][:sites].each do |site| mode 0644 end - directory "#{directory}/bin" do - owner "taginfo" - group "taginfo" - mode 0755 - end - template "#{directory}/bin/update-planet" do source "update-planet.erb" owner "taginfo" diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index ce4819ad0..19c99b0ce 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -84,7 +84,7 @@ nginx_site "default" do end resolvers = node[:networking][:nameservers].map do |resolver| - IPAddr.new(resolver).ipv6? ? "[#{resolver}]" : "#{resolver}" + IPAddr.new(resolver).ipv6? ? "[#{resolver}]" : resolver end nginx_site "tile-ssl" do diff --git a/cookbooks/wiki/README.md b/cookbooks/wiki/README.md new file mode 100644 index 000000000..205739199 --- /dev/null +++ b/cookbooks/wiki/README.md @@ -0,0 +1,34 @@ +Cookbook +======== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +Attributes +---------- +TODO: List you cookbook attributes here. + +Usage +----- +TODO: Write usage instructions for each cookbook. + +Contributing +------------ +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +License and Authors +------------------- +Authors: TODO: List authors diff --git a/cookbooks/wiki/README.rdoc b/cookbooks/wiki/README.rdoc deleted file mode 100644 index 3de2ec7a3..000000000 --- a/cookbooks/wiki/README.rdoc +++ /dev/null @@ -1,8 +0,0 @@ -= DESCRIPTION: - -= REQUIREMENTS: - -= ATTRIBUTES: - -= USAGE: - diff --git a/cookbooks/wiki/metadata.rb b/cookbooks/wiki/metadata.rb index e3f9063be..b93706b8e 100644 --- a/cookbooks/wiki/metadata.rb +++ b/cookbooks/wiki/metadata.rb @@ -1,8 +1,9 @@ +name "wiki" maintainer "OpenStreetMap Administrators" maintainer_email "admins@openstreetmap.org" license "Apache 2.0" description "Installs and configures servers for wiki.openstreetmap.org" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" depends "mediawiki" depends "squid" -- 2.39.5