mirror of
https://github.com/trailofbits/algo.git
synced 2025-04-11 11:47:08 +02:00
* bump ansible to 2.8.3 * DigitalOcean: move to the latest modules * Add Hetzner Cloud * Scaleway and Lightsail fixes * lint missing roles * Update roles/cloud-hetzner/tasks/main.yml Add api_token Co-Authored-By: phaer <phaer@phaer.org> * Update roles/cloud-hetzner/tasks/main.yml Add api_token Co-Authored-By: phaer <phaer@phaer.org> * Try to run apt until succeeded * Scaleway modules upgrade * GCP: Refactoring, remove deprecated modules * Doc updates (#1552) * Update README.md Adding links and mentions of Exoscale aka CloudStack and Hetzner Cloud. * Update index.md Add the Hetzner Cloud to the docs index * Remove link to Win 10 IPsec instructions * Delete client-windows.md Unnecessary since the deprecation of IPsec for Win10. * Update deploy-from-ansible.md Added sections and required variables for CloudStack and Hetzner Cloud. * Update deploy-from-ansible.md Added sections for CloudStack and Hetzner, added req variables and examples, mentioned environment variables, and added links to the provider role section. * Update deploy-from-ansible.md Cosmetic changes to links, fix typo. * Update GCE variables * Update deploy-from-script-or-cloud-init-to-localhost.md Fix a finer point, and make variables list more readable. * update azure requirements * Python3 draft * set LANG=c to the p12 password generation task * Update README * Install cloud requirements to the existing venv * FreeBSD fix * env->.env fixes * lightsail_region_facts fix * yaml syntax fix * Update README for Python 3 (#1564) * Update README for Python 3 * Remove tabs and tweak instructions * Remove cosmetic command indentation * Update README.md * Update README for Python 3 (#1565) * DO fix for "found unpermitted parameters: id" * Verify Python version * Remove ubuntu 16.04 from readme * Revert back DigitalOcean module * Update deploy-from-script-or-cloud-init-to-localhost.md * env to .env
102 lines
2.8 KiB
Python
102 lines
2.8 KiB
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
# Copyright: Ansible Project
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
__metaclass__ = type
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
'status': ['preview'],
|
|
'supported_by': 'community'}
|
|
|
|
DOCUMENTATION = '''
|
|
---
|
|
module: lightsail_region_facts
|
|
short_description: Gather facts about AWS Lightsail regions.
|
|
description:
|
|
- Gather facts about AWS Lightsail regions.
|
|
version_added: "2.5.3"
|
|
author: "Jack Ivanov (@jackivanov)"
|
|
options:
|
|
requirements:
|
|
- "python >= 2.6"
|
|
- boto3
|
|
|
|
extends_documentation_fragment:
|
|
- aws
|
|
- ec2
|
|
'''
|
|
|
|
|
|
EXAMPLES = '''
|
|
# Gather facts about all regions
|
|
- lightsail_region_facts:
|
|
'''
|
|
|
|
RETURN = '''
|
|
regions:
|
|
returned: on success
|
|
description: >
|
|
Each element consists of a dict with all the information related
|
|
to that region.
|
|
type: list
|
|
sample: "[{
|
|
"availabilityZones": [],
|
|
"continentCode": "NA",
|
|
"description": "This region is recommended to serve users in the eastern United States",
|
|
"displayName": "Virginia",
|
|
"name": "us-east-1"
|
|
}]"
|
|
'''
|
|
|
|
import time
|
|
import traceback
|
|
|
|
try:
|
|
import botocore
|
|
HAS_BOTOCORE = True
|
|
except ImportError:
|
|
HAS_BOTOCORE = False
|
|
|
|
try:
|
|
import boto3
|
|
except ImportError:
|
|
# will be caught by imported HAS_BOTO3
|
|
pass
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
from ansible.module_utils.ec2 import (ec2_argument_spec, get_aws_connection_info, boto3_conn,
|
|
HAS_BOTO3, camel_dict_to_snake_dict)
|
|
|
|
def main():
|
|
argument_spec = ec2_argument_spec()
|
|
module = AnsibleModule(argument_spec=argument_spec)
|
|
|
|
if not HAS_BOTO3:
|
|
module.fail_json(msg='Python module "boto3" is missing, please install it')
|
|
|
|
if not HAS_BOTOCORE:
|
|
module.fail_json(msg='Python module "botocore" is missing, please install it')
|
|
|
|
try:
|
|
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
|
|
|
|
client = None
|
|
try:
|
|
client = boto3_conn(module, conn_type='client', resource='lightsail',
|
|
region=region, endpoint=ec2_url, **aws_connect_kwargs)
|
|
except (botocore.exceptions.ClientError, botocore.exceptions.ValidationError) as e:
|
|
module.fail_json(msg='Failed while connecting to the lightsail service: %s' % e, exception=traceback.format_exc())
|
|
|
|
response = client.get_regions(
|
|
includeAvailabilityZones=False
|
|
)
|
|
module.exit_json(changed=False, data=response)
|
|
except (botocore.exceptions.ClientError, Exception) as e:
|
|
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|