It is best to put command_2 first and then protect it by checking if it needs to be run or not. I'm not sure what this command does, but if you can somehow make sure if it is necessary or not, then you can do so.
, command_2, - :
execute 'command_1' do
command "ipa host-del #{machine_name} && touch /tmp/successful"
action :run
ignore_failure true
end
execute 'command_2' do
command "ipa host-mod --certificate #{machine_name}"
action :run
notifies :run, 'execute['command_1']', :immediately
not_if { ::File.exist? '/tmp/successful' }
end
file '/tmp/successful' do
action :delete
end
command_1, , touch /tmp/successful. command_2 , /tmp/successful . IF command_2 , command_1 . , file /tmp/successful