Update recipes to be rubocop compliant

- Add rubocop.yml in recipes/
- Add recipes rubocop tests in Strainerfile
- Update recipes to comply with rubocop

Change-Id: I258b2ed24a6b2f1221ec8b5e188bd4567bc63f99
Addresses: blueprint rubocop-for-ops-messaging
This commit is contained in:
Andy McCrae
2014-01-17 11:32:13 +00:00
parent 34a0660afd
commit 6d04e3e704
4 changed files with 37 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
# Strainerfile # Strainerfile
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile $SANDBOX/$COOKBOOK/metadata.rb --config $SANDBOX/$COOKBOOK/.rubocop.yml rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile $SANDBOX/$COOKBOOK/metadata.rb --config $SANDBOX/$COOKBOOK/.rubocop.yml
# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK # rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/recipes/ --config $SANDBOX/$COOKBOOK/recipes/.rubocop.yml
knife test: bundle exec knife cookbook test $COOKBOOK knife test: bundle exec knife cookbook test $COOKBOOK
foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK
chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec

3
recipes/.rubocop.yml Normal file
View File

@@ -0,0 +1,3 @@
# embedded attributes make for long lines
LineLength:
Enabled: false

View File

@@ -1,3 +1,4 @@
# encoding: UTF-8
# #
# Cookbook Name:: openstack-ops-messaging # Cookbook Name:: openstack-ops-messaging
# Recipe:: rabbitmq-server # Recipe:: rabbitmq-server
@@ -6,14 +7,14 @@
# Copyright 2013, AT&T Services, Inc. # Copyright 2013, AT&T Services, Inc.
# Copyright 2013, Craig Tracey <craigtracey@gmail.com> # Copyright 2013, Craig Tracey <craigtracey@gmail.com>
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
@@ -23,63 +24,61 @@ class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
rabbit_server_role = node["openstack"]["mq"]["server_role"] user = node['openstack']['mq']['user']
user = node["openstack"]["mq"]["user"] pass = get_password 'user', user
pass = get_password "user", user vhost = node['openstack']['mq']['vhost']
vhost = node["openstack"]["mq"]["vhost"] listen_address = address_for node['openstack']['mq']['bind_interface']
bind_interface = node["openstack"]["mq"]["bind_interface"]
listen_address = address_for node["openstack"]["mq"]["bind_interface"]
# Used by OpenStack#rabbit_servers/#rabbit_server # Used by OpenStack#rabbit_servers/#rabbit_server
node.set["openstack"]["mq"]["listen"] = listen_address node.set['openstack']['mq']['listen'] = listen_address
node.override["rabbitmq"]["port"] = node["openstack"]["mq"]["port"] node.override['rabbitmq']['port'] = node['openstack']['mq']['port']
node.override["rabbitmq"]["address"] = listen_address node.override['rabbitmq']['address'] = listen_address
node.override["rabbitmq"]["default_user"] = user node.override['rabbitmq']['default_user'] = user
node.override["rabbitmq"]["default_pass"] = pass node.override['rabbitmq']['default_pass'] = pass
node.override["rabbitmq"]["use_distro_version"] = true node.override['rabbitmq']['use_distro_version'] = true
# Clustering # Clustering
if node["openstack"]["mq"]["cluster"] if node['openstack']['mq']['cluster']
node.override["rabbitmq"]["cluster"] = node["openstack"]["mq"]["cluster"] node.override['rabbitmq']['cluster'] = node['openstack']['mq']['cluster']
node.override["rabbitmq"]["erlang_cookie"] = get_password "service", "rabbit_cookie" node.override['rabbitmq']['erlang_cookie'] = get_password 'service', 'rabbit_cookie'
qs = "roles:#{rabbit_server_role} AND chef_environment:#{node.chef_environment}" qs = "roles:#{node['openstack']['mq']['server_role']} AND chef_environment:#{node.chef_environment}"
node.override["rabbitmq"]["cluster_disk_nodes"] = search(:node, qs).map do |n| node.override['rabbitmq']['cluster_disk_nodes'] = search(:node, qs).map do |n|
"#{user}@#{n['hostname']}" "#{user}@#{n['hostname']}"
end.sort end.sort
end end
include_recipe "rabbitmq" include_recipe 'rabbitmq'
include_recipe "rabbitmq::mgmt_console" include_recipe 'rabbitmq::mgmt_console'
rabbitmq_user "remove rabbit guest user" do rabbitmq_user 'remove rabbit guest user' do
user "guest" user 'guest'
action :delete action :delete
not_if { user == "guest" } not_if { user == 'guest' }
end end
rabbitmq_user "add openstack rabbit user" do rabbitmq_user 'add openstack rabbit user' do
user user user user
password pass password pass
action :add action :add
end end
rabbitmq_user "change openstack rabbit user password" do rabbitmq_user 'change openstack rabbit user password' do
user user user user
password pass password pass
action :change_password action :change_password
end end
rabbitmq_vhost "add openstack rabbit vhost" do rabbitmq_vhost 'add openstack rabbit vhost' do
vhost vhost vhost vhost
action :add action :add
end end
rabbitmq_user "set openstack user permissions" do rabbitmq_user 'set openstack user permissions' do
user user user user
vhost vhost vhost vhost
permissions '.* .* .*' permissions '.* .* .*'
@@ -87,9 +86,9 @@ rabbitmq_user "set openstack user permissions" do
end end
# Necessary for graphing. # Necessary for graphing.
rabbitmq_user "set rabbit administrator tag" do rabbitmq_user 'set rabbit administrator tag' do
user user user user
tag "administrator" tag 'administrator'
action :set_tags action :set_tags
end end

View File

@@ -1,3 +1,4 @@
# encoding: UTF-8
# #
# Cookbook Name:: openstack-ops-messaging # Cookbook Name:: openstack-ops-messaging
# Recipe:: server # Recipe:: server
@@ -6,17 +7,17 @@
# Copyright 2013, Craig Tracey <craigtracey@gmail.com> # Copyright 2013, Craig Tracey <craigtracey@gmail.com>
# Copyright 2013, AT&T Services, Inc. # Copyright 2013, AT&T Services, Inc.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
include_recipe "openstack-ops-messaging::#{node["openstack"]["mq"]["service_type"]}-server" include_recipe "openstack-ops-messaging::#{node['openstack']['mq']['service_type']}-server"