ansible/ansible — pull request #5506 by mohangk (2014-01-05 10:42:55+00:00)
Title: Fix exception being thrown for new instance registration with ELB

Currently if we are trying to register an instance that has not yet
been registered with the elb an exception is thrown as follows:

Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 1412, in
main()
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 335, in main
elb_man.register(wait, enable_availability_zone)
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 168, in register
self._await_elb_instance_state(lb, 'InService', initial_state)
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 213, in _await_elb_instance_state
if instance_state.state != initial_state.state:
AttributeError: 'NoneType' object has no attribute 'state'

This is expected because the code is querying the elb for the state of the new instance and it responds with a "InvalidInstance" response (as its not been registered with the ELB yet) and the code sets the value of the initial_state to None.

This code change checks if the initial_state is None. If it is, its safe to assume that its state has changed.