mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
update to capture peer status
This commit is contained in:
parent
985e485706
commit
deaf40d942
1 changed files with 22 additions and 14 deletions
|
@ -208,6 +208,13 @@ def create_peer_connection(client, module):
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
def peer_status(client, module):
|
||||||
|
params = dict()
|
||||||
|
params['VpcPeeringConnectionIds'] = [module.params.get('peering_id')]
|
||||||
|
vpc_peering_connection = client.describe_vpc_peering_connections(**params)
|
||||||
|
return vpc_peering_connection['VpcPeeringConnections'][0]['Status']['Code']
|
||||||
|
|
||||||
|
|
||||||
def accept_reject_delete(state, client, module):
|
def accept_reject_delete(state, client, module):
|
||||||
changed = False
|
changed = False
|
||||||
params = dict()
|
params = dict()
|
||||||
|
@ -218,6 +225,7 @@ def accept_reject_delete(state, client, module):
|
||||||
'reject': client.reject_vpc_peering_connection,
|
'reject': client.reject_vpc_peering_connection,
|
||||||
'absent': client.delete_vpc_peering_connection
|
'absent': client.delete_vpc_peering_connection
|
||||||
}
|
}
|
||||||
|
if state == 'absent' or peer_status(client, module) != 'active':
|
||||||
try:
|
try:
|
||||||
invocations[state](**params)
|
invocations[state](**params)
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -241,7 +249,7 @@ def main():
|
||||||
module = AnsibleModule(argument_spec=argument_spec)
|
module = AnsibleModule(argument_spec=argument_spec)
|
||||||
|
|
||||||
if not HAS_BOTO3:
|
if not HAS_BOTO3:
|
||||||
module.fail_json(msg='json and boto/boto3 is required.')
|
module.fail_json(msg='json and boto3 is required.')
|
||||||
state = module.params.get('state').lower()
|
state = module.params.get('state').lower()
|
||||||
try:
|
try:
|
||||||
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
|
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
|
||||||
|
|
Loading…
Reference in a new issue