Skip to content
This repository was archived by the owner on May 20, 2020. It is now read-only.

Fix Rubocop offenses #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
AllCops:
DisplayCopNames: true
Exclude:
- 'Berksfile'
- 'Thorfile'
- 'Vagrantfile'
- 'Gemfile'
- 'metadata.rb'

AlignParameters:
Lint/LiteralInCondition:
Enabled: false

Encoding:
Lint/ParenthesesAsGroupedExpression:
Enabled: false

LineLength:
Max: 200
Metrics/LineLength:
Enabled: false

HashSyntax:
EnforcedStyle: hash_rockets
Metrics/MethodLength:
Max: 18

AsciiComments:
Style/AlignParameters:
Enabled: false

MethodLength:
Max: 18
Style/AsciiComments:
Enabled: false

Style/ConditionalAssignment:
Enabled: false

Style/Documentation:
Enabled: false

Style/EachWithObject:
Enabled: false

Style/Encoding:
Enabled: false

Style/FileName:
Enabled: false

Style/HashSyntax:
EnforcedStyle: hash_rockets

Style/NumericLiterals:
Enabled: false

Style/SpaceInsideBrackets:
Enabled: false

Style/RedundantParentheses:
Enabled: false

Style/WordArray:
Enabled: false
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "https://supermarket.chef.io"
source 'https://supermarket.chef.io'

metadata

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'

gem 'berkshelf', '~> 4.0.1'
gem 'test-kitchen', '~> 1.4.0'
gem 'foodcritic', '4.0.0'
gem 'test-kitchen', '~> 1.4.0'

group :integration do
gem 'kitchen-vagrant', '~> 0.18.0'
Expand Down
4 changes: 2 additions & 2 deletions Thorfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ require 'bundler/setup'
require 'berkshelf/thor'

begin
require "kitchen/thor_tasks"
require 'kitchen/thor_tasks'
Kitchen::ThorTasks.new
rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
5 changes: 2 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'
VAGRANTFILE_API_VERSION = '2'.freeze

Vagrant.require_version '>= 1.5.0'

Expand All @@ -18,7 +18,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#
# $ vagrant plugin install vagrant-omnibus
#
if Vagrant.has_plugin?("vagrant-omnibus")
if Vagrant.has_plugin?('vagrant-omnibus')
config.omnibus.chef_version = 'latest'
end

Expand All @@ -27,7 +27,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# config.vm.box_url doesn't need to be specified.
config.vm.box = 'chef/ubuntu-14.04'


# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
Expand Down
38 changes: 19 additions & 19 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@
default['mongodb3']['package']['repo']['url'] = nil

# MongoDB repository info for apt
default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2
default['mongodb3']['package']['repo']['apt']['name'] = nil # eg. 3.0, 3.2
default['mongodb3']['package']['repo']['apt']['keyserver'] = nil # eg. hkp://keyserver.ubuntu.com:80
default['mongodb3']['package']['repo']['apt']['key'] = nil # eg. 3.2 : 'EA312927', 3.0 : '7F0CEB10'
default['mongodb3']['package']['repo']['apt']['components'] = nil # eg. ['multiverse']

# Default attribute for MongoDB installation
case node['platform_family']
when 'rhel', 'fedora'
mongo_user = 'mongod'
mongo_group = 'mongod'
mongo_dbpath = '/var/lib/mongo'
# To guarantee the compatibility for centos 6 in previous version of mongodb3 cookbook
if node['platform_version'].to_i >= 7
mongo_pid_file = '/var/run/mongodb/mongod.pid'
else
mongo_pid_file = '/var/run/mongodb/mongodb.pid'
end
config_processManagement_fork = true
when 'debian'
mongo_user = 'mongodb'
mongo_group = 'mongodb'
mongo_dbpath = '/var/lib/mongodb'
mongo_pid_file = nil
config_processManagement_fork = nil
when 'rhel', 'fedora'
mongo_user = 'mongod'
mongo_group = 'mongod'
mongo_dbpath = '/var/lib/mongo'
# To guarantee the compatibility for centos 6 in previous version of mongodb3 cookbook
if node['platform_version'].to_i >= 7
mongo_pid_file = '/var/run/mongodb/mongod.pid'
else
mongo_pid_file = '/var/run/mongodb/mongodb.pid'
end
config_process_management_fork = true
when 'debian'
mongo_user = 'mongodb'
mongo_group = 'mongodb'
mongo_dbpath = '/var/lib/mongodb'
mongo_pid_file = nil
config_process_management_fork = nil
end

# MongoDB user:group
Expand Down Expand Up @@ -113,7 +113,7 @@

# processManagement Options : http://docs.mongodb.org/manual/reference/configuration-options/#processmanagement-options

default['mongodb3']['config']['mongod']['processManagement']['fork'] = config_processManagement_fork # default : false
default['mongodb3']['config']['mongod']['processManagement']['fork'] = config_process_management_fork # default : false
default['mongodb3']['config']['mongod']['processManagement']['pidFilePath'] = mongo_pid_file

