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