Ejemplo n.º 1
0
def dis_eip_associate(public_ip):
    ec2 = boto.ec2.connect_to_region(region)
    address = ec2.get_all_addresses(addresses='5.2.29.7')
    association_id = address[0].association_id
    ec2.disassociate_address(public_ip=public_ip,
                             association_id=association_id,
                             dry_run=False)
Ejemplo n.º 2
0
def disassociate_ip_and_device(ec2, address, device_id, check_mode, isinstance=True):
    if not address_is_associated_with_device(ec2, address, device_id, isinstance):
        return {"changed": False}

    # If we're in check mode, nothing else to do
    if not check_mode:
        if address.domain == "vpc":
            res = ec2.disassociate_address(association_id=address.association_id)
        else:
            res = ec2.disassociate_address(public_ip=address.public_ip)

        if not res:
            raise EIPException("disassociation failed")

    return {"changed": True}
Ejemplo n.º 3
0
def disassociate_ip_and_eni(ec2, address, eni_id, module):
    if not ip_is_associated_with_eni(ec2, address.public_ip, eni_id, module):
        module.exit_json(changed=False, public_ip=address.public_ip)

    # If we're in check mode, nothing else to do
    if module.check_mode:
        module.exit_json(changed=True)

    try:
        if address.domain == "vpc":
            res = ec2.disassociate_address(association_id=address.association_id)
        else:
            res = ec2.disassociate_address(public_ip=address.public_ip)
    except boto.exception.EC2ResponseError, e:
        module.fail_json(msg=str(e))
Ejemplo n.º 4
0
def disassociate_ip_and_instance(ec2, address, instance_id, module):
    if not ip_is_associated_with_instance(ec2, address.public_ip, instance_id, module):
        module.exit_json(changed=False, public_ip=address.public_ip)

    # If we're in check mode, nothing else to do
    if module.check_mode:
        module.exit_json(changed=True)

    try:
        if address.domain == "vpc":
            res = ec2.disassociate_address(association_id=address.association_id)
        else:
            res = ec2.disassociate_address(public_ip=address.public_ip)
    except boto.exception.EC2ResponseError, e:
        module.fail_json(msg=str(e))
Ejemplo n.º 5
0
def disassociate_ip_and_instance(ec2, address, instance_id, check_mode):
    if not address_is_associated_with_instance(ec2, address, instance_id):
        return {'changed': False}

    # If we're in check mode, nothing else to do
    if not check_mode:
        if address.domain == 'vpc':
            res = ec2.disassociate_address(
                association_id=address.association_id)
        else:
            res = ec2.disassociate_address(public_ip=address.public_ip)

        if not res:
            raise EIPException('disassociation failed')

    return {'changed': True}
Ejemplo n.º 6
0
def disassociate_ip_and_instance(ec2, address, instance_id, check_mode):
    if not address_is_associated_with_instance(ec2, address, instance_id):
        return {'changed': False}

    # If we're in check mode, nothing else to do
    if not check_mode:
        if address.domain == 'vpc':
            res = ec2.disassociate_address(
                association_id=address.association_id)
        else:
            res = ec2.disassociate_address(public_ip=address.public_ip)

        if not res:
            raise EIPException('disassociation failed')

    return {'changed': True}
Ejemplo n.º 7
0
def dis_eip_associate(public_ip):
    ec2 = boto.ec2.connect_to_region(region)
    address = ec2.get_all_addresses(addresses="5.2.29.7")
    association_id = address[0].association_id
    ec2.disassociate_address(public_ip=public_ip, association_id=association_id, dry_run=False)