From 8b15127fb6bf91ddedbea52108027a027fa3f1ed Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@suse.com>
Date: Sat, 2 Aug 2014 00:18:22 +0200
Subject: [PATCH 1/3] Complete 558432f by dropping target-role on the chef
 resource too

Commit 558432f was not fully complete, as it's also important to drop
target-role from the chef resource, not just from the bit we're using to
check if we need to update the pacemaker resource.
---
 chef/cookbooks/pacemaker/providers/primitive.rb | 1 +
 1 file changed, 1 insertion(+)

Index: crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/primitive.rb
===================================================================
--- crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95.orig/chef/cookbooks/pacemaker/providers/primitive.rb
+++ crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/primitive.rb
@@ -99,6 +99,7 @@ def maybe_modify_resource(name)
   #
   # This can result in a primitive not being started with [:create, :start].
   # Therefore, we just delete this deprecated bit from meta to avoid any issue.
+  new_resource.meta.delete('target-role')
   desired_primitive.meta.delete('target-role')
 
   if desired_primitive.op_string != @current_cib_object.op_string
Index: crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/clone.rb
===================================================================
--- crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95.orig/chef/cookbooks/pacemaker/providers/clone.rb
+++ crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/clone.rb
@@ -58,9 +58,16 @@ def create_resource(name)
 end
 
 def maybe_modify_resource(name)
+  deprecate_target_role
+
   Chef::Log.info "Checking existing #{@current_cib_object} for modifications"
 
   desired_clone = cib_object_class.from_chef_resource(new_resource)
+
+  # See comment in primitive provider as to why we do this
+  new_resource.meta.delete('target-role')
+  desired_clone.meta.delete('target-role')
+
   if desired_clone.definition_string != @current_cib_object.definition_string
     Chef::Log.debug "changed from [#{@current_cib_object.definition_string}] to [#{desired_clone.definition_string}]"
     cmd = desired_clone.reconfigure_command
Index: crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/group.rb
===================================================================
--- crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95.orig/chef/cookbooks/pacemaker/providers/group.rb
+++ crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/group.rb
@@ -57,9 +57,16 @@ def create_resource(name)
 end
 
 def maybe_modify_resource(name)
+  deprecate_target_role
+
   Chef::Log.info "Checking existing #{@current_cib_object} for modifications"
 
   desired_group = cib_object_class.from_chef_resource(new_resource)
+
+  # See comment in primitive provider as to why we do this
+  new_resource.meta.delete('target-role')
+  desired_group.meta.delete('target-role')
+
   if desired_group.definition_string != @current_cib_object.definition_string
     Chef::Log.debug "changed from [#{@current_cib_object.definition_string}] to [#{desired_group.definition_string}]"
     cmd = desired_group.reconfigure_command
Index: crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/ms.rb
===================================================================
--- crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95.orig/chef/cookbooks/pacemaker/providers/ms.rb
+++ crowbar-barclamp-pacemaker-1.9+git.1428418359.8d25d95/chef/cookbooks/pacemaker/providers/ms.rb
@@ -58,12 +58,19 @@ def create_resource(name)
 end
 
 def maybe_modify_resource(name)
+  deprecate_target_role
+
   Chef::Log.info "Checking existing #{@current_cib_object} for modifications"
 
-  desired_clone = cib_object_class.from_chef_resource(new_resource)
-  if desired_clone.definition_string != @current_cib_object.definition_string
-    Chef::Log.debug "changed from [#{@current_cib_object.definition_string}] to [#{desired_clone.definition_string}]"
-    cmd = desired_clone.reconfigure_command
+  desired_ms = cib_object_class.from_chef_resource(new_resource)
+
+  # See comment in primitive provider as to why we do this
+  new_resource.meta.delete('target-role')
+  desired_ms.meta.delete('target-role')
+
+  if desired_ms.definition_string != @current_cib_object.definition_string
+    Chef::Log.debug "changed from [#{@current_cib_object.definition_string}] to [#{desired_ms.definition_string}]"
+    cmd = desired_ms.reconfigure_command
     execute cmd do
       action :nothing
     end.run_action(:run)
