ansible/ansible-modules-core — pull request #584 by robbwagoner (2014-12-30 22:05:17+00:00)
Title: ec2_elb_lb instance states in result

Includes the instances, and their states, in the result dictionary. This allows one to perform conditional checks on the number of InService instances for an ELB prior to deregistration with the `ec2_elb` module.

```yaml
- name: Deploy to instances behind ELB
serial: 1
pre_tasks:
- name: Check ELB status
tags: [ 'elb', 'common' ]
local_action:
module: ec2_elb_lb
name: "{{ elb }}"
state: "present"
listeners:
- protocol: http
load_balancer_port: 80
instance_port: 80
zones:
- us-east-1d
- us-east-1e
register: result_elb
- debug: msg="{{ result_elb }}"
tags: [ 'elb', 'common' ]
- assert: msg="Not enough active instances behind the ELB"
when: result_elb.in_service_count|int < 2
tags: [ 'elb', 'common' ]
```
Result:
```
TASK: [debug msg="{{ result_elb }}"] ******************************************
ok: [my-elb-instance] => {
"msg": "{u'elb': {u'status': u'ok', u'subnets': None, u'connection_draining_timeout': 300, u'health_check': {u'healthy_threshold':
2, u'interval': 5, u'target': u'HTTP:80/haproxy?monitor', u'timeout': 2, u'unhealthy_threshold': 2}, u'name': u'my-elb', u'instance
_health': [{u'instance_id': u'i-deadbeef', u'state': u'InService', u'reason_code': u'N/A'}, {u'instance_id': u'i-fa1afe1', u'state': u
'InService', u'reason_code': u'N/A'}], u'in_service_count': 2, u'out_of_service_count': 0, u'zones': [u'us-east-1d', u'us-east-1e'], u'instances': [u'i-fa1afe1', u'i-beadbeef'], u'listeners': [[80, 80, u'HTTP', u'HTTP']], u'scheme': u'internet-facing', u'dns_name': u'my-elb-123456789.us-east-1.elb.amazonaws.com', u'cross_az_load_balancing': u'no', u'security_group_ids': [], u'unknown_instance_state_count': 0}, 'invocation': {'module_name': u'ec2_elb_lb', 'module_args': ''}, u'changed': False, u'ansible_facts': {u'ec2_elb': u'info'}}"
}
```