def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(msg='The Rubrik Python SDK is required for this module (pip install rubrik_cdm).')

    node_ip, username, password = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.get_all_vcenters()
    except SystemExit as error:
        module.fail_json(msg=str(error))
    #fixed
    module.exit_json(**api_request)
Exemple #2
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        managed_volume_name=dict(required=True, aliases=['name']),
        sla_name=dict(required=False, type='str', default="current"),
        action=dict(required=True, choices=['begin', 'end']),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    required_if = [('action', 'end', ['sla_name'])]

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    if ansible["action"] == "begin":
        try:
            api_request = rubrik.begin_managed_volume_snapshot(
                ansible["managed_volume_name"], ansible["timeout"])
        except Exception as error:
            module.fail_json(msg=str(error))

    else:
        try:
            api_request = rubrik.end_managed_volume_snapshot(
                ansible["managed_volume_name"], ansible["sla_name"],
                ansible["timeout"])
        except Exception as error:
            module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #3
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        vcenter_ip=dict(required=True, type='str'),
        vcenter_username=dict(required=True, type='str'),
        vcenter_password=dict(required=True, type='str'),
        vm_linking=dict(required=False, default=True, type='bool'),
        ca_certificate=dict(required=False, type='str'),
        timeout=dict(required=False, type='int', default=30),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    vcenter_ip = ansible["vcenter_ip"]
    vcenter_username = ansible["vcenter_username"]
    vcenter_password = ansible["vcenter_password"]
    vm_linking = ansible["vm_linking"]
    ca_certificate = ansible["ca_certificate"]
    timeout = ansible["timeout"]

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.add_vcenter(vcenter_ip, vcenter_username,
                                         vcenter_password, vm_linking,
                                         ca_certificate, timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #4
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        object_name=dict(required=True, type='str'),
        end_user=dict(required=True, type='str'),
        object_type=dict(required=False,
                         type='str',
                         default="vmware",
                         choices=['vmware']),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    object_name = ansible["object_name"]
    end_user = ansible["end_user"]
    object_type = ansible["object_type"]
    timeout = ansible["timeout"]

    try:
        api_request = rubrik.end_user_authorization(object_name, end_user,
                                                    object_type, timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #5
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = rubrik_argument_spec

    # Start Parameters
    argument_spec.update(
        dict(
            hostID=dict(required=True, type='string'),
            shareType=dict(required=True, type='string'),
            exportPoint=dict(required=True, type='String'),
            fileshareusername=dict(required=False, type='string', default="blank"),
            filesharepassword=dict(required=False, type='string', default="blank"),
            domain=dict(required=False, type='string', default="blank"),

        )
    )
    # End Parameters

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(msg='The Rubrik Python SDK is required for this module (pip install rubrik_cdm).')

    try:
        node_ip, username, password = credentials(module)
    except ValueError:
        module.fail_json(msg="The Rubrik login credentials are missing. Verify the correct env vars are present or provide them through the `provider` param.")

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.new_NasShare(ansible["hostID"], ansible["shareType"], ansible["exportPoint"],
                                                ansible["fileshareusername"], ansible["filesharepassword"], ansible["domain"])

    except SystemExit as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #6
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = rubrik_argument_spece

    # Start Parameters
    argument_spec.update(
        dict(
            timeout=dict(required=False, type='int', default=15),

        )
    )
    # End Parameters

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(msg='The Rubrik Python SDK is required for this module (pip install rubrik_cdm).')

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    ##################################
    ######### Code Block #############
    ##################################
    ##################################

    try:
        api_request = rubrik.
    except SystemExit as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        hostname=dict(required=True, aliases=['ip_address']),
        action=dict(required=True, choices=['add', 'delete']),
        timeout=dict(required=False, type='int', default=120),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    if ansible["action"] == "add":
        try:
            api_request = rubrik.add_physical_host(ansible["hostname"],
                                                   ansible["timeout"])
        except SystemExit as error:
            module.fail_json(msg=str(error))
    else:
        try:
            api_request = rubrik.delete_physical_host(ansible["hostname"],
                                                      ansible["timeout"])
        except SystemExit as error:
            module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        organization_name=dict(required=True, type='str'),
        mssql_host=dict(required=True, type='str'),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    organization_name = ansible["organization_name"]
    mssql_host = ansible["mssql_host"]
    timeout = ansible["timeout"]

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.add_organization_protectable_object_mssql_server_host(
            organization_name, mssql_host, timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        db_name=dict(required=True, type='str'),
        date=dict(required=True, type='str'),
        time=dict(required=True, type='str'),
        sql_instance=dict(required=True, type='str'),
        sql_host=dict(required=True, type='str'),
        mount_name=dict(required=True, type='str'),
        timeout=dict(required=False, type='int', default=30),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.sql_live_mount(ansible["db_name"],
                                            ansible["date"], ansible["time"],
                                            ansible["sql_instance"],
                                            ansible["sql_host"],
                                            ansible["mount_name"],
                                            ansible["timeout"])
    except Exception as error:
        module.fail_json(msg=str(error))

    results["response"] = api_request

    module.exit_json(**results)
Exemple #10
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(url=dict(required=True),
                         wait_for_completion=dict(required=False,
                                                  type='bool',
                                                  default=True),
                         timeout=dict(required=False, type='int', default=15))

    # Start Parameters
    argument_spec.update(rubrik_argument_spec)
    # End Parameters

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.job_status(ansible["url"],
                                        ansible["wait_for_completion"],
                                        ansible["timeout"])
    except Exception as error:
        module.fail_json(msg=str(error))

    results["changed"] = False

    results["response"] = api_request

    module.exit_json(**results)
Exemple #11
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        server_ip=dict(required=True, type='list'),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.configure_dns_servers(ansible["server_ip"],
                                                   ansible["timeout"])
    except SystemExit as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        api_version=dict(required=True, type='str', choices=['v1', 'v2', 'internal']),
        api_endpoint=dict(required=True, type='str'),
        config=dict(required=True, type='raw'),
        authentication=dict(required=False, type='bool', default=True),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(msg='The Rubrik Python SDK is required for this module (pip install rubrik_cdm).')

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token, enable_logging=True)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.post(ansible["api_version"], ansible["api_endpoint"], ansible["config"], ansible["timeout"], ansible["authentication"])
    except Exception as error:
        module.fail_json(msg=str(error))

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    argument_spec = dict(
        object_name=dict(required=True, type='str'),
        object_type=dict(required=False,
                         type='str',
                         default="vmware",
                         choices=["vmware", "physical_host", "ahv"]),
        sla_name=dict(required=False, type='str', default='current'),
        fileset=dict(required=False, type='str', default='None'),
        host_os=dict(required=False,
                     type='str',
                     default='None',
                     hoices=["None", "Linux", "Windows"]),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    results = {}

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password = credentials(module)

    rubrik = rubrik_cdm.Connect(node_ip, username, password)

    if ansible["fileset"] == "None":
        ansible["fileset"] = None

    if ansible["host_os"] == "None":
        ansible["host_os"] = None

    object_name = ansible["object_name"]
    object_type = ansible["object_type"]
    sla_name = ansible["sla_name"]
    fileset = ansible["fileset"]
    host_os = ansible["host_os"]

    try:
        api_request, job_status_url = rubrik.on_demand_snapshot(
            object_name, object_type, sla_name, fileset, host_os)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    results["changed"] = True

    results["response"] = api_request
    results["job_status_url"] = job_status_url

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        fileset_name=dict(required=True, aliases=['name']),
        operating_system=dict(required=True, choices=['Linux', 'Windows']),
        include=dict(required=False, type='list', default=[]),
        exclude=dict(required=False, type='list', default=[]),
        exclude_exception=dict(required=False, type='list', default=[]),
        follow_network_shares=dict(required=False, type='bool', default=False),
        backup_hidden_folders=dict(required=False, type='bool', default=False),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(msg='The Rubrik Python SDK is required for this module (pip install rubrik_cdm).')

    node_ip, username, password = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password)
    except SystemExit as error:
        module.fail_json(msg=str(error))

    fileset_name = ansible["fileset_name"]
    operating_system = ansible["operating_system"]
    include = ansible["include"]
    exclude = ansible["exclude"]
    exclude_exception = ansible["exclude_exception"]
    follow_network_shares = ansible["follow_network_shares"]
    backup_hidden_folders = ansible["backup_hidden_folders"]
    timeout = ansible["timeout"]

    try:
        api_request = rubrik.create_physical_fileset(
            fileset_name,
            operating_system,
            include,
            exclude,
            exclude_exception,
            follow_network_shares,
            backup_hidden_folders,
            timeout)

    except SystemExit as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        hostname=dict(required=True, type='str'),
        port=dict(required=True, type='int'),
        from_email=dict(required=True, type='str'),
        smtp_username=dict(required=True, type='str'),
        smtp_password=dict(required=True, type='str', no_log=True),
        encryption=dict(required=False,
                        type='str',
                        default="NONE",
                        choices=["NONE", "SSL", "STARTTLS"]),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    hostname = ansible["hostname"]
    port = ansible["port"]
    from_email = ansible["from_email"]
    smtp_username = ansible["smtp_username"]
    smtp_password = ansible["smtp_password"]
    encryption = ansible["encryption"]
    timeout = ansible["timeout"]

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.configure_smtp_settings(hostname, port,
                                                     from_email, smtp_username,
                                                     smtp_password, encryption,
                                                     timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #16
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        cluster_name=dict(required=True, type='str'),
        admin_email=dict(required=True, type='str'),
        admin_password=dict(required=True, type='str', no_log=True),
        management_gateway=dict(required=True, type='str'),
        management_subnet_mask=dict(required=True, type='str'),
        node_config=dict(required=True, type='dict'),
        enable_encryption=dict(required=False, type='bool', default=True),
        dns_search_domains=dict(required=False, type='list', default=[]),
        dns_nameservers=dict(required=False, type='list', default=['8.8.8.8']),
        ntp_servers=dict(required=False, type='list',
                         default=['pool.ntp.org']),
        wait_for_completion=dict(required=False, type='bool', default=True),
        timeout=dict(required=False, type='int', default=30),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Bootstrap(node_ip)
    except Exception as error:
        module.fail_json(msg=str(error))

    cluster_name = ansible["cluster_name"]
    admin_email = ansible["admin_email"]
    admin_password = ansible["admin_password"]
    management_gateway = ansible["management_gateway"]
    management_subnet_mask = ansible["management_subnet_mask"]
    node_config = ansible["node_config"]
    enable_encryption = ansible["enable_encryption"]
    dns_search_domains = ansible["dns_search_domains"]
    dns_nameservers = ansible["dns_nameservers"]
    ntp_servers = ansible["ntp_servers"]
    wait_for_completion = ansible["wait_for_completion"]
    timeout = ansible["timeout"]

    try:
        api_request = rubrik.setup_cluster(cluster_name,
                                           admin_email,
                                           admin_password,
                                           management_gateway,
                                           management_subnet_mask,
                                           node_config,
                                           enable_encryption,
                                           dns_search_domains,
                                           dns_nameservers,
                                           ntp_servers,
                                           wait_for_completion,
                                           timeout=timeout)

    except Exception as error:
        module.fail_json(msg=str(error))

    results["response"] = api_request

    module.exit_json(**results)
Exemple #17
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict()

    argument_spec.update(rubrik_argument_spec)

    argument_spec.update(
        dict(
            hostname=dict(required=True, type='str', aliases=['ip_address']),
            fileset_name=dict(required=True, type='str'),
            sla_name=dict(required=True, type='str', aliases=['sla']),
            operating_system=dict(required=True,
                                  type='str',
                                  choices=['Linux', 'Windows', 'UnixLike']),
            include=dict(required=False, type='list', default=[]),
            exclude=dict(required=False, type='list', default=[]),
            exclude_exception=dict(required=False, type='list', default=[]),
            follow_network_shares=dict(required=False,
                                       type='bool',
                                       default=False),
            backup_hidden_folders=dict(required=False,
                                       type='bool',
                                       default=False),
            timeout=dict(required=False, type='int', default=30),
        ))

    required_together = [[
        "include", "exclude", "exclude_exception", "follow_network_shares",
        "backup_hidden_folders"
    ]]

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=required_together,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    # If there are multiple Filesets on the cluster with the same name the end
    # use will need to provide more specific information. That only occurs
    # when includes != None
    if bool(ansible['include']) is False:

        try:
            api_request = rubrik.assign_physical_host_fileset(
                ansible['hostname'],
                ansible['fileset_name'],
                ansible['operating_system'],
                ansible['sla_name'],
                timeout=ansible["timeout"])
        except Exception as error:
            module.fail_json(msg=str(error))

    else:

        try:
            api_request = rubrik.assign_physical_host_fileset(
                ansible['hostname'], ansible['fileset_name'],
                ansible['operating_system'], ansible['sla_name'],
                ansible["include"], ansible["exclude"],
                ansible["exclude_exception"], ansible["follow_network_shares"],
                ansible["backup_hidden_folders"], ansible["timeout"])
        except Exception as error:
            module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        aws_bucket_name=dict(required=True, type='str'),
        aws_region=dict(required=False,
                        type='str',
                        choices=[
                            "ap-south-1", "ap-northeast-2", "ap-southeast-1",
                            "ap-southeast-2", "ap-northeast-1", "ca-central-1",
                            "cn-north-1", "cn-northwest-1", "eu-central-1",
                            "eu-west-1", "eu-west-2", "eu-west-3", "sa-east-1",
                            "us-gov-west-1", "us-west-1", "us-east-1",
                            "us-east-2", "us-west-2"
                        ]),
        aws_access_key=dict(required=False, type='str'),
        aws_secret_key=dict(required=False, type='str'),
        kms_master_key_id=dict(required=False, type='str'),
        rsa_key=dict(required=False, type='str'),
        archive_name=dict(required=False, type='str'),
        storage_class=dict(
            required=False,
            default="standard",
            type='str',
            choices=["standard", "standard_ia", "reduced_redundancy"]),
        timeout=dict(required=False, type='int', default=180),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    aws_bucket_name = ansible["aws_bucket_name"]
    aws_region = ansible["aws_region"]
    aws_access_key = ansible["aws_access_key"]
    aws_secret_key = ansible["aws_secret_key"]
    kms_master_key_id = ansible["kms_master_key_id"]
    rsa_key = ansible["rsa_key"]
    archive_name = ansible["archive_name"]
    storage_class = ansible["storage_class"]
    timeout = ansible["timeout"]

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.aws_s3_cloudout(aws_bucket_name, archive_name,
                                             aws_region, aws_access_key,
                                             aws_secret_key, kms_master_key_id,
                                             rsa_key, storage_class, timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #19
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        timezone=dict(
            required=True,
            type='str',
            choices=[
                'America/Anchorage', 'America/Araguaina', 'America/Barbados',
                'America/Chicago', 'America/Denver', 'America/Los_Angeles',
                'America/Mexico_City', 'America/New_York', 'America/Noronha',
                'America/Phoenix', 'America/Toronto', 'America/Vancouver',
                'Asia/Bangkok', 'Asia/Dhaka', 'Asia/Dubai', 'Asia/Hong_Kong',
                'Asia/Karachi', 'Asia/Kathmandu', 'Asia/Kolkata',
                'Asia/Magadan', 'Asia/Singapore', 'Asia/Tokyo',
                'Atlantic/Cape_Verde', 'Australia/Perth', 'Australia/Sydney',
                'Europe/Amsterdam', 'Europe/Athens', 'Europe/London',
                'Europe/Moscow', 'Pacific/Auckland', 'Pacific/Honolulu',
                'Pacific/Midway', 'UTC'
            ]),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.configure_timezone(ansible["timezone"],
                                                ansible["timeout"])
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #20
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        name=dict(required=True, type='str'),
        hourly_frequency=dict(required=False, default=None, type='int'),
        hourly_retention=dict(required=False, default=None, type='int'),
        daily_frequency=dict(required=False, default=None, type='int'),
        daily_retention=dict(required=False, default=None, type='int'),
        monthly_frequency=dict(required=False, default=None, type='int'),
        monthly_retention=dict(required=False, default=None, type='int'),
        yearly_frequency=dict(required=False, default=None, type='int'),
        yearly_retention=dict(required=False, default=None, type='int'),
        archive_name=dict(required=False, default=None, type='str'),
        retention_on_brik_in_days=dict(required=False, default=None, type='int'),
        instant_archive=dict(required=False, default=False, type='bool'),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    name = ansible["name"]
    hourly_frequency = ansible["hourly_frequency"]
    hourly_retention = ansible["hourly_retention"]
    daily_frequency = ansible["daily_frequency"]
    daily_retention = ansible["daily_retention"]
    monthly_frequency = ansible["monthly_frequency"]
    monthly_retention = ansible["monthly_retention"]
    yearly_frequency = ansible["yearly_frequency"]
    yearly_retention = ansible["yearly_retention"]
    archive_name = ansible["archive_name"]
    retention_on_brik_in_days = ansible["retention_on_brik_in_days"]
    instant_archive = ansible["instant_archive"]
    timeout = ansible["timeout"]

    if not HAS_RUBRIK_SDK:
        module.fail_json(msg='The Rubrik Python SDK is required for this module (pip install rubrik_cdm).')

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.create_sla(
            name,
            hourly_frequency,
            hourly_retention,
            daily_frequency,
            daily_retention,
            monthly_frequency,
            monthly_retention,
            yearly_frequency,
            yearly_retention,
            archive_name,
            retention_on_brik_in_days,
            instant_archive,
            timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
Exemple #21
0
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        object_name=dict(required=True, type='str'),
        sla_name=dict(required=True, type='str'),
        object_type=dict(required=False,
                         type='str',
                         default="vmware",
                         choices=['vmware', 'mssql_host']),
        log_backup_frequency_in_seconds=dict(required=False,
                                             default=None,
                                             type='int'),
        log_retention_hours=dict(required=False, default=None, type='int'),
        copy_only=dict(required=False, default=None, type='bool'),
        timeout=dict(required=False, type='int', default=30),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    object_name = ansible["object_name"]
    sla_name = ansible["sla_name"]
    object_type = ansible["object_type"]
    log_backup_frequency_in_seconds = ansible[
        "log_backup_frequency_in_seconds"]
    log_retention_hours = ansible["log_retention_hours"]
    copy_only = ansible["copy_only"]
    timeout = ansible["timeout"]

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    if object_type == "mssql_host":
        if log_backup_frequency_in_seconds is None or log_retention_hours is None or log_retention_hours is None:
            module.fail_json(
                msg=
                "When the object_type is 'mssql_host' the 'log_backup_frequency_in_seconds', 'log_retention_hours', 'copy_only' paramaters must be populated."
            )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    try:
        api_request = rubrik.assign_sla(object_name, sla_name, object_type,
                                        log_backup_frequency_in_seconds,
                                        log_retention_hours, copy_only,
                                        timeout)
    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)
def main():
    """ Main entry point for Ansible module execution.
    """

    results = {}

    argument_spec = dict(
        fileset_name=dict(required=True, aliases=['name']),
        share_type=dict(required=True, choices=['NFS', 'SMB']),
        include=dict(required=False, type='list', elements='str', default=[]),
        exclude=dict(required=False, type='list', elements='str', default=[]),
        exclude_exception=dict(required=False,
                               type='list',
                               elements='str',
                               default=[]),
        follow_network_shares=dict(required=False, type='bool', default=False),
        timeout=dict(required=False, type='int', default=15),
    )

    argument_spec.update(rubrik_argument_spec)

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    ansible = module.params

    load_provider_variables(module)

    if not HAS_RUBRIK_SDK:
        module.fail_json(
            msg=
            'The Rubrik Python SDK is required for this module (pip install rubrik_cdm).'
        )

    node_ip, username, password, api_token = credentials(module)

    try:
        rubrik = rubrik_cdm.Connect(node_ip, username, password, api_token)
    except Exception as error:
        module.fail_json(msg=str(error))

    fileset_name = ansible["fileset_name"]
    share_type = ansible["share_type"]
    include = ansible["include"]
    exclude = ansible["exclude"]
    exclude_exception = ansible["exclude_exception"]
    follow_network_shares = ansible["follow_network_shares"]
    timeout = ansible["timeout"]

    try:
        api_request = rubrik.create_nas_fileset(fileset_name, share_type,
                                                include, exclude,
                                                exclude_exception,
                                                follow_network_shares, timeout)

    except Exception as error:
        module.fail_json(msg=str(error))

    if "No change required" in api_request:
        results["changed"] = False
    else:
        results["changed"] = True

    results["response"] = api_request

    module.exit_json(**results)