コード例 #1
0
def main():
    module = AnsibleModule(
        argument_spec=DigitalOceanHelper.digital_ocean_argument_spec(),
        supports_check_mode=True,
    )

    core(module)
コード例 #2
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(
        snapshot_type=dict(type='str',
                           required=False,
                           choices=['all', 'droplet', 'volume', 'by_id'],
                           default='all'),
        snapshot_id=dict(type='str', required=False),
    )
    module = AnsibleModule(
        argument_spec=argument_spec,
        required_if=[
            ['snapshot_type', 'by_id', ['snapshot_id']],
        ],
    )
    if module._name in ('digital_ocean_snapshot_facts',
                        'community.general.digital_ocean_snapshot_facts'):
        module.deprecate(
            "The 'digital_ocean_snapshot_facts' module has been renamed to 'digital_ocean_snapshot_info'",
            version='3.0.0',
            collection_name='community.general')  # was Ansible 2.13

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #3
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec)
    if module._name == 'digital_ocean_account_facts':
        module.deprecate("The 'digital_ocean_account_facts' module has been renamed to 'digital_ocean_account_info'", version='2.13')
    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #4
0
def main():
    module = AnsibleModule(
        argument_spec=DigitalOceanHelper.digital_ocean_argument_spec()
    )
    if module._name in ('digital_ocean_floating_ip_facts', 'community.general.digital_ocean_floating_ip_facts'):
        module.deprecate("The 'digital_ocean_floating_ip_facts' module has been renamed to 'digital_ocean_floating_ip_info'", version='2.13')

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e))
コード例 #5
0
def main():
    module = AnsibleModule(
        argument_spec=DigitalOceanHelper.digital_ocean_argument_spec(),
        supports_check_mode=False,
    )

    module.deprecate(
        "The 'digital_ocean_sshkey_facts' module has been deprecated, use the new 'digital_ocean_sshkey_info' module",
        version='2.13')

    core(module)
コード例 #6
0
def main():
    module = AnsibleModule(
        argument_spec=DigitalOceanHelper.digital_ocean_argument_spec(),
        supports_check_mode=False,
    )

    module.deprecate(
        "The 'digital_ocean_sshkey_facts' module has been deprecated, use the new 'digital_ocean_sshkey_info' module",
        version='3.0.0',
        collection_name='community.general')  # was Ansible 2.13

    core(module)
コード例 #7
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(
        certificate_id=dict(type='str', required=False),
    )
    module = AnsibleModule(argument_spec=argument_spec)
    if module._name in ('digital_ocean_certificate_facts', 'community.general.digital_ocean_certificate_facts'):
        module.deprecate("The 'digital_ocean_certificate_facts' module has been renamed to 'digital_ocean_certificate_info'", version='2.13')

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #8
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(
        name=dict(type='str', required=False),
    )
    module = AnsibleModule(argument_spec=argument_spec)
    if module._name == 'digital_ocean_firewall_facts':
        module.deprecate("The 'digital_ocean_firewall_facts' module has been renamed to 'digital_ocean_firewall_info'", version='2.13')

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #9
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec)
    if module._name in ('digital_ocean_account_facts',
                        'community.general.digital_ocean_account_facts'):
        module.deprecate(
            "The 'digital_ocean_account_facts' module has been renamed to 'digital_ocean_account_info'",
            version='3.0.0',
            collection_name='community.general')  # was Ansible 2.13
    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #10
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(
        name=dict(type='str', required=True),
        resource_id=dict(aliases=['droplet_id'], type='str'),
        resource_type=dict(choices=['droplet'], default='droplet'),
        state=dict(choices=['present', 'absent'], default='present'),
    )

    module = AnsibleModule(argument_spec=argument_spec)

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #11
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(state=dict(choices=['present', 'absent'],
                                    default='present'),
                         name=dict(type='str'),
                         id=dict(aliases=['droplet_id'], type='int'),
                         ip=dict(type='str'))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_one_of=(['id', 'name'], ),
    )

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=traceback.format_exc())
コード例 #12
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(
        image_type=dict(type='str',
                        required=False,
                        choices=['all', 'application', 'distribution', 'private'],
                        default='all'
                        )
    )

    module = AnsibleModule(argument_spec=argument_spec)
    if module._name == 'digital_ocean_image_facts':
        module.deprecate("The 'digital_ocean_image_facts' module has been renamed to 'digital_ocean_image_info'", version='2.13')

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e), exception=format_exc())
コード例 #13
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(name=dict(type='str'),
                         leaf_certificate=dict(type='str'),
                         private_key=dict(type='str', no_log=True),
                         state=dict(choices=['present', 'absent'],
                                    default='present'),
                         certificate_chain=dict(type='str'))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_if=[('state', 'present',
                      ['name', 'leaf_certificate', 'private_key']),
                     ('state', 'absent', ['name'])],
    )

    try:
        core(module)
    except Exception as e:
        module.fail_json(msg=to_native(e))
コード例 #14
0
def main():
    argument_spec = DigitalOceanHelper.digital_ocean_argument_spec()
    argument_spec.update(
        state=dict(choices=['present', 'absent'], required=True),
        command=dict(choices=['create', 'attach'], required=True),
        block_size=dict(type='int', required=False),
        volume_name=dict(type='str', required=True),
        description=dict(type='str'),
        region=dict(type='str', required=False),
        snapshot_id=dict(type='str', required=False),
        droplet_id=dict(type='int')
    )

    module = AnsibleModule(argument_spec=argument_spec)

    try:
        handle_request(module)
    except DOBlockStorageException as e:
        module.fail_json(msg=e.message, exception=traceback.format_exc())
    except KeyError as e:
        module.fail_json(msg='Unable to load %s' % e.message, exception=traceback.format_exc())