1--- 2- name: test win_stat module on file 3 win_stat: 4 path: '{{win_stat_dir}}\nested\file.ps1' 5 register: stat_file 6 7- name: check actual for file 8 assert: 9 that: 10 - stat_file.stat.attributes == 'Archive' 11 - stat_file.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 12 - stat_file.stat.creationtime == 1477984205 13 - stat_file.stat.exists == True 14 - stat_file.stat.extension == '.ps1' 15 - stat_file.stat.filename == 'file.ps1' 16 - stat_file.stat.hlnk_targets == [] 17 - stat_file.stat.isarchive == True 18 - stat_file.stat.isdir == False 19 - stat_file.stat.ishidden == False 20 - stat_file.stat.isjunction == False 21 - stat_file.stat.islnk == False 22 - stat_file.stat.isreadonly == False 23 - stat_file.stat.isreg == True 24 - stat_file.stat.isshared == False 25 - stat_file.stat.lastaccesstime == 1477984205 26 - stat_file.stat.lastwritetime == 1477984205 27 - stat_file.stat.md5 is not defined 28 - stat_file.stat.nlink == 1 29 - stat_file.stat.owner == 'BUILTIN\Administrators' 30 - stat_file.stat.path == win_stat_dir + '\\nested\\file.ps1' 31 - stat_file.stat.size == 3 32 33# get_md5 will be undocumented in 2.9, remove this test then 34- name: test win_stat module on file with md5 35 win_stat: 36 path: '{{win_stat_dir}}\nested\file.ps1' 37 get_md5: True 38 register: stat_file_md5 39 40- name: check actual for file without md5 41 assert: 42 that: 43 - stat_file_md5.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 44 45- name: test win_stat module on file with sha256 46 win_stat: 47 path: '{{win_stat_dir}}\nested\file.ps1' 48 checksum_algorithm: sha256 49 register: stat_file_sha256 50 51- name: check actual for file with sha256 52 assert: 53 that: 54 - stat_file_sha256.stat.checksum == 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' 55 56- name: test win_stat module on file with sha384 57 win_stat: 58 path: '{{win_stat_dir}}\nested\file.ps1' 59 checksum_algorithm: sha384 60 register: stat_file_sha384 61 62- name: check actual for file with sha384 63 assert: 64 that: 65 - stat_file_sha384.stat.checksum == 'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7' 66 67- name: test win_stat module on file with sha512 68 win_stat: 69 path: '{{win_stat_dir}}\nested\file.ps1' 70 checksum_algorithm: sha512 71 register: stat_file_sha512 72 73- name: check actual for file with sha512 74 assert: 75 that: 76 - stat_file_sha512.stat.checksum == 'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f' 77 78- name: test win_stat on hidden file 79 win_stat: 80 path: '{{win_stat_dir}}\nested\hidden.ps1' 81 register: stat_file_hidden 82 83- name: check actual for hidden file 84 assert: 85 that: 86 - stat_file_hidden.stat.attributes == 'Hidden, Archive' 87 - stat_file_hidden.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 88 - stat_file_hidden.stat.creationtime == 1477984205 89 - stat_file_hidden.stat.exists == True 90 - stat_file_hidden.stat.extension == '.ps1' 91 - stat_file_hidden.stat.filename == 'hidden.ps1' 92 - stat_file_hidden.stat.hlnk_targets == [] 93 - stat_file_hidden.stat.isarchive == True 94 - stat_file_hidden.stat.isdir == False 95 - stat_file_hidden.stat.ishidden == True 96 - stat_file_hidden.stat.isjunction == False 97 - stat_file_hidden.stat.islnk == False 98 - stat_file_hidden.stat.isreadonly == False 99 - stat_file_hidden.stat.isreg == True 100 - stat_file_hidden.stat.isshared == False 101 - stat_file_hidden.stat.lastaccesstime == 1477984205 102 - stat_file_hidden.stat.lastwritetime == 1477984205 103 - stat_file_hidden.stat.md5 is not defined 104 - stat_file_hidden.stat.nlink == 1 105 - stat_file_hidden.stat.owner == 'BUILTIN\Administrators' 106 - stat_file_hidden.stat.path == win_stat_dir + '\\nested\\hidden.ps1' 107 - stat_file_hidden.stat.size == 3 108 109- name: test win_stat on readonly file 110 win_stat: 111 path: '{{win_stat_dir}}\nested\read-only.ps1' 112 register: stat_readonly 113 114- name: check actual for readonly file 115 assert: 116 that: 117 - stat_readonly.stat.attributes == 'ReadOnly, Archive' 118 - stat_readonly.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 119 - stat_readonly.stat.creationtime == 1477984205 120 - stat_readonly.stat.exists == True 121 - stat_readonly.stat.extension == '.ps1' 122 - stat_readonly.stat.filename == 'read-only.ps1' 123 - stat_readonly.stat.hlnk_targets == [] 124 - stat_readonly.stat.isarchive == True 125 - stat_readonly.stat.isdir == False 126 - stat_readonly.stat.ishidden == False 127 - stat_readonly.stat.isjunction == False 128 - stat_readonly.stat.islnk == False 129 - stat_readonly.stat.isreadonly == True 130 - stat_readonly.stat.isreg == True 131 - stat_readonly.stat.isshared == False 132 - stat_readonly.stat.lastaccesstime == 1477984205 133 - stat_readonly.stat.lastwritetime == 1477984205 134 - stat_readonly.stat.md5 is not defined 135 - stat_readonly.stat.nlink == 1 136 - stat_readonly.stat.owner == 'BUILTIN\Administrators' 137 - stat_readonly.stat.path == win_stat_dir + '\\nested\\read-only.ps1' 138 - stat_readonly.stat.size == 3 139 140- name: test win_stat on hard link file 141 win_stat: 142 path: '{{win_stat_dir}}\nested\hard-link.ps1' 143 follow: True # just verifies we don't do any weird follow logic for hard links 144 register: stat_hard_link 145 146- name: check actual for hard link file 147 assert: 148 that: 149 - stat_hard_link.stat.attributes == 'Archive' 150 - stat_hard_link.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 151 - stat_hard_link.stat.creationtime == 1477984205 152 - stat_hard_link.stat.exists == True 153 - stat_hard_link.stat.extension == '.ps1' 154 - stat_hard_link.stat.filename == 'hard-link.ps1' 155 - stat_hard_link.stat.hlnk_targets == [ win_stat_dir + '\\nested\hard-target.txt' ] 156 - stat_hard_link.stat.isarchive == True 157 - stat_hard_link.stat.isdir == False 158 - stat_hard_link.stat.ishidden == False 159 - stat_hard_link.stat.isjunction == False 160 - stat_hard_link.stat.islnk == False 161 - stat_hard_link.stat.isreadonly == False 162 - stat_hard_link.stat.isshared == False 163 - stat_hard_link.stat.lastaccesstime == 1477984205 164 - stat_hard_link.stat.lastwritetime == 1477984205 165 - stat_hard_link.stat.md5 is not defined 166 - stat_hard_link.stat.nlink == 2 167 - stat_hard_link.stat.owner == 'BUILTIN\Administrators' 168 - stat_hard_link.stat.path == win_stat_dir + '\\nested\\hard-link.ps1' 169 - stat_hard_link.stat.size == 3 170 171- name: test win_stat on directory 172 win_stat: 173 path: '{{win_stat_dir}}\nested' 174 register: stat_directory 175 176- name: check actual for directory 177 assert: 178 that: 179 - stat_directory.stat.attributes == 'Directory' 180 - stat_directory.stat.checksum is not defined 181 - stat_directory.stat.creationtime == 1477984205 182 - stat_directory.stat.exists == True 183 - stat_directory.stat.extension is not defined 184 - stat_directory.stat.filename == 'nested' 185 - stat_directory.stat.hlnk_targets == [] 186 - stat_directory.stat.isarchive == False 187 - stat_directory.stat.isdir == True 188 - stat_directory.stat.ishidden == False 189 - stat_directory.stat.isjunction == False 190 - stat_directory.stat.islnk == False 191 - stat_directory.stat.isreadonly == False 192 - stat_directory.stat.isreg == False 193 - stat_directory.stat.isshared == False 194 - stat_directory.stat.lastaccesstime == 1477984205 195 - stat_directory.stat.lastwritetime == 1477984205 196 - stat_directory.stat.md5 is not defined 197 - stat_directory.stat.nlink == 1 198 - stat_directory.stat.owner == 'BUILTIN\Administrators' 199 - stat_directory.stat.path == win_stat_dir + '\\nested' 200 - stat_directory.stat.size == 24 201 202- name: test win_stat on empty directory 203 win_stat: 204 path: '{{win_stat_dir}}\folder' 205 register: stat_directory_empty 206 207- name: check actual for empty directory 208 assert: 209 that: 210 - stat_directory_empty.stat.attributes == 'Directory' 211 - stat_directory_empty.stat.checksum is not defined 212 - stat_directory_empty.stat.creationtime == 1477984205 213 - stat_directory_empty.stat.exists == True 214 - stat_directory_empty.stat.extension is not defined 215 - stat_directory_empty.stat.filename == 'folder' 216 - stat_directory_empty.stat.hlnk_targets == [] 217 - stat_directory_empty.stat.isarchive == False 218 - stat_directory_empty.stat.isdir == True 219 - stat_directory_empty.stat.ishidden == False 220 - stat_directory_empty.stat.isjunction == False 221 - stat_directory_empty.stat.islnk == False 222 - stat_directory_empty.stat.isreadonly == False 223 - stat_directory_empty.stat.isreg == False 224 - stat_directory_empty.stat.isshared == False 225 - stat_directory_empty.stat.lastaccesstime == 1477984205 226 - stat_directory_empty.stat.lastwritetime == 1477984205 227 - stat_directory_empty.stat.md5 is not defined 228 - stat_directory_empty.stat.nlink == 1 229 - stat_directory_empty.stat.owner == 'BUILTIN\Administrators' 230 - stat_directory_empty.stat.path == win_stat_dir + '\\folder' 231 - stat_directory_empty.stat.size == 0 232 233- name: test win_stat on directory with space in name 234 win_stat: 235 path: '{{win_stat_dir}}\folder space' 236 register: stat_directory_space 237 238- name: check actual for directory with space in name 239 assert: 240 that: 241 - stat_directory_space.stat.attributes == 'Directory' 242 - stat_directory_space.stat.checksum is not defined 243 - stat_directory_space.stat.creationtime == 1477984205 244 - stat_directory_space.stat.exists == True 245 - stat_directory_space.stat.extension is not defined 246 - stat_directory_space.stat.filename == 'folder space' 247 - stat_directory_space.stat.hlnk_targets == [] 248 - stat_directory_space.stat.isarchive == False 249 - stat_directory_space.stat.isdir == True 250 - stat_directory_space.stat.ishidden == False 251 - stat_directory_space.stat.isjunction == False 252 - stat_directory_space.stat.islnk == False 253 - stat_directory_space.stat.isreadonly == False 254 - stat_directory_space.stat.isreg == False 255 - stat_directory_space.stat.isshared == False 256 - stat_directory_space.stat.lastaccesstime == 1477984205 257 - stat_directory_space.stat.lastwritetime == 1477984205 258 - stat_directory_space.stat.md5 is not defined 259 - stat_directory_space.stat.nlink == 1 260 - stat_directory_space.stat.owner == 'BUILTIN\Administrators' 261 - stat_directory_space.stat.path == win_stat_dir + '\\folder space' 262 - stat_directory_space.stat.size == 3 263 264- name: test win_stat on hidden directory 265 win_stat: 266 path: '{{win_stat_dir}}\hidden' 267 register: stat_hidden 268 269- name: check actual for hidden directory 270 assert: 271 that: 272 - stat_hidden.stat.attributes == 'Hidden, Directory' 273 - stat_hidden.stat.checksum is not defined 274 - stat_hidden.stat.creationtime == 1477984205 275 - stat_hidden.stat.exists == True 276 - stat_hidden.stat.extension is not defined 277 - stat_hidden.stat.filename == 'hidden' 278 - stat_hidden.stat.hlnk_targets == [] 279 - stat_hidden.stat.isarchive == False 280 - stat_hidden.stat.isdir == True 281 - stat_hidden.stat.ishidden == True 282 - stat_hidden.stat.isjunction == False 283 - stat_hidden.stat.islnk == False 284 - stat_hidden.stat.isreadonly == False 285 - stat_hidden.stat.isreg == False 286 - stat_hidden.stat.isshared == False 287 - stat_hidden.stat.lastaccesstime == 1477984205 288 - stat_hidden.stat.lastwritetime == 1477984205 289 - stat_hidden.stat.md5 is not defined 290 - stat_hidden.stat.nlink == 1 291 - stat_hidden.stat.owner == 'BUILTIN\Administrators' 292 - stat_hidden.stat.path == win_stat_dir + '\\hidden' 293 - stat_hidden.stat.size == 0 294 295- name: test win_stat on shared directory 296 win_stat: 297 path: '{{win_stat_dir}}\shared' 298 register: stat_shared 299 300- name: check actual for shared directory 301 assert: 302 that: 303 - stat_shared.stat.attributes == 'Directory' 304 - stat_shared.stat.checksum is not defined 305 - stat_shared.stat.creationtime == 1477984205 306 - stat_shared.stat.exists == True 307 - stat_shared.stat.extension is not defined 308 - stat_shared.stat.filename == 'shared' 309 - stat_shared.stat.hlnk_targets == [] 310 - stat_shared.stat.isarchive == False 311 - stat_shared.stat.isdir == True 312 - stat_shared.stat.ishidden == False 313 - stat_shared.stat.isjunction == False 314 - stat_shared.stat.islnk == False 315 - stat_shared.stat.isreadonly == False 316 - stat_shared.stat.isreg == False 317 - stat_shared.stat.isshared == True 318 - stat_shared.stat.lastaccesstime == 1477984205 319 - stat_shared.stat.lastwritetime == 1477984205 320 - stat_shared.stat.md5 is not defined 321 - stat_shared.stat.nlink == 1 322 - stat_shared.stat.owner == 'BUILTIN\Administrators' 323 - stat_shared.stat.path == win_stat_dir + '\\shared' 324 - stat_shared.stat.sharename == 'folder-share' 325 - stat_shared.stat.size == 0 326 327- name: test win_stat on directory symlink 328 win_stat: 329 path: '{{win_stat_dir}}\link' 330 register: stat_symlink 331 332- name: assert directory symlink actual 333 assert: 334 that: 335 - stat_symlink.stat.attributes == 'Directory, ReparsePoint' 336 - stat_symlink.stat.creationtime is defined 337 - stat_symlink.stat.exists == True 338 - stat_symlink.stat.filename == 'link' 339 - stat_symlink.stat.hlnk_targets == [] 340 - stat_symlink.stat.isarchive == False 341 - stat_symlink.stat.isdir == True 342 - stat_symlink.stat.ishidden == False 343 - stat_symlink.stat.islnk == True 344 - stat_symlink.stat.isjunction == False 345 - stat_symlink.stat.isreadonly == False 346 - stat_symlink.stat.isreg == False 347 - stat_symlink.stat.isshared == False 348 - stat_symlink.stat.lastaccesstime is defined 349 - stat_symlink.stat.lastwritetime is defined 350 - stat_symlink.stat.lnk_source == win_stat_dir + '\\link-dest' 351 - stat_symlink.stat.lnk_target == win_stat_dir + '\\link-dest' 352 - stat_symlink.stat.nlink == 1 353 - stat_symlink.stat.owner == 'BUILTIN\\Administrators' 354 - stat_symlink.stat.path == win_stat_dir + '\\link' 355 - stat_symlink.stat.checksum is not defined 356 - stat_symlink.stat.md5 is not defined 357 358- name: test win_stat on file symlink 359 win_stat: 360 path: '{{win_stat_dir}}\file-link.txt' 361 register: stat_file_symlink 362 363- name: assert file symlink actual 364 assert: 365 that: 366 - stat_file_symlink.stat.attributes == 'Archive, ReparsePoint' 367 - stat_file_symlink.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 368 - stat_file_symlink.stat.creationtime is defined 369 - stat_file_symlink.stat.exists == True 370 - stat_file_symlink.stat.extension == '.txt' 371 - stat_file_symlink.stat.filename == 'file-link.txt' 372 - stat_file_symlink.stat.hlnk_targets == [] 373 - stat_file_symlink.stat.isarchive == True 374 - stat_file_symlink.stat.isdir == False 375 - stat_file_symlink.stat.ishidden == False 376 - stat_file_symlink.stat.isjunction == False 377 - stat_file_symlink.stat.islnk == True 378 - stat_file_symlink.stat.isreadonly == False 379 - stat_file_symlink.stat.isreg == False 380 - stat_file_symlink.stat.isshared == False 381 - stat_file_symlink.stat.lastaccesstime is defined 382 - stat_file_symlink.stat.lastwritetime is defined 383 - stat_file_symlink.stat.lnk_source == win_stat_dir + '\\nested\\file.ps1' 384 - stat_file_symlink.stat.lnk_target == win_stat_dir + '\\nested\\file.ps1' 385 - stat_file_symlink.stat.md5 is not defined 386 - stat_file_symlink.stat.nlink == 1 387 - stat_file_symlink.stat.owner == 'BUILTIN\\Administrators' 388 - stat_file_symlink.stat.path == win_stat_dir + '\\file-link.txt' 389 390- name: test win_stat of file symlink with follow 391 win_stat: 392 path: '{{win_stat_dir}}\file-link.txt' 393 follow: True 394 register: stat_file_symlink_follow 395 396- name: assert file system with follow actual 397 assert: 398 that: 399 - stat_file_symlink_follow.stat.attributes == 'Archive' 400 - stat_file_symlink_follow.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 401 - stat_file_symlink_follow.stat.creationtime is defined 402 - stat_file_symlink_follow.stat.exists == True 403 - stat_file_symlink_follow.stat.extension == '.ps1' 404 - stat_file_symlink_follow.stat.filename == 'file.ps1' 405 - stat_file_symlink_follow.stat.hlnk_targets == [] 406 - stat_file_symlink_follow.stat.isarchive == True 407 - stat_file_symlink_follow.stat.isdir == False 408 - stat_file_symlink_follow.stat.ishidden == False 409 - stat_file_symlink_follow.stat.isjunction == False 410 - stat_file_symlink_follow.stat.islnk == False 411 - stat_file_symlink_follow.stat.isreadonly == False 412 - stat_file_symlink_follow.stat.isreg == True 413 - stat_file_symlink_follow.stat.isshared == False 414 - stat_file_symlink_follow.stat.lastaccesstime is defined 415 - stat_file_symlink_follow.stat.lastwritetime is defined 416 - stat_file_symlink_follow.stat.md5 is not defined 417 - stat_file_symlink_follow.stat.nlink == 1 418 - stat_file_symlink_follow.stat.owner == 'BUILTIN\\Administrators' 419 - stat_file_symlink_follow.stat.path == win_stat_dir + '\\nested\\file.ps1' 420 421- name: test win_stat on relative symlink 422 win_stat: 423 path: '{{win_stat_dir}}\nested\nested\link-rel' 424 register: stat_rel_symlink 425 426- name: assert directory relative symlink actual 427 assert: 428 that: 429 - stat_rel_symlink.stat.attributes == 'Directory, ReparsePoint' 430 - stat_rel_symlink.stat.creationtime is defined 431 - stat_rel_symlink.stat.exists == True 432 - stat_rel_symlink.stat.filename == 'link-rel' 433 - stat_rel_symlink.stat.hlnk_targets == [] 434 - stat_rel_symlink.stat.isarchive == False 435 - stat_rel_symlink.stat.isdir == True 436 - stat_rel_symlink.stat.ishidden == False 437 - stat_rel_symlink.stat.isjunction == False 438 - stat_rel_symlink.stat.islnk == True 439 - stat_rel_symlink.stat.isreadonly == False 440 - stat_rel_symlink.stat.isreg == False 441 - stat_rel_symlink.stat.isshared == False 442 - stat_rel_symlink.stat.lastaccesstime is defined 443 - stat_rel_symlink.stat.lastwritetime is defined 444 - stat_rel_symlink.stat.lnk_source == win_stat_dir + '\\link-dest' 445 - stat_rel_symlink.stat.lnk_target == '..\\..\\link-dest' 446 - stat_rel_symlink.stat.nlink == 1 447 - stat_rel_symlink.stat.owner == 'BUILTIN\\Administrators' 448 - stat_rel_symlink.stat.path == win_stat_dir + '\\nested\\nested\\link-rel' 449 - stat_rel_symlink.stat.checksum is not defined 450 - stat_rel_symlink.stat.md5 is not defined 451 452- name: test win_stat on relative multiple symlink with follow 453 win_stat: 454 path: '{{win_stat_dir}}\outer-link' 455 follow: True 456 register: stat_symlink_follow 457 458- name: assert directory relative symlink actual 459 assert: 460 that: 461 - stat_symlink_follow.stat.attributes == 'Directory' 462 - stat_symlink_follow.stat.creationtime is defined 463 - stat_symlink_follow.stat.exists == True 464 - stat_symlink_follow.stat.filename == 'link-dest' 465 - stat_symlink_follow.stat.hlnk_targets == [] 466 - stat_symlink_follow.stat.isarchive == False 467 - stat_symlink_follow.stat.isdir == True 468 - stat_symlink_follow.stat.ishidden == False 469 - stat_symlink_follow.stat.isjunction == False 470 - stat_symlink_follow.stat.islnk == False 471 - stat_symlink_follow.stat.isreadonly == False 472 - stat_symlink_follow.stat.isreg == False 473 - stat_symlink_follow.stat.isshared == False 474 - stat_symlink_follow.stat.lastaccesstime is defined 475 - stat_symlink_follow.stat.lastwritetime is defined 476 - stat_symlink_follow.stat.nlink == 1 477 - stat_symlink_follow.stat.owner == 'BUILTIN\\Administrators' 478 - stat_symlink_follow.stat.path == win_stat_dir + '\\link-dest' 479 - stat_symlink_follow.stat.checksum is not defined 480 - stat_symlink_follow.stat.md5 is not defined 481 482- name: test win_stat on junction 483 win_stat: 484 path: '{{win_stat_dir}}\junction-link' 485 register: stat_junction_point 486 487- name: assert junction actual 488 assert: 489 that: 490 - stat_junction_point.stat.attributes == 'Directory, ReparsePoint' 491 - stat_junction_point.stat.creationtime is defined 492 - stat_junction_point.stat.exists == True 493 - stat_junction_point.stat.filename == 'junction-link' 494 - stat_junction_point.stat.hlnk_targets == [] 495 - stat_junction_point.stat.isarchive == False 496 - stat_junction_point.stat.isdir == True 497 - stat_junction_point.stat.ishidden == False 498 - stat_junction_point.stat.isjunction == True 499 - stat_junction_point.stat.islnk == False 500 - stat_junction_point.stat.isreadonly == False 501 - stat_junction_point.stat.isreg == False 502 - stat_junction_point.stat.isshared == False 503 - stat_junction_point.stat.lastaccesstime is defined 504 - stat_junction_point.stat.lastwritetime is defined 505 - stat_junction_point.stat.lnk_source == win_stat_dir + '\\junction-dest' 506 - stat_junction_point.stat.lnk_target == win_stat_dir + '\\junction-dest' 507 - stat_junction_point.stat.nlink == 1 508 - stat_junction_point.stat.owner == 'BUILTIN\\Administrators' 509 - stat_junction_point.stat.path == win_stat_dir + '\\junction-link' 510 - stat_junction_point.stat.size == 0 511 512- name: test win_stat on junction with follow 513 win_stat: 514 path: '{{win_stat_dir}}\junction-link' 515 follow: True 516 register: stat_junction_point_follow 517 518- name: assert junction with follow actual 519 assert: 520 that: 521 - stat_junction_point_follow.stat.attributes == 'Directory' 522 - stat_junction_point_follow.stat.creationtime is defined 523 - stat_junction_point_follow.stat.exists == True 524 - stat_junction_point_follow.stat.filename == 'junction-dest' 525 - stat_junction_point_follow.stat.hlnk_targets == [] 526 - stat_junction_point_follow.stat.isarchive == False 527 - stat_junction_point_follow.stat.isdir == True 528 - stat_junction_point_follow.stat.ishidden == False 529 - stat_junction_point_follow.stat.isjunction == False 530 - stat_junction_point_follow.stat.islnk == False 531 - stat_junction_point_follow.stat.isreadonly == False 532 - stat_junction_point_follow.stat.isreg == False 533 - stat_junction_point_follow.stat.isshared == False 534 - stat_junction_point_follow.stat.lastaccesstime is defined 535 - stat_junction_point_follow.stat.lastwritetime is defined 536 - stat_junction_point_follow.stat.nlink == 1 537 - stat_junction_point_follow.stat.owner == 'BUILTIN\\Administrators' 538 - stat_junction_point_follow.stat.path == win_stat_dir + '\\junction-dest' 539 - stat_junction_point_follow.stat.size == 0 540 541- name: test win_stat module non-existent path 542 win_stat: 543 path: '{{win_stat_dir}}\this_file_should_not_exist' 544 register: win_stat_missing 545 546- name: check win_stat missing result 547 assert: 548 that: 549 - not win_stat_missing.stat.exists 550 - win_stat_missing is not failed 551 - win_stat_missing is not changed 552 553- name: test win_stat module without path argument 554 win_stat: 555 register: win_stat_no_args 556 failed_when: "win_stat_no_args.msg != 'missing required arguments: path'" 557 558# https://github.com/ansible/ansible/issues/30258 559- name: get path of pagefile 560 win_shell: | 561 $pagefile = $null 562 $cs = Get-CimInstance -ClassName Win32_ComputerSystem 563 if ($cs.AutomaticManagedPagefile) { 564 $pagefile = "$($env:SystemRoot.Substring(0, 1)):\pagefile.sys" 565 } else { 566 $pf = Get-CimInstance -ClassName Win32_PageFileSetting 567 if ($pf -ne $null) { 568 $pagefile = $pf[0].Name 569 } 570 } 571 $pagefile 572 register: pagefile_path 573 574- name: get stat of pagefile 575 win_stat: 576 path: '{{pagefile_path.stdout_lines[0]}}' 577 get_md5: no 578 get_checksum: no 579 register: pagefile_stat 580 when: pagefile_path.stdout_lines|count != 0 581 582- name: assert get stat of pagefile 583 assert: 584 that: 585 - pagefile_stat.stat.exists == True 586 when: pagefile_path.stdout_lines|count != 0 587 588# Tests with normal user 589- set_fact: 590 gen_pw: password123! + {{ lookup('password', '/dev/null chars=ascii_letters,digits length=8') }} 591 592- name: create test user 593 win_user: 594 name: '{{win_stat_user}}' 595 password: '{{gen_pw}}' 596 update_password: always 597 groups: Users 598 599- name: get become user profile dir so we can clean it up later 600 vars: &become_vars 601 ansible_become_user: '{{win_stat_user}}' 602 ansible_become_password: '{{gen_pw}}' 603 ansible_become_method: runas 604 ansible_become: yes 605 win_shell: $env:USERPROFILE 606 register: profile_dir_out 607 608- name: ensure profile dir contains test username (eg, if become fails silently, prevent deletion of real user profile) 609 assert: 610 that: 611 - win_stat_user in profile_dir_out.stdout_lines[0] 612 613- name: test stat with non admin user on a normal file 614 vars: *become_vars 615 win_stat: 616 path: '{{win_stat_dir}}\nested\file.ps1' 617 register: user_file 618 619- name: asert test stat with non admin user on a normal file 620 assert: 621 that: 622 - user_file.stat.attributes == 'Archive' 623 - user_file.stat.checksum == 'a9993e364706816aba3e25717850c26c9cd0d89d' 624 - user_file.stat.creationtime == 1477984205 625 - user_file.stat.exists == True 626 - user_file.stat.extension == '.ps1' 627 - user_file.stat.filename == 'file.ps1' 628 - user_file.stat.hlnk_targets == [] 629 - user_file.stat.isarchive == True 630 - user_file.stat.isdir == False 631 - user_file.stat.ishidden == False 632 - user_file.stat.isjunction == False 633 - user_file.stat.islnk == False 634 - user_file.stat.isreadonly == False 635 - user_file.stat.isreg == True 636 - user_file.stat.isshared == False 637 - user_file.stat.lastaccesstime == 1477984205 638 - user_file.stat.lastwritetime == 1477984205 639 - user_file.stat.md5 is not defined 640 - user_file.stat.nlink == 1 641 - user_file.stat.owner == 'BUILTIN\\Administrators' 642 - user_file.stat.path == win_stat_dir + '\\nested\\file.ps1' 643 - user_file.stat.size == 3 644 645- name: test stat on a symbolic link as normal user 646 vars: *become_vars 647 win_stat: 648 path: '{{win_stat_dir}}\link' 649 register: user_symlink 650 651- name: assert test stat on a symbolic link as normal user 652 assert: 653 that: 654 - user_symlink.stat.attributes == 'Directory, ReparsePoint' 655 - user_symlink.stat.creationtime is defined 656 - user_symlink.stat.exists == True 657 - user_symlink.stat.filename == 'link' 658 - user_symlink.stat.hlnk_targets == [] 659 - user_symlink.stat.isarchive == False 660 - user_symlink.stat.isdir == True 661 - user_symlink.stat.ishidden == False 662 - user_symlink.stat.islnk == True 663 - user_symlink.stat.isjunction == False 664 - user_symlink.stat.isreadonly == False 665 - user_symlink.stat.isreg == False 666 - user_symlink.stat.isshared == False 667 - user_symlink.stat.lastaccesstime is defined 668 - user_symlink.stat.lastwritetime is defined 669 - user_symlink.stat.lnk_source == win_stat_dir + '\\link-dest' 670 - user_symlink.stat.lnk_target == win_stat_dir + '\\link-dest' 671 - user_symlink.stat.nlink == 1 672 - user_symlink.stat.owner == 'BUILTIN\\Administrators' 673 - user_symlink.stat.path == win_stat_dir + '\\link' 674 - user_symlink.stat.checksum is not defined 675 - user_symlink.stat.md5 is not defined 676