Skip to content

Commit

Permalink
Enable unified mode for custom resources
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed May 14, 2021
1 parent e455b3a commit a08c8d9
Show file tree
Hide file tree
Showing 42 changed files with 108 additions and 33 deletions.
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 41
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: **/resources/*.rb
Chef/Deprecations/ResourceWithoutUnifiedTrue:
Enabled: false

# Offense count: 1124
# Cop supports --auto-correct.
# Configuration parameters: .
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/apache/resources/conf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action [:create, :enable]

property :conf, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/apache/resources/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action [:install, :enable]

property :module, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/apache/resources/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action [:create, :enable]

property :site, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/fail2ban/resources/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :filter, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/fail2ban/resources/jail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :jail, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/imagery/resources/layer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

require "yaml"

unified_mode true

default_action :create

property :layer, String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/imagery/resources/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

require "yaml"

unified_mode true

default_action :create

property :site, String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/mediawiki/resources/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :extension, :kind_of => String, :name_property => true
Expand Down
54 changes: 28 additions & 26 deletions cookbooks/mediawiki/resources/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :site, :kind_of => String, :name_property => true
Expand Down Expand Up @@ -76,27 +78,6 @@
end
end

execute "#{mediawiki_directory}/maintenance/install.php" do
action :nothing
# Use metanamespace as Site Name to ensure correct set namespace
command "php maintenance/install.php --server '#{name}' --dbtype 'mysql' --dbname '#{new_resource.database_name}' --dbuser '#{new_resource.database_user}' --dbpass '#{new_resource.database_password}' --dbserver 'localhost' --scriptpath /w --pass '#{new_resource.admin_password}' '#{new_resource.metanamespace}' '#{new_resource.admin_user}'"
cwd mediawiki_directory
user node[:mediawiki][:user]
group node[:mediawiki][:group]
not_if do
::File.exist?("#{mediawiki_directory}/LocalSettings-install.php")
end
notifies :run, "ruby_block[rename-installer-localsettings]", :immediately
end

execute "#{mediawiki_directory}/maintenance/update.php" do
action :nothing
command "php maintenance/update.php --quick"
cwd mediawiki_directory
user node[:mediawiki][:user]
group node[:mediawiki][:group]
end

declare_resource :directory, site_directory do
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
Expand All @@ -121,6 +102,14 @@
notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]"
end

template "#{mediawiki_directory}/composer.local.json" do
cookbook "mediawiki"
source "composer.local.json.erb"
owner node[:mediawiki][:user]
group node[:mediawiki][:group]
mode "664"
end

execute "#{mediawiki_directory}/composer.json" do
action :nothing
command "composer update --no-dev"
Expand All @@ -130,12 +119,25 @@
environment "COMPOSER_HOME" => site_directory
end

template "#{mediawiki_directory}/composer.local.json" do
cookbook "mediawiki"
source "composer.local.json.erb"
owner node[:mediawiki][:user]
execute "#{mediawiki_directory}/maintenance/install.php" do
action :nothing
# Use metanamespace as Site Name to ensure correct set namespace
command "php maintenance/install.php --server '#{name}' --dbtype 'mysql' --dbname '#{new_resource.database_name}' --dbuser '#{new_resource.database_user}' --dbpass '#{new_resource.database_password}' --dbserver 'localhost' --scriptpath /w --pass '#{new_resource.admin_password}' '#{new_resource.metanamespace}' '#{new_resource.admin_user}'"
cwd mediawiki_directory
user node[:mediawiki][:user]
group node[:mediawiki][:group]
not_if do
::File.exist?("#{mediawiki_directory}/LocalSettings-install.php")
end
notifies :run, "ruby_block[rename-installer-localsettings]", :immediately
end

execute "#{mediawiki_directory}/maintenance/update.php" do
action :nothing
command "php maintenance/update.php --quick"
cwd mediawiki_directory
user node[:mediawiki][:user]
group node[:mediawiki][:group]
mode "664"
end

# Safety catch if git doesn't update but install.php hasn't run
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/mediawiki/resources/skin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :skin, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/munin/resources/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :plugin, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/munin/resources/plugin_conf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :plugin_conf, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/mysql/resources/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :database, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/mysql/resources/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :user, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/networking/resources/firewall_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
resource_name :firewall_rule
provides :firewall_rule

unified_mode true

default_action :nothing

property :rule, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/nginx/resources/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :site, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/nodejs/resources/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

require "json"

unified_mode true

default_action :install

property :package, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/ohai/resources/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :plugin, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/passenger/resources/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :restart

property :application, String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/php/resources/fpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :pool, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :database, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/execute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :run

property :command, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :extension, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/munin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :munin, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :table, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/tablespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :tablespace, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/postgresql/resources/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

require "shellwords"

unified_mode true

default_action :create

property :user, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/prometheus/resources/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :collector, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/prometheus/resources/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :exporter, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/python/resources/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :install

property :package_name, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/python/resources/virtualenv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :virtualenv_directory, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/squid/resources/fragment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :fragment, :kind_of => String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/ssl/resources/certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :certificate, String, :name_property => true
Expand Down
2 changes: 2 additions & 0 deletions cookbooks/systemd/resources/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# limitations under the License.
#

unified_mode true

default_action :create

property :path, String, :name_property => true
Expand Down
Loading

0 comments on commit a08c8d9

Please sign in to comment.