[icinga-checkins] icinga.org: chef-icinga2/master: Make rubocop happy

git at icinga.org git at icinga.org
Mon Dec 19 18:41:45 CET 2016


Module: chef-icinga2
Branch: master
Commit: a61be26a0d6975e43dc4aa76167e0695facf4072
URL:    https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=a61be26a0d6975e43dc4aa76167e0695facf4072

Author: Blerim Sheqa <blerim.sheqa at netways.de>
Date:   Mon Nov 28 12:01:43 2016 +0100

Make rubocop happy

---

 .rubocop.yml                  |    1 +
 libraries/search.rb           |    6 ++---
 recipes/server_os_packages.rb |   58 ++++++++++++++++++++---------------------
 recipes/server_web2.rb        |   14 +++++-----
 4 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/.rubocop.yml b/.rubocop.yml
index e401fdd..7a3e9a4 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,4 +1,5 @@
 AllCops:
+  TargetRubyVersion: 2.2
   Exclude:
     - Rakefile
     - Berksfile
diff --git a/libraries/search.rb b/libraries/search.rb
index 97d8fa1..e8e84f4 100644
--- a/libraries/search.rb
+++ b/libraries/search.rb
@@ -206,8 +206,8 @@ module Icinga2
       node_hash['chef_environment'] = node.chef_environment
       node_hash['environment'] = node.chef_environment
       node_hash['run_list'] = node.run_list
-      node_hash['recipes'] = !node.run_list.nil? ? node.run_list&.recipes
-      node_hash['roles'] = !node.run_list.nil? ? node.run_list&.roles
+      node_hash['recipes'] = !node.run_list.nil? ? node.run_list.recipes : []
+      node_hash['roles'] = !node.run_list.nil? ? node.run_list.roles : []
       node_hash['fqdn'] = node['fqdn']
       node_hash['hostname'] = node['hostname']
       node_hash['kernel_machine'] = !node['kernel'].nil? ? node['kernel']['machine'] : nil
@@ -299,7 +299,7 @@ module Icinga2
     def node_custom_vars(vars)
       custom_vars = {}
       # add icinga2 host custom vars from node custom_vars
-      if vars&.key?('client')
+      if vars && vars.key?('client')
         if vars['client'].key?('custom_vars') && vars['client']['custom_vars'].is_a?(Hash)
           custom_vars = vars['client']['custom_vars'].to_hash
         end
diff --git a/recipes/server_os_packages.rb b/recipes/server_os_packages.rb
index eb9708d..840e179 100644
--- a/recipes/server_os_packages.rb
+++ b/recipes/server_os_packages.rb
@@ -20,39 +20,39 @@
 # install packages for icinga2 / classicui2 / web2
 
 case node['platform_family']
-  when 'debian'
-    case node['lsb']['codename']
-      when 'trusty'
-        # package libjpeg62-dev conflicts with libgd2-xpm-dev
-        # perhaps can be removed.
-        os_packages = %w(g++ mailutils php5 php5-cli php5-fpm build-essential
-                      libgd2-xpm-dev libjpeg62 libpng12-0
-                      libpng12-dev libapache2-mod-php5 imagemagick
-                      php5-imagick php-pear php5-xmlrpc php5-xsl php5-mysql
-                      php-soap php5-gd php5-ldap php5-pgsql php5-intl)
-      when 'xenial'
-        os_packages = %w(g++ mailutils php5.5 php5.5-cli php5.5-fpm build-essential
-                      libgd2-xpm-dev libjpeg62 libpng12-0
-                      libpng12-dev libapache2-mod-php5.5 imagemagick
-                      php5.5-imagick php-pear php5.5-xmlrpc php5.5-xsl php5.5-mysql
-                      php-soap php5.5-gd php5.5-ldap php5.5-pgsql php5.5-intl)
-    end
+when 'debian'
+  case node['lsb']['codename']
+  when 'trusty'
+    # package libjpeg62-dev conflicts with libgd2-xpm-dev
+    # perhaps can be removed.
+    os_packages = %w(g++ mailutils php5 php5-cli php5-fpm build-essential
+                     libgd2-xpm-dev libjpeg62 libpng12-0
+                     libpng12-dev libapache2-mod-php5 imagemagick
+                     php5-imagick php-pear php5-xmlrpc php5-xsl php5-mysql
+                     php-soap php5-gd php5-ldap php5-pgsql php5-intl)
+  when 'xenial'
+    os_packages = %w(g++ mailutils php5.5 php5.5-cli php5.5-fpm build-essential
+                     libgd2-xpm-dev libjpeg62 libpng12-0
+                     libpng12-dev libapache2-mod-php5.5 imagemagick
+                     php5.5-imagick php-pear php5.5-xmlrpc php5.5-xsl php5.5-mysql
+                     php-soap php5.5-gd php5.5-ldap php5.5-pgsql php5.5-intl)
+  end
 
