You could probably simplify this section a little. See knife-ec2/lib/chef/knife/ec2_server_create.rb #wait_for_direct_sshd for some ideas like using 'until'.