summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/windows-paths/tasks/main.yml
blob: 4d222659161d6facd8fa64fecc63e592f30bb3e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
- name: Set variables in YAML syntax
  set_fact:
    no_quotes_single: C:\Windows\Temp
    single_quotes_single: 'C:\Windows\Temp'
#    double_quotes_single: "C:\Windows\Temp"
    no_quotes_double: C:\\Windows\\Temp
    single_quotes_double: 'C:\\Windows\\Temp'
    double_quotes_double: "C:\\Windows\\Temp"
    no_quotes_slash: C:/Windows/Temp
    no_quotes_trailing: C:\Windows\Temp\
    single_quotes_trailing: 'C:\Windows\Temp\'
#    double_quotes_trailing: "C:\Windows\Temp\"
    good: C:\Windows\Temp
    works1: C:\\Windows\\Temp
    works2: C:/Windows/Temp
#    fail: "C:\Windows\Temp"
    trailing: C:\Windows\Temp\
  register: yaml_syntax

- assert:
    that:
    - no_quotes_single == good
    - single_quotes_single == good
#    - double_quotes_single == fail
    - no_quotes_double == works1
    - single_quotes_double == works1
    - double_quotes_double == good
    - no_quotes_slash == works2
    - no_quotes_trailing == trailing
    - single_quotes_trailing == trailing
#    - double_quotes_trailing == fail
    - good != works1
    - good != works2
    - good != trailing
    - works1 != works2
    - works1 != trailing
    - works2 != trailing

- name: Test good path {{ good }}
  win_stat:
    path: '{{ good }}'
  register: good_result

- assert:
    that:
    - good_result is successful
    - good_result.stat.attributes == 'Directory'
    - good_result.stat.exists == true
    - good_result.stat.path == good

- name: Test works1 path {{ works1 }}
  win_stat:
    path: '{{ works1 }}'
  register: works1_result

- assert:
    that:
    - works1_result is successful
    - works1_result.stat.attributes == 'Directory'
    - works1_result.stat.exists == true
    - works1_result.stat.path == good

- name: Test works2 path {{ works2 }}
  win_stat:
    path: '{{ works2 }}'
  register: works2_result

- assert:
    that:
    - works2_result is successful
    - works2_result.stat.attributes == 'Directory'
    - works2_result.stat.exists == true
    - works2_result.stat.path == good

- name: Test trailing path {{ trailing }}
  win_stat:
    path: '{{ trailing }}'
  register: trailing_result

- assert:
    that:
    - trailing_result is successful
    - trailing_result.stat.attributes == 'Directory'
    - trailing_result.stat.exists == true
    - trailing_result.stat.path == trailing

- name: Set variables in key=value syntax
  set_fact:
    no_quotes_single=C:\Windows\Temp
    single_quotes_single='C:\Windows\Temp'
    double_quotes_single="C:\Windows\Temp"
    no_quotes_single_tab=C:\Windows\temp
    single_quotes_single_tab='C:\Windows\temp'
    double_quotes_single_tab="C:\Windows\temp"
    no_quotes_double=C:\\Windows\\Temp
    single_quotes_double='C:\\Windows\\Temp'
    double_quotes_double="C:\\Windows\\Temp"
    no_quotes_slash=C:/Windows/Temp
    no_quotes_trailing=C:\Windows\Temp\
    good=C:\Windows\Temp
    works1=C:\\Windows\\Temp
    works2=C:/Windows/Temp
    fail="C:\Windows\Temp"
    trailing=C:\Windows\Temp\
    tab=C:\Windows\x09emp
    eof=foobar
#    single_quotes_trailing='C:\Windows\Temp\'
#    double_quotes_trailing="C:\Windows\Temp\"
  register: legacy_syntax

- assert:
    that:
    - no_quotes_single == good
    - single_quotes_single == good
    - double_quotes_single == good
    - no_quotes_double == works1
    - single_quotes_double == works1
    - double_quotes_double == works1
    - no_quotes_slash == works2
    - no_quotes_single_tab == tab
    - single_quotes_single_tab == tab
    - double_quotes_single_tab == tab
    - no_quotes_trailing == trailing
    - good == works1
    - good != works2
    - good != tab
    - good != trailing
    - works1 != works2
    - works1 != tab
    - works1 != trailing
    - works2 != tab
    - works2 != trailing
    - tab != trailing

- name: Test good path {{ good }}
  win_stat:
    path: '{{ good }}'
  register: good_result

- assert:
    that:
    - good_result is successful
    - good_result.stat.attributes == 'Directory'
    - good_result.stat.exists == true
    - good_result.stat.path == good

- name: Test works1 path {{ works1 }}
  win_stat:
    path: '{{ works1 }}'
  register: works1_result

- assert:
    that:
    - works1_result is successful
    - works1_result.stat.attributes == 'Directory'
    - works1_result.stat.exists == true
    - works1_result.stat.path == good

- name: Test works2 path {{ works2 }}
  win_stat:
    path: '{{ works2 }}'
  register: works2_result

- assert:
    that:
    - works2_result is successful
    - works2_result.stat.attributes == 'Directory'
    - works2_result.stat.exists == true
    - works2_result.stat.path == good

- name: Test trailing path {{ trailing }}
  win_stat:
    path: '{{ trailing }}'
  register: trailing_result

- assert:
    that:
    - trailing_result is successful
    - trailing_result.stat.attributes == 'Directory'
    - trailing_result.stat.exists == true
    - trailing_result.stat.path == trailing

- name: Test tab path {{ tab }}
  win_stat:
    path: '{{ tab }}'
  register: tab_result
  ignore_errors: yes

- assert:
    that:
    - tab_result is failed