Debian Codegraph @

ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # (c) 2022, John McCall (@lowlydba)
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r'''
8 ---
9 module: agent_job_step
10 short_description: Configures a SQL Agent job step
11 description:
12 - Configures a step for an agent job.
13 version_added: 0.1.0
14 options:
15 job:
16 description:
17 - The name of the job to which to add the step.
18 required: true
19 type: str
20 step_id:
21 description:
22 - The sequence identification number for the job step. Step identification numbers start at C(1) and increment without gaps.
23 - Required if I(state=present).
24 required: false
25 type: int
26 step_name:
27 description:
28 - The name of the step. Required if I(state=present).
29 required: false
30 type: str
31 database:
32 description:
33 - The name of the database in which to execute a Transact-SQL step.
34 required: false
35 type: str
36 default: 'master'
37 subsystem:
38 description:
39 - The subsystem used by the SQL Server Agent service to execute command.
40 required: false
41 type: str
42 default: 'TransactSql'
43 choices: ['CmdExec', 'Distribution', 'LogReader', 'Merge', 'PowerShell', 'QueueReader', 'Snapshot', 'Ssis', 'TransactSql']
44 command:
45 description:
46 - The commands to be executed by SQLServerAgent service through subsystem.
47 required: false
48 type: str
49 on_success_action:
50 description:
51 - The action to perform if the step succeeds.
52 required: false
53 type: str
54 default: 'QuitWithSuccess'
55 choices: ['QuitWithSuccess', 'QuitWithFailure', 'GoToNextStep', 'GoToStep']
56 on_success_step_id:
57 description:
58 - The ID of the step in this job to execute if the step succeeds and I(on_success_action=GoToStep).
59 required: false
60 type: int
61 default: 0
62 on_fail_action:
63 description:
64 - The action to perform if the step fails.
65 required: false
66 type: str
67 default: 'QuitWithFailure'
68 choices: ['QuitWithSuccess', 'QuitWithFailure', 'GoToNextStep', 'GoToStep']
69 on_fail_step_id:
70 description:
71 - The ID of the step in this job to execute if the step fails and I(on_fail_action=GoToStep).
72 required: false
73 type: int
74 default: 0
75 retry_attempts:
76 description:
77 - The number of retry attempts to use if this step fails. The default is C(0).
78 required: false
79 type: int
80 default: 0
81 retry_interval:
82 description:
83 - The amount of time in minutes between retry attempts.
84 required: false
85 type: int
86 default: 0
87 output_file:
88 description:
89 - The full path to the output file for the job step.
90 - This specifies where the output of the job step will be written.
91 version_added: 2.7.0
92 required: false
93 type: str
94 author: "John McCall (@lowlydba)"
95 requirements:
96 - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
97 extends_documentation_fragment:
98 - lowlydba.sqlserver.sql_credentials
99 - lowlydba.sqlserver.attributes.check_mode
100 - lowlydba.sqlserver.attributes.platform_all
101 - lowlydba.sqlserver.state
102 '''
103
104 EXAMPLES = r'''
105 - name: Create a job
106 lowlydba.sqlserver.agent_job:
107 sql_instance: sql-01.myco.io
108 job: MyJob
109 force: true
110
111 - name: Create a job step
112 lowlydba.sqlserver.agent_job_step:
113 sql_instance: sql-01.myco.io
114 job: MyJob
115 step_name: Step1
116 step_id: 1
117 command: "TRUNCATE TABLE dbo.TestData;"
118
119 - name: Create a job step with output file
120 lowlydba.sqlserver.agent_job_step:
121 sql_instance: sql-01.myco.io
122 job: MyJob
123 step_name: Step2
124 step_id: 2
125 command: "SELECT * FROM sys.databases;"
126 output_file: "C:\\Logs\\MyJob_Step2.log"
127 '''
128
129 RETURN = r'''
130 data:
131 description: Output from the C(New-DbaAgentJobStep), C(Set-DbaAgentJobStep), or C(Remove-DbaAgentJobStep) function.
132 returned: success, but not in check_mode.
133 type: dict
134 '''