community.general.mssql_db (8.5.0) — module

Add or remove MSSQL databases from a remote host

Authors: Vedit Firat Arig (@vedit)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Add or remove MSSQL databases from a remote host.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new database with name 'jackdata'
  community.general.mssql_db:
    name: jackdata
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Copy database dump file to remote host and restore it to database 'my_db'
- name: Copy database dump file to remote host
  ansible.builtin.copy:
    src: dump.sql
    dest: /tmp
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Restore the dump file to database 'my_db'
  community.general.mssql_db:
    name: my_db
    state: import
    target: /tmp/dump.sql

Inputs

    
name:
    aliases:
    - db
    description:
    - name of the database to add or remove
    required: true
    type: str

state:
    choices:
    - present
    - absent
    - import
    default: present
    description:
    - The database state
    type: str

target:
    description:
    - Location, on the remote host, of the dump file to read from or write to. Uncompressed
      SQL files (C(.sql)) files are supported.
    type: str

autocommit:
    default: false
    description:
    - Automatically commit the change only if the import succeed. Sometimes it is necessary
      to use autocommit=true, since some content can't be changed within a transaction.
    type: bool

login_host:
    description:
    - Host running the database
    required: true
    type: str

login_port:
    default: '1433'
    description:
    - Port of the MSSQL server. Requires login_host be defined as other than localhost
      if login_port is used
    type: str

login_user:
    default: ''
    description:
    - The username used to authenticate with
    type: str

login_password:
    default: ''
    description:
    - The password used to authenticate with
    type: str