Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_scheduled_task/tasks/failures.yml

raw
1 # test out the known failure cases to ensure we have decent error messages
2 ---
3 # ensure we have good error messages for invalid task chars
4 - name: fail to create tasks with invalid characters
5 win_scheduled_task:
6 name: "Bad {{ item }} {{ test_scheduled_task_name }}"
7 state: present
8 actions:
9 - path: cmd.exe
10 arguments: /c echo hi
11 loop: "{{ test_scheduled_task_invalid_chars }}"
12 register: fail_invalid_chars
13 failed_when: fail_invalid_chars is not failed or fail_invalid_chars.msg is not search('The following characters are not valid')
14
15 - name: fail create task without an action
16 win_scheduled_task:
17 name: '{{test_scheduled_task_name}}'
18 state: present
19 register: fail_create_without_action
20 failed_when: fail_create_without_action.msg != 'cannot create a task with no actions, set at least one action with a path to an executable'
21
22 - name: fail both username and group are set
23 win_scheduled_task:
24 name: '{{test_scheduled_task_name}}'
25 state: present
26 username: '{{ansible_user}}'
27 group: '{{ansible_user}}'
28 register: fail_username_and_group
29 failed_when: fail_username_and_group.msg != 'username and group can not be set at the same time'
30
31 - name: fail logon type s4u but no password set
32 win_scheduled_task:
33 name: '{{test_scheduled_task_name}}'
34 state: present
35 logon_type: s4u
36 register: fail_lt_s4u_not_set
37 failed_when: fail_lt_s4u_not_set.msg != 'password must be set when logon_type=s4u'
38
39 - name: fail logon type group but no group set
40 win_scheduled_task:
41 name: '{{test_scheduled_task_name}}'
42 state: present
43 logon_type: group
44 register: fail_lt_group_not_set
45 failed_when: fail_lt_group_not_set.msg != 'group must be set when logon_type=group'
46
47 - name: fail logon type service but non service user set
48 win_scheduled_task:
49 name: '{{test_scheduled_task_name}}'
50 state: present
51 logon_type: service_account
52 username: '{{ansible_user}}'
53 register: fail_lt_service_invalid_user
54 failed_when: fail_lt_service_invalid_user.msg != 'username must be SYSTEM, LOCAL SERVICE or NETWORK SERVICE when logon_type=service_account'
55
56 - name: fail trigger with no type
57 win_scheduled_task:
58 name: '{{test_scheduled_task_name}}'
59 state: present
60 triggers:
61 - delay: test
62 register: fail_trigger_no_type
63 failed_when: fail_trigger_no_type.msg != "a trigger entry must contain a key 'type' with a value of 'event', 'time', 'daily', 'weekly', 'monthly', 'monthlydow', 'idle', 'registration', 'boot', 'logon', 'session_state_change'"
64
65 - name: fail trigger with datetime in incorrect format
66 win_scheduled_task:
67 name: '{{test_scheduled_task_name}}'
68 state: present
69 triggers:
70 - type: time
71 start_boundary: fake
72 register: fail_trigger_invalid_datetime
73 failed_when: fail_trigger_invalid_datetime.msg != "trigger option 'start_boundary' must be in the format 'YYYY-MM-DDThh:mm:ss' format but was 'fake'"
74
75 - name: fail trigger with duration in incorrect format
76 win_scheduled_task:
77 name: '{{test_scheduled_task_name}}'
78 state: present
79 triggers:
80 - type: boot
81 execution_time_limit: fake
82 register: fail_trigger_invalid_duration
83 failed_when: fail_trigger_invalid_duration.msg != "trigger option 'execution_time_limit' must be in the XML duration format but was 'fake'"
84
85 - name: fail trigger option invalid day of the week
86 win_scheduled_task:
87 name: '{{test_scheduled_task_name}}'
88 state: present
89 triggers:
90 - type: weekly
91 start_boundary: '2000-01-01T00:00:01'
92 days_of_week: fakeday
93 register: fail_trigger_invalid_day_of_week
94 failed_when: fail_trigger_invalid_day_of_week.msg != "invalid day of week 'fakeday', check the spelling matches the full day name"
95
96 - name: fail trigger option invalid day of the month
97 win_scheduled_task:
98 name: '{{test_scheduled_task_name}}'
99 state: present
100 triggers:
101 - type: monthly
102 start_boundary: '2000-01-01T00:00:01'
103 days_of_month: 35
104 register: fail_trigger_invalid_day_of_month
105 failed_when: fail_trigger_invalid_day_of_month.msg != "invalid day of month '35', please specify numbers from 1-31"
106
107 - name: fail trigger option invalid week of the month
108 win_scheduled_task:
109 name: '{{test_scheduled_task_name}}'
110 state: present
111 triggers:
112 - type: monthlydow
113 start_boundary: '2000-01-01T00:00:01'
114 weeks_of_month: 5
115 register: fail_trigger_invalid_week_of_month
116 failed_when: fail_trigger_invalid_week_of_month.msg != "invalid week of month '5', please specify weeks from 1-4"
117
118 - name: fail trigger option invalid month of the year
119 win_scheduled_task:
120 name: '{{test_scheduled_task_name}}'
121 state: present
122 triggers:
123 - type: monthlydow
124 start_boundary: '2000-01-01T00:00:01'
125 months_of_year: fakemonth
126 register: fail_trigger_invalid_month_of_year
127 failed_when: fail_trigger_invalid_month_of_year.msg != "invalid month name 'fakemonth', please specify full month name"
128
129 - name: fail trigger repetition with duration in incorrect format
130 win_scheduled_task:
131 name: '{{test_scheduled_task_name}}'
132 state: present
133 triggers:
134 - type: boot
135 repetition:
136 - duration: fake
137 register: fail_trigger_repetition_invalid_duration
138 failed_when: fail_trigger_repetition_invalid_duration.msg != "trigger option 'duration' must be in the XML duration format but was 'fake'"
139
140 - name: fail trigger repetition with interval in incorrect format
141 win_scheduled_task:
142 name: '{{test_scheduled_task_name}}'
143 state: present
144 triggers:
145 - type: boot
146 repetition:
147 - interval: fake
148 register: fail_trigger_repetition_invalid_interval
149 failed_when: fail_trigger_repetition_invalid_interval.msg != "trigger option 'interval' must be in the XML duration format but was 'fake'"
150
151 - name: fail trigger repetition option interval greater than duration
152 win_scheduled_task:
153 name: '{{test_scheduled_task_name}}'
154 state: present
155 triggers:
156 - type: boot
157 repetition:
158 - interval: PT5M
159 duration: PT1M
160 register: fail_trigger_repetition_interval_greater_than_duration
161 failed_when: fail_trigger_repetition_interval_greater_than_duration.msg != "trigger repetition option 'interval' value 'PT5M' must be less than or equal to 'duration' value 'PT1M'"