diff --git a/recipes/bootstrap_osd.rb b/recipes/bootstrap_osd.rb deleted file mode 100644 index b5c6bc1..0000000 --- a/recipes/bootstrap_osd.rb +++ /dev/null @@ -1,83 +0,0 @@ -# this recipe allows bootstrapping new osds, with help from mon - -include_recipe "ceph::osd" -include_recipe "ceph::conf" - -package 'gdisk' do - action :upgrade -end - -mons = get_mon_nodes("ceph_bootstrap_osd_key:*") - -if mons.empty? then - puts "No ceph-mon found." -else - - directory "/var/lib/ceph/bootstrap-osd" do - owner "root" - group "root" - mode "0755" - end - - # TODO cluster name - cluster = 'ceph' - - file "/var/lib/ceph/bootstrap-osd/#{cluster}.keyring.raw" do - owner "root" - group "root" - mode "0440" - content mons[0]["ceph_bootstrap_osd_key"] - end - - execute "format as keyring" do - command <<-EOH - set -e - # TODO don't put the key in "ps" output, stdout - read KEY <'/var/lib/ceph/bootstrap-osd/#{cluster}.keyring.raw' - ceph-authtool '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring' --create-keyring --name=client.bootstrap-osd --add-key="$KEY" - rm -f '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring.raw' - EOH - end - - if is_crowbar? - ruby_block "select new disks for ceph osd" do - block do - do_trigger = false - node["crowbar"]["disks"].each do |disk, data| - use = true - - if node["swift"] and node["swift"]["devs"] - node["swift"]["devs"].each do |num| - if num["name"].match(disk) - puts "Disk: #{disk} is being used for swift, skipping" - use = false - end - end - end - - if node["crowbar"]["disks"][disk]["usage"] == "Storage" and use == true - puts "Disk: #{disk} should be used for ceph" - - system 'ceph-disk-prepare', \ - "/dev/#{disk}" - raise 'ceph-disk-prepare failed' unless $?.exitstatus == 0 - - do_trigger = true - - node["crowbar"]["disks"][disk]["usage"] = "ceph-osd" - node.save - end - end - - if do_trigger - system 'udevadm', \ - "trigger", \ - "--subsystem-match=block", \ - "--action=add" - raise 'udevadm trigger failed' unless $?.exitstatus == 0 - end - - end - end - end -end diff --git a/recipes/osd.rb b/recipes/osd.rb index acad61b..636dddc 100644 --- a/recipes/osd.rb +++ b/recipes/osd.rb @@ -16,5 +16,87 @@ # 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. - + +# this recipe allows bootstrapping new osds, with help from mon + include_recipe "ceph::default" +include_recipe "ceph::conf" + +package 'gdisk' do + action :upgrade +end + +mons = get_mon_nodes("ceph_bootstrap_osd_key:*") + +if mons.empty? then + puts "No ceph-mon found." +else + + directory "/var/lib/ceph/bootstrap-osd" do + owner "root" + group "root" + mode "0755" + end + + # TODO cluster name + cluster = 'ceph' + + file "/var/lib/ceph/bootstrap-osd/#{cluster}.keyring.raw" do + owner "root" + group "root" + mode "0440" + content mons[0]["ceph_bootstrap_osd_key"] + end + + execute "format as keyring" do + command <<-EOH + set -e + # TODO don't put the key in "ps" output, stdout + read KEY <'/var/lib/ceph/bootstrap-osd/#{cluster}.keyring.raw' + ceph-authtool '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring' --create-keyring --name=client.bootstrap-osd --add-key="$KEY" + rm -f '/var/lib/ceph/bootstrap-osd/#{cluster}.keyring.raw' + EOH + end + + if is_crowbar? + ruby_block "select new disks for ceph osd" do + block do + do_trigger = false + node["crowbar"]["disks"].each do |disk, data| + use = true + + if node["swift"] and node["swift"]["devs"] + node["swift"]["devs"].each do |num| + if num["name"].match(disk) + puts "Disk: #{disk} is being used for swift, skipping" + use = false + end + end + end + + if node["crowbar"]["disks"][disk]["usage"] == "Storage" and use == true + puts "Disk: #{disk} should be used for ceph" + + system 'ceph-disk-prepare', \ + "/dev/#{disk}" + raise 'ceph-disk-prepare failed' unless $?.exitstatus == 0 + + do_trigger = true + + node["crowbar"]["disks"][disk]["usage"] = "ceph-osd" + node.save + end + end + + if do_trigger + system 'udevadm', \ + "trigger", \ + "--subsystem-match=block", \ + "--action=add" + raise 'udevadm trigger failed' unless $?.exitstatus == 0 + end + + end + end + end +end diff --git a/roles/ceph-osd.rb b/roles/ceph-osd.rb index edf4088..25369e9 100644 --- a/roles/ceph-osd.rb +++ b/roles/ceph-osd.rb @@ -1,5 +1,5 @@ name "ceph-osd" description "Ceph Object Storage Device" run_list( - 'recipe[ceph::bootstrap_osd]' + 'recipe[ceph::osd]' )