diff --git a/chef/cookbooks/ceph/recipes/mon.rb b/chef/cookbooks/ceph/recipes/mon.rb index ff0b12a..43caf6a 100644 --- a/chef/cookbooks/ceph/recipes/mon.rb +++ b/chef/cookbooks/ceph/recipes/mon.rb @@ -52,6 +52,8 @@ add_key.run_command add_key.error! + # no need to check if the attribute is already set: it's part of the + # only_if node.set["ceph"]["monitor-secret"] = monitor_key node.save end @@ -85,10 +87,11 @@ add_key.run_command add_key.error! + # no need to check if the attribute is already set: it's part of the node.set["ceph"]["monitor-secret"] = monitor_key node.save end - only_if { node["ceph"]["monitor-secret"].empty? } + only_if { node["ceph"]["monitor-secret"].empty? && !node[:ceph][:master] } notifies :run, "execute[ceph-mon mkfs]", :immediately end diff --git a/chef/cookbooks/ceph/recipes/osd.rb b/chef/cookbooks/ceph/recipes/osd.rb index d8c291d..6522e7b 100644 --- a/chef/cookbooks/ceph/recipes/osd.rb +++ b/chef/cookbooks/ceph/recipes/osd.rb @@ -69,13 +69,19 @@ end if is_crowbar? - node.set["ceph"]["osd_devices"] = [] if node["ceph"]["osd_devices"].nil? + dirty = false + + node.set["ceph"]["osd_devices"] ||= [] min_size_blocks = node["ceph"]["osd"]["min_size_gb"] * 1024 * 1024 * 2 unclaimed_disks = BarclampLibrary::Barclamp::Inventory::Disk.unclaimed(node).sort.select { |d| d.size >= min_size_blocks } # if devices for journal are explicitely listed, do not use automatic journal assigning to SSD if !node["ceph"]["osd"]["journal_devices"].empty? - node.set["ceph"]["osd"]["use_ssd_for_journal"] = false + # explicit comparison because we don't want a condition that uses nil + if node["ceph"]["osd"]["use_ssd_for_journal"] != false + node.set["ceph"]["osd"]["use_ssd_for_journal"] = false + dirty = true + end end # If no OSDs have yet been deployed, check what type of disks are available. @@ -88,7 +94,11 @@ has_ssds = unclaimed_disks.any? { |d| node[:block_device][d.name.gsub("/dev/", "")]["rotational"] == "0" } has_hdds = unclaimed_disks.any? { |d| node[:block_device][d.name.gsub("/dev/", "")]["rotational"] == "1" } - node.set["ceph"]["osd"]["use_ssd_for_journal"] = false unless has_ssds && has_hdds + use_ssd_for_journal = has_ssds && has_hdds + if node["ceph"]["osd"]["use_ssd_for_journal"] != use_ssd_for_journal + node.set["ceph"]["osd"]["use_ssd_for_journal"] = use_ssd_for_journal + dirty = true + end end if node["ceph"]["disk_mode"] == "first" && node["ceph"]["osd_devices"].empty? @@ -127,7 +137,7 @@ end device["device"] = d.name node.set["ceph"]["osd_devices"].push(device) - node.save + dirty = true else Chef::Log.info("Ceph: Ignoring #{d.name}") end @@ -198,8 +208,15 @@ end end end - node.set["ceph"]["osd_devices"][index]["status"] = "deployed" - node.set["ceph"]["osd_devices"][index]["journal"] = journal_device unless journal_device.nil? + if node["ceph"]["osd_devices"][index]["status"] != "deployed" + node.set["ceph"]["osd_devices"][index]["status"] = "deployed" + dirty = true + end + # if journal_device is nil, this will still work as expected + if node["ceph"]["osd_devices"][index]["journal"] != journal_device + node.set["ceph"]["osd_devices"][index]["journal"] = journal_device + dirty = true + end execute "Writing Ceph OSD device mappings to fstab" do command "tail -n1 /etc/mtab >> /etc/fstab" @@ -209,7 +226,6 @@ # No need to specifically enable ceph-osd@N on systemd systems, as this # is done automatically by ceph-disk-activate end - node.save service "ceph_osd" do case service_type @@ -234,5 +250,7 @@ end end end + + node.save if dirty end end