Thanks for explaining.


On Apr 25, 2013, at 5:36 PM, jarv <notifications@github.com> wrote:

> In playbooks/util/elb_reg.py:
> 
> > +        else:
> > +            print "Checking again in 2 seconds. Elapsed time: {0}".format(
> > +                time.time() - start_time)
> > +            time.sleep(2)
> > +
> > +
> > +def deregister():
> > +    """Deregister the instance from all ELBs and wait for the ELB
> > +    to report them out-of-service"""
> > +
> > +    for lb in active_lbs:
> > +        lb.deregister_instances([args.instance])
> > +        await_elb_instance_state(lb, args.instance, 'OutOfService')
> > +
> > +
> > +def register():
> Here is the sequence broken down, it's not intuitive at all unfortunately looking at the playbook (I should have added more comments to the example)
> 
> pre_tasks:
> 
> name: Gathering ec2 facts ec2_facts:
> name: Gathering ELB facts local_action: ec2_elb_facts
> These two modules "ec2_facts" and "ec2_elb_facts" are invoked in the pre_tasks and give us the following facts which are variables that can be used in the playbook:
> 
> $elbs which is { '<instanceid-1>': [ <elb1>, <elb2>, .. ], <instanceid-2>... } Where elb1, elb2 are the elbs attached to the instance.
> $ansible_ec2_instance_id which is the current instance that operations are being run on
> The way the command is invoked is as follows:
> 
> local_action: command util/elb_reg.py -e {{ ",".join(elbs[ansible_ec2_instance_id]) }} -i {{ ansible_ec2_instance_id }} deregister
> Where -e is the list of elbs that the current instances belong to and -i is the instance
> "active_elbs" are the elbs that are passed in.
> 
> local_action: command util/elb_reg.py -e {{ ",".join(elbs[ansible_ec2_instance_id]) }} -i {{ ansible_ec2_instance_id }} register
> Register will pass in the same elb list and the same instance id to add it back to the pool
> 
> —
> Reply to this email directly or view it on GitHub.
>