lowlydba.sqlserver.agent_job module – Configures a SQL Agent job

Note

This module is part of the lowlydba.sqlserver collection (version 2.3.2).

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.agent_job.

New in lowlydba.sqlserver 0.1.0

Synopsis

  • Configure a SQL Agent job, including which schedules and category it belongs to.

Requirements

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

Parameters

Parameter

Comments

category

string

Category for the target SQL Agent job. Must already exist.

description

string

Description for the SQL Agent job.

enabled

boolean

added in lowlydba.sqlserver 0.4.0

Whether the SQL Agent job should be enabled or disabled.

Choices:

  • false

  • true ← (default)

force

boolean

If force=true, any job categories will be created if they don’t exist already.

Choices:

  • false ← (default)

  • true

job

string / required

The name of the target SQL Agent job.

owner_login

string

The owning login for the database. Will default to the current user if the database is being created and none supplied.

schedule

string

The name of the schedule the job should be associated with. Only one schedule per job is supported.

sql_instance

string / required

The SQL Server instance to modify.

sql_password

string

Password for SQL Authentication.

sql_username

string

Username for SQL Authentication.

start_step_id

integer

What step number the job should begin with when run.

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.

Notes

Note

  • On slower hardware, stale job component data may be returned (i.e., a previous or default job category). Configuring each component (schedule, step, category, etc.) individually is recommended for this reason.

Examples

- name: Create a job
  lowlydba.sqlserver.agent_job:
    sql_instance: sql-01.myco.io
    job: MyJob
    force: true

Return Values

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

Key

Description

data

dictionary

Output from the New-DbaAgentJob, Set-DbaAgentJob, or Remove-DbaAgentJob function.

Returned: success, but not in check_mode.

Authors

  • John McCall (@lowlydba)