ec2_vpn_connection.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:f5-aws-vpn 作者: f5devcentral 项目源码 文件源码
def main():
    argument_spec = ec2_argument_spec()
    argument_spec.update(dict(
            state={'required': True, 'choices': ['present', 'absent']},
            id={'default': None, 'required': False, 'type': 'str'},
            type={'default': 'ipsec.1', 'required': False, 'type': 'str'},
            cgw={'default': None, 'required': False, 'type': 'str'},
            vpn_gw={'default': None, 'required': False, 'type': 'str'},
            vpc={'default': None, 'required': False, 'type': 'str'},
            static_routes_only={'default': False, 'required': False, 'type': 'bool'},
            static_routes={'default': None, 'required': False, 'type': 'list' },
            tags={'required': True, 'type': 'dict'}


        )
    )

    module = AnsibleModule(
        argument_spec=argument_spec,
    )


    region, ec2_url, aws_connect_params = get_aws_connection_info(module)


    state = module.params['state']
    id = module.params['id']
    type = module.params['type']
    cgw = module.params['cgw']
    vpn_gw = module.params['vpn_gw']
    vpc = module.params['vpc']
    static_routes_only = module.params['static_routes_only']
    static_routes = module.params['static_routes']
    tags = module.params['tags']


    if not region:
        module.fail_json(msg="Region must be specified as a parameter, in EC2_REGION or AWS_REGION environment variables or in boto configuration file")


    vpn_conn_man = VPNConnectionManager( module, id, type, cgw, vpn_gw, vpc, 
                                         static_routes_only, static_routes, tags,
                                         region, **aws_connect_params )

    if state == 'present':
        vpn_conn_man.ensure_ok()
    elif state == 'absent':
        vpn_conn_man.ensure_gone()


    ansible_facts = {'ec2_vpn_connection': 'info'}
    ec2_facts_result = dict(changed=vpn_conn_man.changed,
                            vpn_conn=vpn_conn_man.get_info(),
                            ansible_facts=ansible_facts)

    module.exit_json(**ec2_facts_result)

# import module snippets
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号