-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add various bits of setup automation #61
Closed
Closed
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bec77ef
Add ceph-setup role and automated osd preparation
odyssey4me 5b75636
Fix spacing issue in role
odyssey4me 1e396a3
Improved uuid generation by using ruby instead of shell
odyssey4me 1ec33a0
Improve error handling for disk preparation
odyssey4me 7560e2d
Fixed major fubar action causing existing osd's to be erased
odyssey4me 2ecb47c
Ensure that gdisk package installs immediately
odyssey4me 628e33e
Allow ceph::default to expect ceph-setup role, or direct config settings
odyssey4me ff30d81
Fix bug in osd bootstrap search parameter
odyssey4me 9117793
Add automation for MDS setup
odyssey4me 8b02743
Fix bug with package installation order
odyssey4me e74819d
Implement alternative method of saving device status that is more rel…
odyssey4me ffe9230
Ensure that disk erase and prepare execute at the appropriate point i…
odyssey4me 2c72495
Adjust logging to be less verbose unless in debug mode
odyssey4me c6bc74f
Add manage_pool LWRP, example attributes and recipe
odyssey4me File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,39 @@ | |
include_recipe "ceph::default" | ||
include_recipe "ceph::conf" | ||
|
||
if !node["ceph"]["osd_devices"].nil? | ||
node["ceph"]["osd_devices"].each do |osd_device| | ||
Log.info("ceph-osd device: #{osd_device}") | ||
end | ||
elsif node["ceph"]["osd_autoprepare"] | ||
# set node["ceph"]["osd_autoprepare"] to true to enable automated osd disk | ||
# discovery and preparation | ||
osd_devices = Array.new | ||
node['block_device'].select{|device,info| device =~ /^[hvs]d[^a]$/ and info['size'].to_i > 0}.each do |device,info| | ||
Log.info("ceph-osd: Candidate Device /dev/#{device} found.") | ||
osd_devices << {"device" => "/dev/#{device}"} | ||
end | ||
Log.info("ceph-osd: New Candidates = #{osd_devices}") | ||
node.set["ceph"]["osd_devices"] = osd_devices | ||
node.save | ||
else | ||
Log.warn('ceph-osd: No ceph osd_devices have been set and ceph osd_autoprepare not enabled.') | ||
end | ||
|
||
package 'gdisk' do | ||
action :upgrade | ||
end | ||
|
||
# sometimes there are partitions on the disk that interfere with | ||
# ceph-disk-prepare, so let's make sure there's nothing on each candidate disk | ||
if node["ceph"]["osd_autoprepare"] and !node["ceph"]["osd_devices"].nil? | ||
node["ceph"]["osd_devices"].each do |osd_device| | ||
Log.info("ceph-osd: Erasing #{osd_device['device']} to prepare it as an osd") | ||
system 'sgdisk', '-oZ', "#{osd_device['device']}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is better than "system". ;)
raise an exception :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, good tip - I've pushed an update. |
||
raise "ceph-osd: erase of #{osd_device['device']} failed" unless $?.exitstatus == 0 | ||
end | ||
end | ||
|
||
if !search(:node,"hostname:#{node['hostname']} AND dmcrypt:true").empty? | ||
package 'cryptsetup' do | ||
action :upgrade | ||
|
@@ -48,7 +77,7 @@ | |
mons = get_mon_nodes("ceph_bootstrap_osd_key:*") | ||
|
||
if mons.empty? then | ||
puts "No ceph-mon found." | ||
Log.info("ceph-osd: No ceph-mons found.") | ||
else | ||
|
||
directory "/var/lib/ceph/bootstrap-osd" do | ||
|
@@ -104,16 +133,18 @@ | |
# osd/$cluster-$id) | ||
# - $cluster should always be ceph | ||
# - The --dmcrypt option will be available starting w/ Cuttlefish | ||
Log.info("ceph-osd: Starting setup of osd_devices.") | ||
unless node["ceph"]["osd_devices"].nil? | ||
node["ceph"]["osd_devices"].each_with_index do |osd_device,index| | ||
if !osd_device["status"].nil? | ||
Log.info("osd: osd_device #{osd_device} has already been setup.") | ||
Log.info("ceph-osd: osd_device #{osd_device} has already been setup.") | ||
next | ||
end | ||
dmcrypt = "" | ||
if osd_device["encrypted"] == true | ||
dmcrypt = "--dmcrypt" | ||
end | ||
Log.info("ceph-osd: creating osd on #{osd_device['device']}.") | ||
execute "Creating Ceph OSD on #{osd_device['device']}" do | ||
command "ceph-disk-prepare #{dmcrypt} #{osd_device['device']} #{osd_device['journal']}" | ||
action :run | ||
|
@@ -143,7 +174,7 @@ | |
supports :restart => true | ||
end | ||
else | ||
Log.info('node["ceph"]["osd_devices"] empty') | ||
Log.info('ceph-osd: No ceph osd_devices have been set.') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# | ||
# Cookbook Name:: ceph | ||
# Recipe:: setup | ||
# | ||
# Copyright 2013, Business Connexion (Pty) Ltd | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# make sure we die early if there is another ceph-setup node | ||
search_query = "roles:ceph-setup NOT name:#{node.name}" | ||
search_result = search(:node, search_query) | ||
if search_result.length > 0 | ||
msg = "You can only have one node with the ceph-setup role." | ||
Chef::Application.fatal! msg | ||
end | ||
|
||
# This recipe creates a new ceph cluster and sets the node up as the | ||
# mon_initial_member for the cluster. This value can be overridden if | ||
# desired. | ||
|
||
if node['ceph']['config']['fsid'].nil? | ||
Log.info("ceph-setup: ceph fsid not set - generating a new fsid") | ||
require 'securerandom' | ||
fsid = SecureRandom.uuid | ||
node.set['ceph']['config']['fsid'] = fsid | ||
node.save | ||
Log.info("ceph-setup: ceph fsid has been set to #{fsid}") | ||
else | ||
Log.info("ceph-setup: ceph fsid is #{node['ceph']['config']['fsid']}") | ||
end | ||
|
||
if node['ceph']['config']['mon_initial_members'].nil? | ||
Log.info("ceph-setup: mon_initial_members not set - using the ceph-setup node") | ||
node.set['ceph']['config']['mon_initial_members'] = node['hostname'] | ||
node.save | ||
Log.info("ceph-setup: mon_initial_members has been set to #{node['hostname']}") | ||
else | ||
Log.info("ceph-setup: mon_initial_members is #{node['ceph']['config']['mon_initial_members']}") | ||
end | ||
|
||
include_recipe "ceph::default" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name "ceph-setup" | ||
description "Role for the setup of a Ceph cluster. Includes a mon role." | ||
run_list( | ||
'recipe[ceph::setup]', | ||
'role[ceph-mon]' | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this regex can be quite a problem...
I don't have a chef server to check, but OHAI don't give you a device type or somethings like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no - ohai gives output like this:
My thinking was that although this regex is pretty liberal, the use of it is optional and the user can always submit a patch to improve its flexibility. For now I'm happy to scratch my own itch. :)
Of course if you can think of a way to improve it right now, then I'll gladly patch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could maybe use a loop that look into /sys/block//. If inside this directory you see a . It means that the disks has partitions so we probably do not want to touch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this as a strategy?