@@ -47,17 +47,37 @@ def build_provider(resource)
4747 # Determine the appropriate provider for the given resource, then
4848 # execute it.
4949 def run_action ( resource , action , delayed_actions )
50+ # Check if this resource has an only_if block -- if it does,
51+ # evaluate the only_if block and skip the resource if
52+ # appropriate.
53+ if resource . only_if
54+ unless Chef ::Mixin ::Command . only_if ( resource . only_if , resource . only_if_args )
55+ Chef ::Log . debug ( "Skipping #{ resource } due to only_if" )
56+ return
57+ end
58+ end
59+
60+ # Check if this resource has a not_if block -- if it does,
61+ # evaluate the not_if block and skip the resource if
62+ # appropriate.
63+ if resource . not_if
64+ unless Chef ::Mixin ::Command . not_if ( resource . not_if , resource . not_if_args )
65+ Chef ::Log . debug ( "Skipping #{ resource } due to not_if" )
66+ return
67+ end
68+ end
69+
5070 provider = build_provider ( resource )
5171 provider . send ( "action_#{ action } " )
52-
72+
5373 # Execute any immediate and queue up any delayed notifications
5474 # associated with the resource.
5575 if resource . updated
5676 resource . notifies_immediate . each do |notify |
5777 Chef ::Log . info ( "#{ resource } sending #{ notify . action } action to #{ notify . resource } (immediate)" )
5878 run_action ( notify . resource , notify . action , delayed_actions )
5979 end
60-
80+
6181 resource . notifies_delayed . each do |notify |
6282 unless delayed_actions . include? ( notify )
6383 delayed_actions << notify
@@ -83,26 +103,6 @@ def converge
83103 begin
84104 Chef ::Log . debug ( "Processing #{ resource } on #{ run_context . node . name } " )
85105
86- # Check if this resource has an only_if block -- if it does,
87- # evaluate the only_if block and skip the resource if
88- # appropriate.
89- if resource . only_if
90- unless Chef ::Mixin ::Command . only_if ( resource . only_if , resource . only_if_args )
91- Chef ::Log . debug ( "Skipping #{ resource } due to only_if" )
92- next
93- end
94- end
95-
96- # Check if this resource has a not_if block -- if it does,
97- # evaluate the not_if block and skip the resource if
98- # appropriate.
99- if resource . not_if
100- unless Chef ::Mixin ::Command . not_if ( resource . not_if , resource . not_if_args )
101- Chef ::Log . debug ( "Skipping #{ resource } due to not_if" )
102- next
103- end
104- end
105-
106106 # Execute each of this resource's actions.
107107 action_list = resource . action . kind_of? ( Array ) ? resource . action : [ resource . action ]
108108 action_list . each do |action |
0 commit comments