lowlydba.sqlserver.user_role module – Configures a user’s role in a database.
Note
This module is part of the lowlydba.sqlserver collection (version 2.7.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install lowlydba.sqlserver.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: lowlydba.sqlserver.user_role.
New in lowlydba.sqlserver 2.4.0
Synopsis
- Adds or removes a user’s role in a database. 
Requirements
The below requirements are needed on the host that executes this module.
- dbatools PowerShell module 
Parameters
| Parameter | Comments | 
|---|---|
| Database for the user. | |
| The database role for the user to be modified. | |
| The SQL Server instance to modify. | |
| Password for SQL Authentication. | |
| Username for SQL Authentication. | |
| Whether or not the object should be  Choices: 
 | |
| Name of the user. | 
Attributes
| Attribute | Support | Description | 
|---|---|---|
| Support: full | Can run in check_mode and return changed status prediction without modifying target. | |
| Platforms: all | Target OS/families that can be operated against. | 
Examples
- name: Add a user to a fixed db role
  lowlydba.sqlserver.user_role:
    sql_instance: sql-01.myco.io
    username: TheIntern
    database: InternProject1
    role: db_owner
- name: Remove a user from a fixed db role
  lowlydba.sqlserver.login:
    sql_instance: sql-01.myco.io
    username: TheIntern
    database: InternProject1
    role: db_owner
    state: absent
- name: Add a user to a custom db role
  lowlydba.sqlserver.login:
    sql_instance: sql-01.myco.io
    username: TheIntern
    database: InternProject1
    role: db_intern
    state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| Output from the  Returned: success, but not in check_mode. | 
