lowlydba.sqlserver.login_role module – Configures a login’s server roles.

Note

This module is part of the lowlydba.sqlserver collection (version 2.5.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.login_role.

New in lowlydba.sqlserver 2.5.0

Synopsis

  • Adds or removes a login’s server role.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter

Comments

login

string / required

Name of the login.

server_role

string / required

The server role for the login to be modified.

sql_instance

string / required

The SQL Server instance to modify.

sql_password

string

Password for SQL Authentication.

sql_username

string

Username for SQL Authentication.

state

string

Whether or not the object should be present or absent.

Choices:

  • "present" ← (default)

  • "absent"

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

platform

Platforms: all

Target OS/families that can be operated against.

Examples

- name: Add a user to a fixed server role
  lowlydba.sqlserver.login_role:
    sql_instance: sql-01.myco.io
    login: TheIntern
    server_role: sysadmin

- name: Remove a user from a fixed server role
  lowlydba.sqlserver.login_role:
    sql_instance: sql-01.myco.io
    login: TheIntern
    server_role: sysadmin
    state: absent

- name: Add a user to a custom server role
  lowlydba.sqlserver.login_role:
    sql_instance: sql-01.myco.io
    login: TheIntern
    server_role: demi-admin

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

data

dictionary

Output from the Remove-DbaServerRoleMember, (Get-DbaServerRoleMember), or Add-DbaServerRoleMember functions.

Returned: success, but not in check_mode.

Authors

  • John McCall (@lowlydba)