-    apt_repository 'ondrej-php' do
-      uri 'ppa:ondrej/php'
-      distribution node['lsb']['codename']
-      only_if { node['lsb']['codename'] == 'xenial' } # That's Ubuntu 16
-    end
-    include_recipe 'apt'
-    os_packages.push('git-core') if node['icinga2']['web2']['install_method'] == 'source' && node['icinga2']['web2']['enable'] == true
-  when 'rhel'
-    os_packages = %w(gcc gcc-c++ glibc glibc-common mailx php php-devel gd
+  apt_repository 'ondrej-php' do
+    uri 'ppa:ondrej/php'
+    distribution node['lsb']['codename']
+    only_if { node['lsb']['codename'] == 'xenial' } # That's Ubuntu 16
+  end
+  include_recipe 'apt'
+  os_packages.push('git-core') if node['icinga2']['web2']['install_method'] == 'source' && node['icinga2']['web2']['enable'] == true
+when 'rhel'
+  os_packages = %w(gcc gcc-c++ glibc glibc-common mailx php php-devel gd
                    gd-devel libjpeg libjpeg-devel libpng libpng-devel php-gd
                    php-fpm php-cli php-pear php-xmlrpc php-xsl php-pdo
                    php-soap php-ldap php-mysql php-pgsql php-intl git php-pecl-imagick)
-    # yum epel repository is required for php-pecl-imagick
-    include_recipe 'yum-epel' if node['platform'] != 'amazon' && node['icinga2']['setup_epel']
-    os_packages.push('git') if node['icinga2']['web2']['install_method'] == 'source' && node['icinga2']['web2']['enable'] == true
+  # yum epel repository is required for php-pecl-imagick
+  include_recipe 'yum-epel' if node['platform'] != 'amazon' && node['icinga2']['setup_epel']
+  os_packages.push('git') if node['icinga2']['web2']['install_method'] == 'source' && node['icinga2']['web2']['enable'] == true
 end
 
 # dependencies
diff --git a/recipes/server_web2.rb b/recipes/server_web2.rb
index d594f88..7d43f40 100644
--- a/recipes/server_web2.rb
+++ b/recipes/server_web2.rb
@@ -49,13 +49,13 @@ file ::File.join(node['icinga2']['web2']['conf_dir'], 'setup.token') do
 end
 
 # set php time zone
-if node['platform_family'] == 'rhel'
-  php_ini = '/etc/php.ini'
-elsif node['lsb']['codename'] == 'xenial'
-  php_ini = '/etc/php/5.5/apache2/php.ini'
-else
-  php_ini = '/etc/php5/apache2/php.ini'
-end
+php_ini = if node['platform_family'] == 'rhel'
+            '/etc/php.ini'
+          elsif node['lsb']['codename'] == 'xenial'
+            '/etc/php/5.5/apache2/php.ini'
+          else
+            '/etc/php5/apache2/php.ini'
+          end
 
 ruby_block 'set php timezone' do
   block do



More information about the icinga-checkins mailing list