From aab42e3b80e8f518ca99165a3ec2ecb712bf19c4 Mon Sep 17 00:00:00 2001 From: Dennis Hoer Date: Wed, 9 Sep 2015 11:18:03 -0700 Subject: [PATCH 1/6] Update changelog --- CHANGELOG.md | 6 ++++-- README.md | 14 +++++++++----- attributes/default.rb | 2 ++ metadata.rb | 2 +- recipes/default.rb | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdf668a..f763e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ WildFly Cookbook CHANGELOG ========================== +# 0.2.0 (2015-09-09) +* Make install of Java optional. + # 0.1.19 (2015-04-01) * Fixed location of wildfly.conf in Debian init script. - # 0.1.18 (2015-03-19) * Adjusted behavior of the service user update procedure. * Fixed hardcoded username. @@ -104,4 +106,4 @@ WildFly Cookbook CHANGELOG # 0.1.0 (2014-02-18) -* Initial commit \ No newline at end of file +* Initial commit diff --git a/README.md b/README.md index f0dfbd7..80e215e 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,8 @@ Cookbook to deploy Wildfly Java Application Server # Requirements -Chef Client 11+ - -Java Opscode Community Cookbook +- Chef Client 11+ +- Java Cookbook (ignored if node['wildfly']['install_java'] is false) # Platform - CentOS, Red Hat @@ -17,9 +16,13 @@ You can add users in the proper format to `attributes\users.rb` You can customize the Java version, and the Connector/J if you'd like. -If running in production, I STRONGLY recommend you use a wrapper cookbook, and manually specify the Wildfly version, Java version, and cookbook version as well. This cookbook and configuration templates will continually be updated to support the latest stable release of Wildfly. Currently, version upgrades will trigger configuration enforcement, meaning any changes made outside of Chef will be wiped out. +If running in production, I STRONGLY recommend you use a wrapper cookbook, and manually specify the Wildfly version, +Java version (if node['wildfly']['install_java'] is true), and cookbook version as well. +This cookbook and configuration templates will continually be updated to support the latest stable release of Wildfly. +Currently, version upgrades will trigger configuration enforcement, meaning any changes made outside of Chef will be wiped out. # Attributes +* `node['wildfly']['install_java']` - Install Java using Java Cookbook. Default `true` * `node['wildfly']['base']` - Base directory to run Wildfly from * `node['wildfly']['version']` - Specify the version of Wildfly @@ -39,7 +42,8 @@ If running in production, I STRONGLY recommend you use a wrapper cookbook, and m # Recipes -* `::default` - Installs Java & Wildfly. Also installs Connector/J if you've got it enabled. +* `::default` - Installs Java (if node['wildfly']['install_java'] is true) & Wildfly. +Also installs Connector/J if you've got it enabled. * `::install` - Installs Wildfly. * `::mysql_connector` - Installs Connector/J into appropriate Wildfly directory. diff --git a/attributes/default.rb b/attributes/default.rb index 973140f..b5b6ab3 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -91,3 +91,5 @@ # => Hardcode JAVA_HOME into init.d configuration. # => Based on value of node['java']['java_home'] default['wildfly']['java']['enforce_java_home'] = true + +default['wildfly']['install_java'] = true diff --git a/metadata.rb b/metadata.rb index 0771834..7d4b0c9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,7 +6,7 @@ license 'Apache License, Version 2.0' description 'Installs/Configures wildfly' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.1.19' +version '0.2.0' supports 'centos' diff --git a/recipes/default.rb b/recipes/default.rb index ff54f77..4f68aa6 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -19,7 +19,7 @@ # limitations under the License. # -include_recipe 'java' +include_recipe 'java' if node['wildfly']['install_java'] include_recipe 'wildfly::install' include_recipe 'wildfly::mysql_connector' if node['wildfly']['mysql']['enabled'] include_recipe 'wildfly::postgres_connector' if node['wildfly']['postgresql']['enabled'] From 0d8d3cb32c7bfd49a9da740eb7161ea76dedb918 Mon Sep 17 00:00:00 2001 From: Dennis Hoer Date: Wed, 9 Sep 2015 11:44:12 -0700 Subject: [PATCH 2/6] Fix rubocop offenses --- Berksfile | 2 +- Vagrantfile | 7 +++---- attributes/default.rb | 1 - attributes/mysql_datasources.rb | 1 - attributes/postgres_datasources.rb | 2 +- attributes/system_properties.rb | 1 - attributes/users.rb | 1 - providers/attribute.rb | 6 +++--- providers/datasource.rb | 10 +++++----- providers/deploy.rb | 30 +++++++++++++++--------------- providers/logcategory.rb | 10 +++++----- providers/loghandler.rb | 10 +++++----- providers/property.rb | 10 +++++----- recipes/default.rb | 1 - resources/attribute.rb | 11 +++++------ resources/datasource.rb | 9 ++++----- resources/deploy.rb | 11 +++++------ resources/logcategory.rb | 9 ++++----- resources/loghandler.rb | 19 +++++++++---------- resources/property.rb | 9 ++++----- 20 files changed, 74 insertions(+), 86 deletions(-) diff --git a/Berksfile b/Berksfile index 26c74c6..b5d5531 100644 --- a/Berksfile +++ b/Berksfile @@ -1,3 +1,3 @@ -source "http://api.berkshelf.com" +source 'http://api.berkshelf.com' metadata diff --git a/Vagrantfile b/Vagrantfile index a02a095..a5806a6 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -6,9 +6,9 @@ ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_workstation' # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" +VAGRANTFILE_API_VERSION = '2' -Vagrant.require_version ">= 1.5.0" +Vagrant.require_version '>= 1.5.0' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration @@ -19,11 +19,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Set the version of chef to install using the vagrant-omnibus plugin - config.omnibus.chef_version = :latest # Every Vagrant virtual environment requires a box to build off of. - # If this value is a shorthand to a box in Vagrant Cloud then + # If this value is a shorthand to a box in Vagrant Cloud then # config.vm.box_url doesn't need to be specified. config.vm.box = 'CentOS6.6_x64' diff --git a/attributes/default.rb b/attributes/default.rb index b5b6ab3..833e207 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # diff --git a/attributes/mysql_datasources.rb b/attributes/mysql_datasources.rb index 792722f..56d7ab3 100644 --- a/attributes/mysql_datasources.rb +++ b/attributes/mysql_datasources.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # diff --git a/attributes/postgres_datasources.rb b/attributes/postgres_datasources.rb index 159561b..190ec32 100644 --- a/attributes/postgres_datasources.rb +++ b/attributes/postgres_datasources.rb @@ -19,4 +19,4 @@ pool_min: '5', pool_max: '20' } -] \ No newline at end of file +] diff --git a/attributes/system_properties.rb b/attributes/system_properties.rb index 1a9139b..5101e42 100644 --- a/attributes/system_properties.rb +++ b/attributes/system_properties.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # diff --git a/attributes/users.rb b/attributes/users.rb index 1f22583..b7a8a7a 100644 --- a/attributes/users.rb +++ b/attributes/users.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # diff --git a/providers/attribute.rb b/providers/attribute.rb index 5ee1bb9..4638fac 100644 --- a/providers/attribute.rb +++ b/providers/attribute.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, MethodLength +# rubocop:disable LineLength, Metrics/AbcSize, MethodLength # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # @@ -26,9 +26,9 @@ def whyrun_supported? action :set do if @current_resource.exists - Chef::Log.info "#{ @new_resource } already set - nothing to do." + Chef::Log.info "#{@new_resource} already set - nothing to do." else - converge_by("Set #{ @new_resource }") do + converge_by("Set #{@new_resource}") do attribute_set end end diff --git a/providers/datasource.rb b/providers/datasource.rb index 005d94f..7660bfb 100644 --- a/providers/datasource.rb +++ b/providers/datasource.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, MethodLength +# rubocop:disable LineLength, SpecialGlobalVars, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # @@ -25,9 +25,9 @@ def whyrun_supported? action :create do if @current_resource.exists - Chef::Log.info "#{ @new_resource } already exists - nothing to do." + Chef::Log.info "#{@new_resource} already exists - nothing to do." else - converge_by("Create #{ @new_resource }") do + converge_by("Create #{@new_resource}") do create_datasource end end @@ -35,11 +35,11 @@ def whyrun_supported? action :delete do if @current_resource.exists - converge_by("Delete #{ @new_resource }") do + converge_by("Delete #{@new_resource}") do delete_datasource end else - Chef::Log.info "#{ @current_resource } doesn't exist - can't delete." + Chef::Log.info "#{@current_resource} doesn't exist - can't delete." end end diff --git a/providers/deploy.rb b/providers/deploy.rb index 094cf8e..717e18b 100644 --- a/providers/deploy.rb +++ b/providers/deploy.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars +# rubocop:disable LineLength, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # @@ -26,11 +26,11 @@ def whyrun_supported? action :install do if runtime_exists? - Chef::Log.info "#{ @new_resource.runtime_name } already exists" + Chef::Log.info "#{@new_resource.runtime_name} already exists" if deploy_exists? - Chef::Log.info "#{ @new_resource.name } already enabled - nothing to do." + Chef::Log.info "#{@new_resource.name} already enabled - nothing to do." else - Chef::Log.info "#{ @new_resource.name } is not the active resource." + Chef::Log.info "#{@new_resource.name} is not the active resource." deploy_remove(@current_resource.runtime_name, false) read_deployment_details(true) deploy_install(@current_resource.cli, @current_resource.name, @current_resource.runtime_name) @@ -44,25 +44,25 @@ def whyrun_supported? if runtime_exists? deploy_remove(@current_resource.runtime_name, false) else - Chef::Log.info "#{ @new_resource.runtime_name } does not exist - nothing to do." + Chef::Log.info "#{@new_resource.runtime_name} does not exist - nothing to do." end end action :enable do if runtime_exists? - Chef::Log.info "#{ @new_resource.runtime_name } already exists" + Chef::Log.info "#{@new_resource.runtime_name} already exists" if deploy_exists? if deploy_enabled?(@current_resource.name) - Chef::Log.info "#{ @new_resource.name } resource is already enabled." + Chef::Log.info "#{@new_resource.name} resource is already enabled." else - Chef::Log.info "#{ @new_resource.name } activating previously loaded resource." + Chef::Log.info "#{@new_resource.name} activating previously loaded resource." deploy_install('', @current_resource.name, @current_resource.runtime_name) end else - Chef::Log.info "#{ @new_resource.name } resource does not exist yet, cannot enable." + Chef::Log.info "#{@new_resource.name} resource does not exist yet, cannot enable." end else - Chef::Log.info "#{ @new_resource.runtime_name } resource does not exist yet, cannot enable." + Chef::Log.info "#{@new_resource.runtime_name} resource does not exist yet, cannot enable." end end @@ -70,7 +70,7 @@ def whyrun_supported? if runtime_exists? deploy_remove(@current_resource.runtime_name, true) else - Chef::Log.info "#{ @new_resource.runtime_name } does not exist - nothing to do." + Chef::Log.info "#{@new_resource.runtime_name} does not exist - nothing to do." end end @@ -102,7 +102,7 @@ def deploy_enabled?(name) def deploy_install(source, name, runtime_name) Chef::Log.info "Deploying #{name}" - converge_by((source == '' ? 'Enabling' : 'Deploying') + " #{ detailed_name(runtime_name, name) }") do + converge_by((source == '' ? 'Enabling' : 'Deploying') + " #{detailed_name(runtime_name, name)}") do result = shell_out("bin/jboss-cli.sh -c ' deploy #{source} --name=#{name} --runtime-name=#{runtime_name}'", user: node['wildfly']['user'], cwd: node['wildfly']['base']) result.error! if result.exitstatus != 0 end @@ -111,8 +111,8 @@ def deploy_install(source, name, runtime_name) def deploy_remove(runtime_name, keep_content = false) deployments = read_deployment_details - deployments[runtime_name].each do | deployed | - converge_by((keep_content ? 'Disabling' : 'Removing') + " #{ detailed_name(runtime_name, deployed.keys.first) }") do + deployments[runtime_name].each do |deployed| + converge_by((keep_content ? 'Disabling' : 'Removing') + " #{detailed_name(runtime_name, deployed.keys.first)}") do Chef::Log.info 'Undeploying #{detailed_name(runtime_name, deployed.keys.first)}' result = shell_out("bin/jboss-cli.sh -c ' undeploy #{deployed.keys.first} #{keep_content ? '--keep-content' : ''}'", user: node['wildfly']['user'], cwd: node['wildfly']['base']) result.error! if result.exitstatus != 0 @@ -136,7 +136,7 @@ def detailed_name(runtime_name, name) def format_output(data) result = {} - data.split(/\n/).each do | item | + data.split(/\n/).each do |item| output = item.split(/\s+/) if result.key?(output[1]) result[output[1]] << { output[0] => { persistent: output[2], enabled: output[3], status: output[4] } } diff --git a/providers/logcategory.rb b/providers/logcategory.rb index 186b7bf..094d7c0 100644 --- a/providers/logcategory.rb +++ b/providers/logcategory.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, MethodLength +# rubocop:disable LineLength, SpecialGlobalVars, MethodLength, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # @@ -25,9 +25,9 @@ def whyrun_supported? action :create do if @current_resource.exists - Chef::Log.info "#{ @new_resource } already exists - nothing to do." + Chef::Log.info "#{@new_resource} already exists - nothing to do." else - converge_by("Create #{ @new_resource }") do + converge_by("Create #{@new_resource}") do create_logcategory end end @@ -35,11 +35,11 @@ def whyrun_supported? action :delete do if @current_resource.exists - converge_by("Delete #{ @new_resource }") do + converge_by("Delete #{@new_resource}") do delete_logcategory end else - Chef::Log.info "#{ @current_resource } doesn't exist - can't delete." + Chef::Log.info "#{@current_resource} doesn't exist - can't delete." end end diff --git a/providers/loghandler.rb b/providers/loghandler.rb index 95dd419..97215c9 100644 --- a/providers/loghandler.rb +++ b/providers/loghandler.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, MethodLength +# rubocop:disable LineLength, SpecialGlobalVars, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # @@ -25,9 +25,9 @@ def whyrun_supported? action :create do if @current_resource_exists - Chef::Log.info "#{ @new_resource } already exists - nothing to do." + Chef::Log.info "#{@new_resource} already exists - nothing to do." else - converge_by("Create #{ @new_resource }") do + converge_by("Create #{@new_resource}") do create_loghandler end end @@ -35,11 +35,11 @@ def whyrun_supported? action :delete do if @current_resource.exists - converge_by("Delete #{ @new_resource }") do + converge_by("Delete #{@new_resource}") do delete_loghandler end else - Chef::Log.info "#{ @current_resource } doesn't exist - can't delete." + Chef::Log.info "#{@current_resource} doesn't exist - can't delete." end end diff --git a/providers/property.rb b/providers/property.rb index caeb6a5..2bb2608 100644 --- a/providers/property.rb +++ b/providers/property.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, MethodLength +# rubocop:disable LineLength, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # @@ -27,9 +27,9 @@ def whyrun_supported? action :set do if property_value_exists? - Chef::Log.info "#{ @new_resource } already set - nothing to do." + Chef::Log.info "#{@new_resource} already set - nothing to do." else - converge_by("Set #{ @new_resource }") do + converge_by("Set #{@new_resource}") do property_set end notify? @@ -38,12 +38,12 @@ def whyrun_supported? action :delete do if property_exists? - converge_by("Delete #{ @new_resource }") do + converge_by("Delete #{@new_resource}") do property_delete end notify? else - Chef::Log.info "#{ @new_resource } not present - nothing to do." + Chef::Log.info "#{@new_resource} not present - nothing to do." end end diff --git a/recipes/default.rb b/recipes/default.rb index 4f68aa6..163e5d9 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength # # Cookbook Name:: wildfly # Recipe:: default diff --git a/resources/attribute.rb b/resources/attribute.rb index acbce6c..eece7f6 100644 --- a/resources/attribute.rb +++ b/resources/attribute.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, HashSyntax # # LWRP that sets an attribute # @@ -21,10 +20,10 @@ actions :set default_action :set -attribute :name, :kind_of => String, :required => true, :name_attribute => true -attribute :parameter, :kind_of => String -attribute :value, :kind_of => String -attribute :path, :kind_of => String -attribute :restart, :kind_of => [TrueClass, FalseClass], :default => true +attribute :name, kind_of: String, required: true, name_attribute: true +attribute :parameter, kind_of: String +attribute :value, kind_of: String +attribute :path, kind_of: String +attribute :restart, kind_of: [TrueClass, FalseClass], default: true attr_accessor :exists diff --git a/resources/datasource.rb b/resources/datasource.rb index 1c3f5f4..904161f 100644 --- a/resources/datasource.rb +++ b/resources/datasource.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, HashSyntax # # LWRP that provisions a datasource # @@ -21,9 +20,9 @@ actions :create, :delete default_action :create -attribute :name, :kind_of => String, :required => true, :name_attribute => true -attribute :jndiname, :kind_of => String -attribute :drivername, :kind_of => String -attribute :connectionurl, :kind_of => String +attribute :name, kind_of: String, required: true, name_attribute: true +attribute :jndiname, kind_of: String +attribute :drivername, kind_of: String +attribute :connectionurl, kind_of: String attr_accessor :exists diff --git a/resources/deploy.rb b/resources/deploy.rb index e389c2d..5089523 100644 --- a/resources/deploy.rb +++ b/resources/deploy.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, HashSyntax # # LWRP that deploys war "name" from either path :path or url :url # @@ -20,10 +19,10 @@ actions :install, :remove, :enable, :disable default_action :install -attribute :name, :kind_of => String, :required => true, :name_attribute => true -attribute :runtime_name, :kind_of => String, :default => 'noname' -attribute :path, :kind_of => String, :default => 'nopath' -attribute :url, :kind_of => String, :default => 'nourl' -attribute :cli, :kind_of => String +attribute :name, kind_of: String, required: true, name_attribute: true +attribute :runtime_name, kind_of: String, default: 'noname' +attribute :path, kind_of: String, default: 'nopath' +attribute :url, kind_of: String, default: 'nourl' +attribute :cli, kind_of: String attr_accessor :exists diff --git a/resources/logcategory.rb b/resources/logcategory.rb index 4204fb5..aab5ab2 100644 --- a/resources/logcategory.rb +++ b/resources/logcategory.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, HashSyntax # # LWRP that provisions a datasource # @@ -21,9 +20,9 @@ actions :create, :delete default_action :create -attribute :name, :kind_of => String, :required => true, :name_attribute => true -attribute :use_parent_handlers, :kind_of => String -attribute :level, :kind_of => String -attribute :handlers, :kind_of => Array +attribute :name, kind_of: String, required: true, name_attribute: true +attribute :use_parent_handlers, kind_of: String +attribute :level, kind_of: String +attribute :handlers, kind_of: Array attr_accessor :exists diff --git a/resources/loghandler.rb b/resources/loghandler.rb index b95d864..f0e7840 100644 --- a/resources/loghandler.rb +++ b/resources/loghandler.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, HashSyntax # # LWRP that provisions a datasource # @@ -21,14 +20,14 @@ actions :create, :delete default_action :create -attribute :name, :kind_of => String, :required => true, :name_attribute => true -attribute :type, :kind_of => String, :required => true -attribute :hostname, :kind_of => String, :default => 'localhost' -attribute :server_address, :kind_of => String, :default => 'localhost' -attribute :port, :kind_of => String, :default => '514' -attribute :level, :kind_of => String, :default => 'ALL' -attribute :syslog_format, :kind_of => String, :default => 'RFC5424' -attribute :enabled, :kind_of => String, :default => 'true' -attribute :app_name, :kind_of => String, :required => true +attribute :name, kind_of: String, required: true, name_attribute: true +attribute :type, kind_of: String, required: true +attribute :hostname, kind_of: String, default: 'localhost' +attribute :server_address, kind_of: String, default: 'localhost' +attribute :port, kind_of: String, default: '514' +attribute :level, kind_of: String, default: 'ALL' +attribute :syslog_format, kind_of: String, default: 'RFC5424' +attribute :enabled, kind_of: String, default: 'true' +attribute :app_name, kind_of: String, required: true attr_accessor :exists diff --git a/resources/property.rb b/resources/property.rb index 286b634..4e33d5f 100644 --- a/resources/property.rb +++ b/resources/property.rb @@ -1,5 +1,4 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, HashSyntax # # LWRP that sets a system property # @@ -21,9 +20,9 @@ actions :set, :delete default_action :set -attribute :name, :kind_of => String, :required => true, :name_attribute => true -attribute :property, :kind_of => String, :required => true -attribute :value, :kind_of => String -attribute :restart, :kind_of => [TrueClass, FalseClass], :default => true +attribute :name, kind_of: String, required: true, name_attribute: true +attribute :property, kind_of: String, required: true +attribute :value, kind_of: String +attribute :restart, kind_of: [TrueClass, FalseClass], default: true attr_accessor :exists From 292eb4a6645c50892a4f712f55b4979cd27c62de Mon Sep 17 00:00:00 2001 From: Dennis Hoer Date: Wed, 9 Sep 2015 12:24:07 -0700 Subject: [PATCH 3/6] Fix FC017: LWRP does not notify when updated --- providers/deploy.rb | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/providers/deploy.rb b/providers/deploy.rb index 717e18b..8817789 100644 --- a/providers/deploy.rb +++ b/providers/deploy.rb @@ -30,19 +30,24 @@ def whyrun_supported? if deploy_exists? Chef::Log.info "#{@new_resource.name} already enabled - nothing to do." else - Chef::Log.info "#{@new_resource.name} is not the active resource." - deploy_remove(@current_resource.runtime_name, false) - read_deployment_details(true) - deploy_install(@current_resource.cli, @current_resource.name, @current_resource.runtime_name) + converge_by("#{@new_resource.name} is not the active resource.") do + deploy_remove(@current_resource.runtime_name, false) + read_deployment_details(true) + deploy_install(@current_resource.cli, @current_resource.name, @current_resource.runtime_name) + end end else - deploy_install(@current_resource.cli, @current_resource.name, @current_resource.runtime_name) + converge_by("install #{@new_resource.name}") do + deploy_install(@current_resource.cli, @current_resource.name, @current_resource.runtime_name) + end end end action :remove do if runtime_exists? - deploy_remove(@current_resource.runtime_name, false) + converge_by("remove #{@current_resource.runtime_name}") do + deploy_remove(@current_resource.runtime_name, false) + end else Chef::Log.info "#{@new_resource.runtime_name} does not exist - nothing to do." end @@ -55,8 +60,9 @@ def whyrun_supported? if deploy_enabled?(@current_resource.name) Chef::Log.info "#{@new_resource.name} resource is already enabled." else - Chef::Log.info "#{@new_resource.name} activating previously loaded resource." - deploy_install('', @current_resource.name, @current_resource.runtime_name) + converge_by("#{@new_resource.name} activating previously loaded resource.") do + deploy_install('', @current_resource.name, @current_resource.runtime_name) + end end else Chef::Log.info "#{@new_resource.name} resource does not exist yet, cannot enable." @@ -68,7 +74,9 @@ def whyrun_supported? action :disable do if runtime_exists? - deploy_remove(@current_resource.runtime_name, true) + converge_by("disable #{@current_resource.runtime_name}") do + deploy_remove(@current_resource.runtime_name, true) + end else Chef::Log.info "#{@new_resource.runtime_name} does not exist - nothing to do." end From b564e944fc156ccf82f4d1953622d8b003f4e6b5 Mon Sep 17 00:00:00 2001 From: Dennis Hoer Date: Wed, 9 Sep 2015 12:46:54 -0700 Subject: [PATCH 4/6] Fix FC048: Prefer Mixlib::ShellOut --- providers/datasource.rb | 5 +++-- providers/logcategory.rb | 5 +++-- providers/loghandler.rb | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/providers/datasource.rb b/providers/datasource.rb index 7660bfb..9ad6780 100644 --- a/providers/datasource.rb +++ b/providers/datasource.rb @@ -17,6 +17,7 @@ # require 'etc' +include Chef::Mixin::ShellOut # Support whyrun def whyrun_supported? @@ -56,8 +57,8 @@ def load_current_resource private def datasource_exists?(name) - `su #{node['wildfly']['user']} -s /bin/bash -c "#{node['wildfly']['base']}/bin/jboss-cli.sh -c ' /subsystem=datasources/data-source=#{name}:read-resource'"` - $?.exitstatus == 0 + result = shell_out("su #{node['wildfly']['user']} -s /bin/bash -c \"#{node['wildfly']['base']}/bin/jboss-cli.sh -c ' /subsystem=datasources/data-source=#{name}:read-resource'\"") + result.exitstatus == 0 end def create_datasource diff --git a/providers/logcategory.rb b/providers/logcategory.rb index 094d7c0..9cce304 100644 --- a/providers/logcategory.rb +++ b/providers/logcategory.rb @@ -17,6 +17,7 @@ # require 'etc' +include Chef::Mixin::ShellOut # Support whyrun def whyrun_supported? @@ -56,8 +57,8 @@ def load_current_resource private def logcategory_exists?(name) - `su #{node['wildfly']['user']} -s /bin/bash -c "#{node['wildfly']['base']}/bin/jboss-cli.sh -c ' /subsystem=logging/logger=#{name}:read-resource'"` - $?.exitstatus == 0 + result = shell_out("su #{node['wildfly']['user']} -s /bin/bash -c \"#{node['wildfly']['base']}/bin/jboss-cli.sh -c ' /subsystem=logging/logger=#{name}:read-resource'\"") + result.exitstatus == 0 end def create_logcategory diff --git a/providers/loghandler.rb b/providers/loghandler.rb index 97215c9..2963120 100644 --- a/providers/loghandler.rb +++ b/providers/loghandler.rb @@ -17,6 +17,7 @@ # require 'etc' +include Chef::Mixin::ShellOut # Support whyrun def whyrun_supported? @@ -50,9 +51,8 @@ def load_current_resource private def loghandler_exists?(name) - `su #{node['wildfly']['user']} -s /bin/bash -c "#{node['wildfly']['base']}/bin/jboss-cli.sh -c ' /subsystem=logging/#{new_resource.type}=#{name}:read-resource'"` - - $?.exitstatus == 0 + result = shell_out("su #{node['wildfly']['user']} -s /bin/bash -c \"#{node['wildfly']['base']}/bin/jboss-cli.sh -c ' /subsystem=logging/#{new_resource.type}=#{name}:read-resource'\"") + result.exitstatus == 0 end def create_loghandler From 2101d7143360c1151be1c56bcb5567945f436e6b Mon Sep 17 00:00:00 2001 From: Dennis Hoer Date: Wed, 9 Sep 2015 12:47:12 -0700 Subject: [PATCH 5/6] Ignore FC048: Prefer Mixlib::ShellOut --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2e610d7..f27e3a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,6 @@ rvm: - 1.9.3 - 2.0.0 script: - - bundle exec foodcritic -f any . --tags ~FC007 --tags ~FC024 + - bundle exec foodcritic -f any . --tags ~FC007 --tags ~FC024 --tags ~FC048 # - bundle exec rspec --color --format progress - bundle exec rubocop From 9dba78d1554af905bee6c5fee780aaf0e2175be1 Mon Sep 17 00:00:00 2001 From: Dennis Hoer Date: Wed, 9 Sep 2015 12:54:27 -0700 Subject: [PATCH 6/6] Fix rubocop Lint/UnneededDisable: Unnecessary disabling of Style/SpecialGlobalVars offenses --- providers/datasource.rb | 2 +- providers/logcategory.rb | 2 +- providers/loghandler.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/datasource.rb b/providers/datasource.rb index 9ad6780..1530ce9 100644 --- a/providers/datasource.rb +++ b/providers/datasource.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, Metrics/AbcSize +# rubocop:disable LineLength, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # diff --git a/providers/logcategory.rb b/providers/logcategory.rb index 9cce304..79d6e58 100644 --- a/providers/logcategory.rb +++ b/providers/logcategory.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, MethodLength, Metrics/AbcSize +# rubocop:disable LineLength, MethodLength, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services # diff --git a/providers/loghandler.rb b/providers/loghandler.rb index 2963120..c51ecbc 100644 --- a/providers/loghandler.rb +++ b/providers/loghandler.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 -# rubocop:disable LineLength, SpecialGlobalVars, Metrics/AbcSize +# rubocop:disable LineLength, Metrics/AbcSize # # Copyright (C) 2014 Brian Dwyer - Intelligent Digital Services #