From 5ce5e04f518fcb7251b4c62401408cbcc80f18f3 Mon Sep 17 00:00:00 2001 From: Craig Bryant Date: Wed, 16 Jul 2014 16:25:01 -0600 Subject: [PATCH] Get initial build to work. Add .gitreview, Gemfile, .rubocop.yml, Berksfile, Strainerfile Fixed style errors. Added empty unit test so chef-unit passes until we get real unit tests Change-Id: I75a9449a28cfc294eacbdc0003a8b7de2613290e --- .gitreview | 4 ++++ .rubocop.yml | 24 ++++++++++++++++++++++++ Berksfile | 1 + Gemfile | 11 +++++++++++ Strainerfile | 5 +++++ attributes/backup.rb | 4 +++- attributes/default.rb | 2 ++ attributes/monitor.rb | 1 + metadata.rb | 2 ++ recipes/default.rb | 10 ++++++---- spec/empty.rb | 2 ++ 11 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 .gitreview create mode 100644 .rubocop.yml create mode 100644 Berksfile create mode 100644 Gemfile create mode 100644 Strainerfile create mode 100644 spec/empty.rb diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..b38d733 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/cookbook-monasca-notification diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..5500e6d --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,24 @@ +AllCops: + Includes: + - metadata.rb + - Gemfile + - attributes/** + - libraries/** + - providers/** + - recipes/** + - resources/** + - spec/** + +Encoding: + Exclude: + - metadata.rb + - Gemfile + +NumericLiterals: + Enabled: false + +LineLength: + Enabled: false + +WordArray: + MinSize: 3 diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..850a120 --- /dev/null +++ b/Berksfile @@ -0,0 +1 @@ +metadata diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..eeb359d --- /dev/null +++ b/Gemfile @@ -0,0 +1,11 @@ +source 'https://rubygems.org' + +gem 'chef', '~> 11.8' +gem 'json', '<= 1.7.7' # chef 11 dependency +gem 'berkshelf', '~> 2.0.18' +gem 'hashie', '~> 2.0' +gem 'chefspec', '~> 3.4.0' +gem 'rspec', '~> 2.14.1' +gem 'foodcritic', '~> 3.0.3' +gem 'strainer' +gem 'rubocop', '~> 0.18.1' diff --git a/Strainerfile b/Strainerfile new file mode 100644 index 0000000..cf2ff52 --- /dev/null +++ b/Strainerfile @@ -0,0 +1,5 @@ +# Strainerfile +rubocop: rubocop $SANDBOX/$COOKBOOK +knife test: knife cookbook test $COOKBOOK +foodcritic: foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK +chefspec: rspec $SANDBOX/$COOKBOOK/spec diff --git a/attributes/backup.rb b/attributes/backup.rb index 6373e8a..a0321a2 100644 --- a/attributes/backup.rb +++ b/attributes/backup.rb @@ -1,2 +1,4 @@ +# encoding: UTF-8 # Logs to backup -node.default[:mon_log_backup][:logs][:mon_notification] = [ '/var/log/mon-notification/notification.log' ] +node.default[:mon_log_backup][:logs][:mon_notification] = + ['/var/log/mon-notification/notification.log'] diff --git a/attributes/default.rb b/attributes/default.rb index 1a8b081..a563421 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 +# default[:mon_notification][:user] = 'mon-notification' default[:mon_notification][:group] = 'mon-notification' default[:mon_notification][:conf_dir] = '/etc/mon' diff --git a/attributes/monitor.rb b/attributes/monitor.rb index 558eddf..3f401ec 100644 --- a/attributes/monitor.rb +++ b/attributes/monitor.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # Have ossec watch the log node.default[:ossec][:watched][:mon_notification] = { '/var/log/mon-notification/notification.log' => :syslog diff --git a/metadata.rb b/metadata.rb index 9ef3072..0b376ef 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 +# name 'mon_notification' maintainer 'HP Monitoring' maintainer_email 'hpcs-mon@hp.com' diff --git a/recipes/default.rb b/recipes/default.rb index 83780f9..3de8501 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,4 +1,6 @@ -include_recipe "python" +# encoding: UTF-8 +# +include_recipe 'python' # preferable for the OS to install this then to have pip compile %w[ python-mysqldb libmysqlclient-dev ].each do |pkg_name| @@ -47,7 +49,7 @@ directory node[:mon_notification][:log_dir] do mode 0775 end -# todo - setup an encrypted data bag for credentials +# TODO: setup an encrypted data bag for credentials hosts = data_bag_item(node[:mon_notification][:data_bag], 'hosts') template "#{node[:mon_notification][:conf_dir]}/notification.yaml" do action :create @@ -56,7 +58,7 @@ template "#{node[:mon_notification][:conf_dir]}/notification.yaml" do group node[:mon_notification][:group] mode 0640 variables( - :hosts => hosts + hosts: hosts ) - notifies :restart, "service[mon-notification]" + notifies :restart, 'service[mon-notification]' end diff --git a/spec/empty.rb b/spec/empty.rb new file mode 100644 index 0000000..fc2f6d6 --- /dev/null +++ b/spec/empty.rb @@ -0,0 +1,2 @@ +# encoding: UTF-8 +# No unit tests at this time.