diff --git a/Gemfile b/Gemfile index 50baaa3c..fab43515 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ source "https://rubygems.org" gem "sprockets-standalone", "~> 1.2.1" group :development do + gem "rake", "< 12.0.0" gem "closure-compiler", "~> 1.1.10" gem "sass", "~> 3.2.19" gem "sprockets", "~> 2.11.0" diff --git a/chef/cookbooks/crowbar-pacemaker/recipes/drbd.rb b/chef/cookbooks/crowbar-pacemaker/recipes/drbd.rb index ec3e56a9..875c05a5 100644 --- a/chef/cookbooks/crowbar-pacemaker/recipes/drbd.rb +++ b/chef/cookbooks/crowbar-pacemaker/recipes/drbd.rb @@ -67,4 +67,7 @@ lvm_group lvm_group end -include_recipe "drbd::default" +# Disable drbd as it should never be started on boot (pacemaker should do it) +service "drbd" do + action :disable +end diff --git a/chef/cookbooks/drbd/providers/resource.rb b/chef/cookbooks/drbd/providers/resource.rb index 94a41d8c..7e6b97ac 100644 --- a/chef/cookbooks/drbd/providers/resource.rb +++ b/chef/cookbooks/drbd/providers/resource.rb @@ -31,7 +31,7 @@ raise "Remote node #{remote_host} not found!" if remote_nodes.empty? remote = remote_nodes.first - template "/etc/drbd.d/#{name}.res" do + drbd_resource_template = template "/etc/drbd.d/#{name}.res" do cookbook "drbd" source "resource.erb" variables( @@ -47,45 +47,35 @@ owner "root" group "root" action :nothing - end.run_action(:create) + end + drbd_resource_template.run_action(:create) # first pass only, initialize drbd # for disks re-usage from old resources we will run with force option - p = execute "drbdadm -- --force create-md #{name}" do - only_if do - overview = DrbdOverview.get(name) - !overview.nil? && overview["state"] == "Unconfigured" - end + drbdadm_create_md = execute "drbdadm -- --force create-md #{name}" do + only_if { drbd_resource_template.updated_by_last_action? } action :nothing end - p.run_action(:run) + drbdadm_create_md.run_action(:run) - if p.updated_by_last_action? - # we would usually do something like: - # notifies :restart, "service[drbd]", :immediately - # in the execute above; but the notification doesn't work (probably because - # we're already in a LWRP). So we hack around this. - service "drbd(#{name})" do - service_name "drbd" - action :nothing - end.run_action(:restart) + drbdadm_up = execute "drbdadm up #{name}" do + only_if { drbd_resource_template.updated_by_last_action? } + action :nothing end + drbdadm_up.run_action(:run) - overview = DrbdOverview.get(name) - if !overview.nil? && overview["state"] != "Unconfigured" && overview["primary"].nil? - # claim primary based off of master - execute "drbdadm -- --overwrite-data-of-peer primary #{name}" do - only_if { master } - action :nothing - end.run_action(:run) + # claim primary based off of master + execute "drbdadm -- --overwrite-data-of-peer primary #{name}" do + only_if { drbd_resource_template.updated_by_last_action? && master } + action :nothing + end.run_action(:run) - # you may now create a filesystem on the device, use it as a raw block device - # for disks re-usage from old resources we will run with force option - execute "mkfs -t #{fstype} -f #{device}" do - only_if { master } - action :nothing - end.run_action(:run) - end + # you may now create a filesystem on the device, use it as a raw block device + # for disks re-usage from old resources we will run with force option + execute "mkfs -t #{fstype} -f #{device}" do + only_if { drbd_resource_template.updated_by_last_action? && master } + action :nothing + end.run_action(:run) unless mount.nil? or mount.empty? directory mount do @@ -100,7 +90,10 @@ action :nothing end.run_action(:mount) end +end +action :wait do + name = new_resource.name begin Timeout.timeout(20) do while true diff --git a/chef/cookbooks/drbd/resources/resource.rb b/chef/cookbooks/drbd/resources/resource.rb index 0d2b1863..4d75a044 100644 --- a/chef/cookbooks/drbd/resources/resource.rb +++ b/chef/cookbooks/drbd/resources/resource.rb @@ -14,7 +14,7 @@ # limitations under the License. # -actions :create +actions :create, :wait default_action :create attribute :name, kind_of: String, name_attribute: true diff --git a/chef/cookbooks/pacemaker/Gemfile b/chef/cookbooks/pacemaker/Gemfile index 4a84ad3b..0dc3c45a 100644 --- a/chef/cookbooks/pacemaker/Gemfile +++ b/chef/cookbooks/pacemaker/Gemfile @@ -1,6 +1,7 @@ source "https://rubygems.org" #gem 'berkshelf', '~> 2.0' +gem "rack", "< 2.0.0" gem "rake" group :test, :development do diff --git a/crowbar_framework/app/models/pacemaker_service.rb b/crowbar_framework/app/models/pacemaker_service.rb index 5ac63011..cd2bdca5 100644 --- a/crowbar_framework/app/models/pacemaker_service.rb +++ b/crowbar_framework/app/models/pacemaker_service.rb @@ -154,7 +154,8 @@ def apply_cluster_roles_to_new_nodes_for(cluster_element, relevant_nodes, all_ro end expanded_nodes.sort! - old_expanded_nodes = deployment["elements_expanded"][role_name].sort + old_expanded_nodes = deployment["elements_expanded"][role_name] || [] + old_expanded_nodes.sort! if old_expanded_nodes != expanded_nodes deployment["elements_expanded"][role_name] = expanded_nodes