# net Options : http://docs.mongodb.org/manual/reference/configuration-options/#net-options
Expand Down
72 changes: 33 additions & 39 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
package pkg do
version node['mongodb3']['package']['version']
case node['platform_family']
when 'debian'
# bypass dpkg errors about pre-existing init or conf file
options '-o Dpkg::Options::="--force-confold" --force-yes'
when 'debian'
# bypass dpkg errors about pre-existing init or conf file
options '-o Dpkg::Options::="--force-confold" --force-yes'
end
action :install
end
Expand Down Expand Up @@ -75,9 +75,9 @@
# Update the mongodb config file
template node['mongodb3']['mongod']['config_file'] do
source 'mongodb.conf.erb'
mode 0644
mode '0644'
variables(
:config => node['mongodb3']['config']['mongod']
:config => node['mongodb3']['config']['mongod']
)
helpers Mongodb3Helper
end
Expand All @@ -90,59 +90,53 @@
group 'root'
mode '0755'
action :create
only_if {
node['mongodb3']['mongod']['disable-transparent-hugepages']
}
only_if { node['mongodb3']['mongod']['disable-transparent-hugepages'] }
end

case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
cookbook_file '/lib/systemd/system/disable-transparent-hugepages.service' do
source 'disable-transparent-hugepages.service'
owner 'root'
group 'root'
mode '0655'
action :create
only_if {
node['mongodb3']['mongod']['disable-transparent-hugepages']
}
end
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
cookbook_file '/lib/systemd/system/disable-transparent-hugepages.service' do
source 'disable-transparent-hugepages.service'
owner 'root'
group 'root'
mode '0655'
action :create
only_if { node['mongodb3']['mongod']['disable-transparent-hugepages'] }
end
end
end

service 'disable-transparent-hugepages' do
case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
provider Chef::Provider::Service::Systemd
end
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
provider Chef::Provider::Service::Systemd
end
end
action [ :enable, :start ]
only_if {
node['mongodb3']['mongod']['disable-transparent-hugepages']
}
only_if { node['mongodb3']['mongod']['disable-transparent-hugepages'] }
end

# Create the mongod.service file
case node['platform']
when 'ubuntu'
template '/lib/systemd/system/mongod.service' do
source 'mongod.service.erb'
mode 0644
only_if { node['platform_version'].to_f >= 15.04 }
end
when 'ubuntu'
template '/lib/systemd/system/mongod.service' do
source 'mongod.service.erb'
mode '0644'
only_if { node['platform_version'].to_f >= 15.04 }
end
end

# Start the mongod service
service 'mongod' do
case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
provider Chef::Provider::Service::Systemd
elsif node['platform_version'].to_f >= 14.04
provider Chef::Provider::Service::Upstart
end
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
provider Chef::Provider::Service::Systemd
elsif node['platform_version'].to_f >= 14.04
provider Chef::Provider::Service::Upstart
end
end
supports :start => true, :stop => true, :restart => true, :status => true
action :enable
Expand Down
46 changes: 23 additions & 23 deletions recipes/mms_automation_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

# Set variables by platform
case node['platform_family']
when 'rhel', 'fedora'
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
mms_agent_file = '/root/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
when 'debian'
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
else
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.deb'
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.deb'
end
when 'rhel', 'fedora'
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
mms_agent_file = '/root/mongodb-mms-automation-agent-manager-latest.x86_64.rpm'
when 'debian'
if node['platform'] == 'ubuntu' && node['platform_version'].to_f >= 15.04
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.ubuntu1604.deb'
else
mms_agent_source = 'https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager_latest_amd64.deb'
mms_agent_file = '/root/mongodb-mms-automation-agent-manager_latest_amd64.deb'
end
end

# Download the mms automation agent manager latest
Expand All @@ -48,26 +48,26 @@

# Install package
case node['platform_family']
when 'rhel', 'fedora'
rpm_package 'mongodb-mms-automation-agent-manager' do
source mms_agent_file
action :install
end
when 'debian'
dpkg_package 'mongodb-mms-automation-agent-manager' do
source mms_agent_file
action :install
end
when 'rhel', 'fedora'
rpm_package 'mongodb-mms-automation-agent-manager' do
source mms_agent_file
action :install
end
when 'debian'
dpkg_package 'mongodb-mms-automation-agent-manager' do
source mms_agent_file
action :install
end
end

# Create or modify the mms agent config file
template '/etc/mongodb-mms/automation-agent.config' do
source 'automation-agent.config.erb'
mode 0600
mode '0600'
owner node['mongodb3']['user']
group node['mongodb3']['group']
variables(
:config => node['mongodb3']['config']['mms']
:config => node['mongodb3']['config']['mms']
)
end

Expand Down
Loading