Debian Codegraph @

ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.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_schedule
10 short_description: Configures a SQL Agent job schedule
11 description:
12 - Configures settings for an agent schedule that can be applied to one or more agent jobs.
13 version_added: 0.1.0
14 options:
15 schedule:
16 description:
17 - The name of the schedule.
18 type: str
19 required: true
20 job:
21 description:
22 - The name of the job that has the schedule.
23 - Schedules and jobs can also be associated via M(lowlydba.sqlserver.agent_job).
24 - See U(https://docs.dbatools.io/New-DbaAgentSchedule) for more detailed usage.
25 type: str
26 required: true
27 enabled:
28 description:
29 - Whether the schedule is enabled or disabled.
30 type: bool
31 required: false
32 force:
33 description:
34 - The force option will ignore some errors in the options and assume defaults.
35 - It will also remove the any present schedules with the same name for the specific job.
36 type: bool
37 frequency_type:
38 description:
39 - A value indicating when a job is to be executed.
40 - If I(force=true) the default will be C(Once).
41 type: str
42 required: false
43 choices: ['Once', 'OneTime', 'Daily', 'Weekly', 'Monthly', 'MonthlyRelative', 'AgentStart', 'AutoStart', 'IdleComputer', 'OnIdle']
44 frequency_interval:
45 description:
46 - The days that a job is executed.
47 - Allowed values for I(frequency_type=Daily) - C(EveryDay) or a number between C(1) and C(365) inclusive.
48 - >-
49 Allowed values for I(frequency_type=Weekly) -
50 C(Sunday), C(Monday), C(Tuesday), C(Wednesday), C(Thursday), C(Friday), C(Saturday),
51 C(Weekdays), C(Weekend) or C(EveryDay).
52 - Allowed values for I(frequency_type=Monthly) - Numbers C(1) through C(31) for each day of the month.
53 - If C(Weekdays), C(Weekend) or C(EveryDay) is used it overwrites any other value that has been passed before.
54 - If I(force=true) the default will be C(1).
55 type: str
56 required: false
57 frequency_subday_type:
58 description:
59 - Specifies the units for the subday I(frequency_interval).
60 type: str
61 required: false
62 choices: ['Time', 'Seconds', 'Minutes', 'Hours']
63 frequency_subday_interval:
64 description:
65 - The number of subday type periods to occur between each execution of a job.
66 type: int
67 required: false
68 frequency_relative_interval:
69 description:
70 - A job's occurrence of I(frequency_interval) in each month. If I(frequency_interval=32) (C(MonthlyRelative)).
71 type: str
72 required: false
73 choices: ['Unused', 'First', 'Second', 'Third', 'Fourth', 'Last']
74 frequency_recurrence_factor:
75 description:
76 - The number of weeks or months between the scheduled execution of a job.
77 - Required if I(frequency_type=Weekly), I(frequency_type=Monthly) or I(frequency_type=MonthlyRelative).
78 type: int
79 required: false
80 start_date:
81 description:
82 - The date on which execution of a job can begin.
83 - If I(force=true) the start date will be the current day.
84 - Format is C(yyyyMMdd).
85 type: str
86 required: false
87 end_date:
88 description:
89 - The date on which execution of a job can stop.
90 - If I(force=true) the end date will be C(99991231), via dbatools.
91 - Format is C(yyyyMMdd).
92 type: str
93 required: false
94
95 start_time:
96 description:
97 - The time on any day to begin execution of a job. Format C(HHMMSS) (24 hour clock).
98 - If I(force=true) the start time will be C(00:00:00).
99 type: str
100 required: false
101 end_time:
102 description:
103 - The time on any day to end execution of a job. Format C(HHMMSS) (24 hour clock).
104 - If (force=true) the start time will be C(23:59:59).
105 type: str
106 required: false
107 author: "John McCall (@lowlydba)"
108 requirements:
109 - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
110 extends_documentation_fragment:
111 - lowlydba.sqlserver.sql_credentials
112 - lowlydba.sqlserver.attributes.check_mode
113 - lowlydba.sqlserver.attributes.platform_all
114 - lowlydba.sqlserver.state
115 '''
116
117 EXAMPLES = r'''
118 - name: Create a job schedule
119 lowlydba.sqlserver.agent_job_schedule:
120 sql_instance: sql-01.myco.io
121 schedule: DailySchedule
122 force: true
123 enabled: true
124 start_date: 2020-05-25 # May 25, 2020
125 end_date: 2099-05-25 # May 25, 2099
126 start_time: 010500 # 01:05:00 AM
127 end_time: 140030 # 02:00:30 PM
128 state: present
129
130 - name: Create a job with schedule
131 lowlydba.sqlserver.agent_job:
132 sql_instance: sql-01.myco.io
133 job: MyJob
134 force: true
135 schedule: DailySchedule
136 '''
137
138 RETURN = r'''
139 data:
140 description: Output from the C(New-DbaAgentJobSchedule) or C(Remove-DbaAgentJobSchedule) function.
141 returned: success, but not in check_mode.
142 type: dict
143 '''