Skip to content

Commit

Permalink
Merge branch 'rubocop' of https://github.com/guilhem/ceph-cookbook in…
Browse files Browse the repository at this point in the history
…to guilhem-rubocop

Conflicts:
	recipes/apt.rb
  • Loading branch information
guilhem committed Mar 14, 2014
2 parents bb30a9f + afb859a commit 5040229
Show file tree
Hide file tree
Showing 39 changed files with 343 additions and 308 deletions.
20 changes: 16 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
AllCops:
Includes:
- Berksfile
- Gemfile
- Rakefile
- Thorfile
- Guardfile
Excludes:
- vendor/**

AlignParameters:
ClassLength:
Enabled: false
Documentation:
Enabled: false
Encoding:
Enabled: false
HashSyntax:
Enabled: false
StringLiterals:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Max: 30
Enabled: false
SignalException:
Enabled: false
TrailingComma:
Enabled: false
WordArray:
Enabled: false
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
before_script:
- bundle exec berks install
bundler_args: --without integration
script:
- bundle exec strainer test --except kitchen
- bundle exec rake travis
16 changes: 7 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gem "chef", "~> 11"
gem "berkshelf", "~> 2.0.10"
gem 'chef', '~> 11'
gem 'berkshelf', '~> 2.0.10'

group :test do
gem "chefspec", "~> 3.0.2"
gem "foodcritic", "~> 3.0.3"
gem "strainer"
gem "rubocop"
gem 'foodcritic', '~> 3.0'
gem 'rubocop'
end

group :integration do
gem "test-kitchen", "~> 1.1.1"
gem "kitchen-vagrant", "~> 0.14"
gem 'test-kitchen', '~> 1.1.1'
gem 'kitchen-vagrant', '~> 0.14'
end
47 changes: 47 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env rake

# Style tests. Rubocop and Foodcritic
namespace :style do
begin
require 'rubocop/rake_task'
desc 'Run Ruby style checks'
Rubocop::RakeTask.new(:ruby)
rescue LoadError
puts '>>>>> Rubocop gem not loaded, omitting tasks' unless ENV['CI']
end

begin
require 'foodcritic'

desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any'],
tags: ['~FC003']
}
end
rescue LoadError
puts '>>>>> foodcritic gem not loaded, omitting tasks' unless ENV['CI']
end
end

desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']

# Integration tests. Kitchen.ci
namespace :integration do
begin
require 'kitchen/rake_tasks'

desc 'Run kitchen integration tests'
Kitchen::RakeTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
end

desc 'Run all tests on Travis'
task travis: ['style']

# Default
task default: ['style', 'integration:kitchen:all']
5 changes: 0 additions & 5 deletions Strainerfile

This file was deleted.

2 changes: 1 addition & 1 deletion attributes/cephfs.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default["ceph"]["cephfs_mount"] = "/ceph"
default['ceph']['cephfs_mount'] = '/ceph'
4 changes: 2 additions & 2 deletions attributes/conf.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
default["ceph"]["config"] = {}
default["ceph"]["config-sections"] = {}
default['ceph']['config'] = {}
default['ceph']['config-sections'] = {}
4 changes: 2 additions & 2 deletions attributes/mds.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
case node['platform']
when 'ubuntu'
default["ceph"]["mds"]["init_style"] = "upstart"
default['ceph']['mds']['init_style'] = 'upstart'
else
default["ceph"]["mds"]["init_style"] = "sysvinit"
default['ceph']['mds']['init_style'] = 'sysvinit'
end
6 changes: 3 additions & 3 deletions attributes/mon.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
case node['platform']
when 'ubuntu'
default["ceph"]["mon"]["init_style"] = "upstart"
default['ceph']['mon']['init_style'] = 'upstart'
else
default["ceph"]["mon"]["init_style"] = "sysvinit"
default['ceph']['mon']['init_style'] = 'sysvinit'
end
default["ceph"]["mon"]["secret_file"] = "/etc/chef/secrets/ceph_mon"
default['ceph']['mon']['secret_file'] = '/etc/chef/secrets/ceph_mon'
6 changes: 3 additions & 3 deletions attributes/osd.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
case node['platform']
when 'ubuntu'
default["ceph"]["osd"]["init_style"] = "upstart"
default['ceph']['osd']['init_style'] = 'upstart'
else
default["ceph"]["osd"]["init_style"] = "sysvinit"
default['ceph']['osd']['init_style'] = 'sysvinit'
end
default["ceph"]["osd"]["secret_file"] = "/etc/chef/secrets/ceph_osd"
default['ceph']['osd']['secret_file'] = '/etc/chef/secrets/ceph_osd'
16 changes: 8 additions & 8 deletions attributes/radosgw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
# limitations under the License.
#

default["ceph"]["radosgw"]["api_fqdn"] = "localhost"
default["ceph"]["radosgw"]["admin_email"] = "[email protected]"
default["ceph"]["radosgw"]["rgw_addr"] = "*:80"
default["ceph"]["radosgw"]["rgw_port"] = false
default["ceph"]["radosgw"]["webserver_companion"] = "apache2" # can be false
default['ceph']["radosgw"]['use_apache_fork'] = true
default['ceph']['radosgw']['api_fqdn'] = 'localhost'
default['ceph']['radosgw']['admin_email'] = '[email protected]'
default['ceph']['radosgw']['rgw_addr'] = '*:80'
default['ceph']['radosgw']['rgw_port'] = false
default['ceph']['radosgw']['webserver_companion'] = 'apache2' # can be false
default['ceph']['radosgw']['use_apache_fork'] = true
case node['platform']
when 'ubuntu'
default["ceph"]["radosgw"]["init_style"] = "upstart"
default['ceph']['radosgw']['init_style'] = 'upstart'
else
default["ceph"]["radosgw"]["init_style"] = "sysvinit"
default['ceph']['radosgw']['init_style'] = 'sysvinit'
end
34 changes: 17 additions & 17 deletions attributes/repo.rb
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
default['ceph']['branch'] = "stable" # Can be stable, testing or dev.
default['ceph']['branch'] = 'stable' # Can be stable, testing or dev.
# Major release version to install or gitbuilder branch
default['ceph']['version'] = "dumpling"
default['ceph']['version'] = 'dumpling'
default['ceph']['el_add_epel'] = true
default['ceph']['repo_url'] = "http://ceph.com"
default['ceph']['extras_repo_url'] = "http://ceph.com/packages/ceph-extras"
default['ceph']['repo_url'] = 'http://ceph.com'
default['ceph']['extras_repo_url'] = 'http://ceph.com/packages/ceph-extras'
default['ceph']['extras_repo'] = false

case node['platform_family']
when "debian"
when 'debian'
# Debian/Ubuntu default repositories
default['ceph']['debian']['stable']['repository'] = "#{node['ceph']['repo_url']}/debian-#{node['ceph']['version']}/"
default['ceph']['debian']['stable']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc"
default['ceph']['debian']['stable']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc'
default['ceph']['debian']['testing']['repository'] = "#{node['ceph']['repo_url']}/debian-testing/"
default['ceph']['debian']['testing']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc"
default['ceph']['debian']['testing']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc'
default['ceph']['debian']['dev']['repository'] = "http://gitbuilder.ceph.com/ceph-deb-#{node['lsb']['codename']}-x86_64-basic/ref/#{node['ceph']['version']}"
default['ceph']['debian']['dev']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
default['ceph']['debian']['dev']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc'
default['ceph']['debian']['extras']['repository'] = "#{node['ceph']['extras_repo_url']}/debian/"
default['ceph']['debian']['extras']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc"
when "rhel"
default['ceph']['debian']['extras']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc'
when 'rhel'
# Redhat/CentOS default repositories
default['ceph']['rhel']['stable']['repository'] = "#{node['ceph']['repo_url']}/rpm-#{node['ceph']['version']}/el6/noarch/ceph-release-1-0.el6.noarch.rpm"
default['ceph']['rhel']['testing']['repository'] = "#{node['ceph']['repo_url']}/rpm-testing/el6/x86_64/ceph-release-1-0.el6.noarch.rpm"
default['ceph']['rhel']['dev']['repository'] = "http://gitbuilder.ceph.com/ceph-rpm-centos6-x86_64-basic/ref/#{node['ceph']['version']}/x86_64/"
default['ceph']['rhel']['dev']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
default['ceph']['rhel']['dev']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc'
default['ceph']['rhel']['extras']['repository'] = "#{node['ceph']['extras_repo_url']}/rpm/rhel6/x86_64/"
default['ceph']['rhel']['extras']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
when "fedora"
default['ceph']['rhel']['extras']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc'
when 'fedora'
# Fedora default repositories
default['ceph']['fedora']['stable']['repository'] = "#{node['ceph']['repo_url']}/rpm-#{node['ceph']['version']}/fc#{node['platform_version']}/x86_64/ceph-release-1-0.fc#{node['platform_version']}.noarch.rpm"
default['ceph']['fedora']['testing']['repository'] = "#{node['ceph']['repo_url']}/rpm-testing/fc#{node['platform_version']}/x86_64/ceph-release-1-0.fc#{node['platform_version']}.noarch.rpm"
default['ceph']['fedora']['dev']['repository'] = "http://gitbuilder.ceph.com/ceph-rpm-fc#{node['platform_version']}-x86_64-basic/ref/#{node['ceph']['version']}/RPMS/x86_64/"
default['ceph']['fedora']['dev']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
default['ceph']['fedora']['dev']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc'
default['ceph']['fedora']['extras']['repository'] = "#{node['ceph']['extras_repo_url']}/rpm/fedora#{node['platform_version']}/x86_64/"
default['ceph']['fedora']['extras']['repository_key'] = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc"
when "suse"
default['ceph']['fedora']['extras']['repository_key'] = 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/autobuild.asc'
when 'suse'
# (Open)SuSE default repositories
# Chef doesn't make a difference between suse and opensuse
suse = Mixlib::ShellOut.new("head -n1 /etc/SuSE-release| awk '{print $1}'").run_command.stdout.chomp.downcase
suse = "sles" if suse == "suse"
suse = 'sles' if suse == 'suse'
suse_version = suse << Mixlib::ShellOut.new("grep VERSION /etc/SuSE-release | awk -F'= ' '{print $2}'").run_command.stdout.chomp

default['ceph']['suse']['stable']['repository'] = "#{node['ceph']['repo_url']}/rpm-#{node['ceph']['version']}/#{suse_version}/x86_64/ceph-release-1-0.#{suse_version}.noarch.rpm"
Expand Down
6 changes: 6 additions & 0 deletions infrastructure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
roles:
- ceph-mds:
- ceph-mon:
- ceph-osd:
- ceph-radosgw:
- ceph-tgt:
16 changes: 8 additions & 8 deletions libraries/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def get_mon_nodes(extra_search = nil)
if crowbar?
mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]')
unless mon_roles.empty?
search_string = mon_roles.map { |role_object| "roles:" + role_object.name }.join(' OR ')
search_string = mon_roles.map { |role_object| 'roles:' + role_object.name }.join(' OR ')
search_string = "(#{search_string}) AND ceph_config_environment:#{node['ceph']['config']['environment']}"
end
else
Expand All @@ -31,11 +31,11 @@ def get_mon_nodes(extra_search = nil)
def find_node_ip_in_network(network, nodeish = nil)
nodeish = node unless nodeish
net = IPAddr.new(network)
nodeish["network"]["interfaces"].each do |iface, addrs|
addrs["addresses"].each do |ip, params|
if params['family'].eql?("inet6") && net.include?(ip)
nodeish['network']['interfaces'].each do |iface, addrs|
addrs['addresses'].each do |ip, params|
if params['family'].eql?('inet6') && net.include?(ip)
return "[#{ip}]:6789"
elsif params['family'].eql?("inet") && net.include?(ip)
elsif params['family'].eql?('inet') && net.include?(ip)
return "#{ip}:6789"
end
end
Expand All @@ -46,7 +46,7 @@ def find_node_ip_in_network(network, nodeish = nil)
def mon_addresses
mon_ips = []

if File.exists?("/var/run/ceph/ceph-mon.#{node['hostname']}.asok")
if File.exist?("/var/run/ceph/ceph-mon.#{node['hostname']}.asok")
mon_ips = quorum_members_ips
else
mons = []
Expand All @@ -57,12 +57,12 @@ def mon_addresses

mons += get_mon_nodes
if crowbar?
mon_ips = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address }
mon_ips = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, 'admin').address }
else
if node['ceph']['config']['global'] && node['ceph']['config']['global']['public network']
mon_ips = mons.map { |nodeish| find_node_ip_in_network(node['ceph']['config']['global']['public network'], nodeish) }
else
mon_ips = mons.map { |node| node['ipaddress'] + ":6789" }
mon_ips = mons.map { |node| node['ipaddress'] + ':6789' }
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name "ceph"
maintainer "Kyle Bader"
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs/Configures the Ceph distributed filesystem"
name 'ceph'
maintainer 'Kyle Bader'
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Installs/Configures the Ceph distributed filesystem'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.2.1"
version '0.2.1'

depends "apache2", ">= 1.1.12"
depends "apt"
depends "yum", ">= 3.0"
depends "yum-epel"
depends 'apache2', '>= 1.1.12'
depends 'apt'
depends 'yum', '>= 3.0'
depends 'yum-epel'
18 changes: 9 additions & 9 deletions providers/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def whyrun_supported?

file filename do
content file_content
owner "root"
group "root"
mode "640"
owner 'root'
group 'root'
mode '640'
end
end

Expand Down Expand Up @@ -53,21 +53,21 @@ def get_caps(keyname)

def auth_set_key(keyname, caps)
# find the monitor secret
mon_secret = ""
mon_secret = ''
mons = get_mon_nodes
if !mons.empty?
mon_secret = mons[0]["ceph"]["monitor-secret"]
elsif mons.empty? && node["ceph"]["monitor-secret"]
mon_secret = node["ceph"]["monitor-secret"]
mon_secret = mons[0]['ceph']['monitor-secret']
elsif mons.empty? && node['ceph']['monitor-secret']
mon_secret = node['ceph']['monitor-secret']
else
Chef::Log.warn("No monitor secret found")
Chef::Log.warn('No monitor secret found')
end
# try to add the key
cmd = "ceph auth get-or-create #{keyname} #{caps} --name mon. --key='#{mon_secret}'"
get_or_create = Mixlib::ShellOut.new(cmd)
get_or_create.run_command
if get_or_create.stderr.scan(/EINVAL.*but cap.*does not match/)
Chef::Log.info("Deleting old key with incorrect caps")
Chef::Log.info('Deleting old key with incorrect caps')
# delete an old key if it exists and is wrong
Mixlib::ShellOut.new("ceph auth del #{keyname}").run_command
# try to create again
Expand Down
Loading

0 comments on commit 5040229

Please sign in to comment.