def delete_role(module, blade): """Delete Directory Service Role""" changed = False try: role = DirectoryServiceRole(group_base='', group='') blade.directory_services.update_directory_services_roles( names=[module.params['role']], directory_service_role=role) changed = True except Exception: module.fail_json(msg='Delete Directory Service Role {0} failed'.format( module.params['role'])) module.exit_json(changed=changed)
def delete_role(module, blade): """Delete Directory Service Role""" changed = True if not module.check_mode: try: role = DirectoryServiceRole(group_base="", group="") blade.directory_services.update_directory_services_roles( names=[module.params["role"]], directory_service_role=role) except Exception: module.fail_json(msg="Delete Directory Service Role {0} failed". format(module.params["role"])) module.exit_json(changed=changed)
def create_role(module, blade): """Create Directory Service Role""" changed = False try: role = DirectoryServiceRole(group_base=module.params['group_base'], group=module.params['group']) blade.directory_services.update_directory_services_roles(names=[module.params['role']], directory_service_role=role) changed = True except Exception: module.fail_json(msg='Create Directory Service Role {0} failed: Check configuration'.format(module.params['role'])) module.exit_json(changed=changed)
def update_role(module, blade): """Update Directory Service Role""" changed = False role = blade.directory_services.list_directory_services_roles(names=[module.params['role']]) if role.items[0].group_base != module.params['group_base'] or role.items[0].group != module.params['group']: try: role = DirectoryServiceRole(group_base=module.params['group_base'], group=module.params['group']) blade.directory_services.update_directory_services_roles(names=[module.params['role']], directory_service_role=role) changed = True except Exception: module.fail_json(msg='Update Directory Service Role {0} failed'.format(module.params['role'])) module.exit_json(changed=changed)
def update_role(module, blade): """Update Directory Service Role""" changed = False role = blade.directory_services.list_directory_services_roles( names=[module.params["role"]]) if (role.items[0].group_base != module.params["group_base"] or role.items[0].group != module.params["group"]): changed = True if not module.check_mode: try: role = DirectoryServiceRole( group_base=module.params["group_base"], group=module.params["group"]) blade.directory_services.update_directory_services_roles( names=[module.params["role"]], directory_service_role=role) except Exception: module.fail_json( msg="Update Directory Service Role {0} failed".format( module.params["role"])) module.exit_json(changed=changed)