mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Feature/win stat extra info (#19148)
* Added more return results to win_stat * Changed Win2012 methods to support older versions in setup * staging of the tests to work with older servers
This commit is contained in:
parent
a655e90e41
commit
971783a7fd
8 changed files with 925 additions and 108 deletions
1
test/integration/targets/win_stat/defaults/main.yml
Normal file
1
test/integration/targets/win_stat/defaults/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
win_stat_dir: "{{win_output_dir}}\\win_stat"
|
|
@ -0,0 +1,9 @@
|
|||
$path = $args[0]
|
||||
$attr = $args[1]
|
||||
$item = Get-Item "$path"
|
||||
|
||||
$attributes = $item.Attributes -split ','
|
||||
If ($attributes -notcontains $attr) {
|
||||
$attributes += $attr
|
||||
}
|
||||
$item.Attributes = $attributes -join ','
|
6
test/integration/targets/win_stat/files/set_filedate.ps1
Normal file
6
test/integration/targets/win_stat/files/set_filedate.ps1
Normal file
|
@ -0,0 +1,6 @@
|
|||
$date = Get-Date -Year 2016 -Month 11 -Day 1 -Hour 7 -Minute 10 -Second 5 -Millisecond 0
|
||||
|
||||
$item = Get-Item -Path "$($args[0])"
|
||||
$item.CreationTime = $date
|
||||
$item.LastAccessTime = $date
|
||||
$item.LastWriteTime = $date
|
6
test/integration/targets/win_stat/files/setup_share.ps1
Normal file
6
test/integration/targets/win_stat/files/setup_share.ps1
Normal file
|
@ -0,0 +1,6 @@
|
|||
$share_stat = Get-WmiObject -Class Win32_Share -Filter "name='folder-share'"
|
||||
If ($share_stat) {
|
||||
$share_stat.Delete()
|
||||
}
|
||||
$wmi = [wmiClass] 'Win32_Share'
|
||||
$wmi.Create($args[0], 'folder-share', 0)
|
|
@ -16,70 +16,587 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: remove links if they exist as win_file struggles
|
||||
win_command: cmd.exe /c rmdir "{{item}}"
|
||||
ignore_errors: True
|
||||
with_items:
|
||||
- "{{win_stat_dir}}\\link"
|
||||
- "{{win_stat_dir}}\\nested\\hard-link.ps1"
|
||||
- "{{win_stat_dir}}\\junction-link"
|
||||
|
||||
- name: ensure the testing directory is cleared before the run
|
||||
win_file:
|
||||
path: "{{win_stat_dir}}"
|
||||
state: absent
|
||||
|
||||
- name: ensure win testing directories exist
|
||||
win_file:
|
||||
path: "{{item}}"
|
||||
state: directory
|
||||
with_items:
|
||||
- "{{win_stat_dir}}\\folder"
|
||||
- "{{win_stat_dir}}\\folder space"
|
||||
- "{{win_stat_dir}}\\nested"
|
||||
- "{{win_stat_dir}}\\nested\\nested"
|
||||
- "{{win_stat_dir}}\\shared"
|
||||
- "{{win_stat_dir}}\\hidden"
|
||||
- "{{win_stat_dir}}\\link-dest"
|
||||
- "{{win_stat_dir}}\\junction-dest"
|
||||
|
||||
- name: create empty test files
|
||||
win_file:
|
||||
path: "{{item}}"
|
||||
state: touch
|
||||
with_items:
|
||||
- "{{win_stat_dir}}\\nested\\file.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\read-only.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\archive.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\hidden.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\nested\\file.ps1"
|
||||
- "{{win_stat_dir}}\\folder space\\file.ps1"
|
||||
|
||||
- name: populate files with a test string
|
||||
win_lineinfile:
|
||||
dest: "{{item}}"
|
||||
line: abc
|
||||
with_items:
|
||||
- "{{win_stat_dir}}\\nested\\file.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\read-only.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\archive.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\hidden.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\nested\\file.ps1"
|
||||
- "{{win_stat_dir}}\\folder space\\file.ps1"
|
||||
|
||||
- name: create share
|
||||
script: setup_share.ps1 {{win_stat_dir}}\shared
|
||||
|
||||
- name: create links
|
||||
win_command: cmd.exe /c mklink /{{item.type}} {{item.source}} {{item.target}}
|
||||
with_items:
|
||||
- { type: 'D', source: "{{win_stat_dir}}\\link", target: "{{win_stat_dir}}\\link-dest" }
|
||||
- { type: 'H', source: "{{win_stat_dir}}\\nested\\hard-link.ps1", target: "{{win_stat_dir}}\\nested\\file.ps1" }
|
||||
- { type: 'J', source: "{{win_stat_dir}}\\junction-link", target: "{{win_stat_dir}}\\junction-dest" }
|
||||
|
||||
- name: set modification date on files/folders
|
||||
script: set_filedate.ps1 "{{item}}"
|
||||
with_items:
|
||||
- "{{win_stat_dir}}\\nested\\file.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\read-only.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\archive.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\hidden.ps1"
|
||||
- "{{win_stat_dir}}\\nested\\nested\\file.ps1"
|
||||
- "{{win_stat_dir}}\\folder space\\file.ps1"
|
||||
- "{{win_stat_dir}}\\folder"
|
||||
- "{{win_stat_dir}}\\folder space"
|
||||
- "{{win_stat_dir}}\\nested"
|
||||
- "{{win_stat_dir}}\\nested\\nested"
|
||||
- "{{win_stat_dir}}\\shared"
|
||||
- "{{win_stat_dir}}\\hidden"
|
||||
- "{{win_stat_dir}}\\link-dest"
|
||||
- "{{win_stat_dir}}\\junction-dest"
|
||||
|
||||
- name: set file attributes for test
|
||||
script: set_attributes.ps1 {{item.path}} {{item.attr}}
|
||||
with_items:
|
||||
- { path: "{{win_stat_dir}}\\hidden", attr: "Hidden" }
|
||||
- { path: "{{win_stat_dir}}\\nested\\read-only.ps1", attr: "ReadOnly" }
|
||||
- { path: "{{win_stat_dir}}\\nested\\archive.ps1", attr: "Archive" }
|
||||
- { path: "{{win_stat_dir}}\\nested\\hidden.ps1", attr: "Hidden" }
|
||||
# End setup of test files
|
||||
|
||||
- name: test win_stat module on file
|
||||
win_stat: path="C:/Windows/win.ini"
|
||||
register: win_stat_file
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
register: actual
|
||||
|
||||
- name: check win_stat file result
|
||||
- name: set expected fact for file
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Archive
|
||||
checksum: 5943831380243c1269c8b68bb92de6e2f1844590
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: file.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for file
|
||||
assert:
|
||||
that:
|
||||
- "win_stat_file.stat.exists"
|
||||
- "not win_stat_file.stat.isdir"
|
||||
- "win_stat_file.stat.size > 0"
|
||||
- "win_stat_file.stat.md5"
|
||||
- "win_stat_file.stat.extension"
|
||||
- "win_stat_file.stat.attributes"
|
||||
- "win_stat_file.stat.owner"
|
||||
- "win_stat_file.stat.creationtime"
|
||||
- "win_stat_file.stat.lastaccesstime"
|
||||
- "win_stat_file.stat.lastwritetime"
|
||||
- "not win_stat_file|failed"
|
||||
- "not win_stat_file|changed"
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat module on file without md5 and backslashes
|
||||
win_stat: path="C:\Windows\win.ini" get_md5=no
|
||||
register: win_stat_file_no_md5
|
||||
- name: test win_stat module on file without md5
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
get_md5: False
|
||||
register: actual
|
||||
|
||||
- name: check win_stat file result without md5
|
||||
- name: set expected fact for file without md5
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Archive
|
||||
checksum: 5943831380243c1269c8b68bb92de6e2f1844590
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: file.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for file without md5
|
||||
assert:
|
||||
that:
|
||||
- "win_stat_file_no_md5.stat.exists"
|
||||
- "not win_stat_file_no_md5.stat.isdir"
|
||||
- "win_stat_file_no_md5.stat.size > 0"
|
||||
- "not win_stat_file_no_md5.stat.md5|default('')"
|
||||
- "win_stat_file_no_md5.stat.extension"
|
||||
- "win_stat_file_no_md5.stat.attributes"
|
||||
- "win_stat_file_no_md5.stat.owner"
|
||||
- "win_stat_file_no_md5.stat.creationtime"
|
||||
- "win_stat_file_no_md5.stat.lastaccesstime"
|
||||
- "win_stat_file_no_md5.stat.lastwritetime"
|
||||
- "not win_stat_file_no_md5|failed"
|
||||
- "not win_stat_file_no_md5|changed"
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat module on directory
|
||||
win_stat: path="C:\\Windows"
|
||||
register: win_stat_dir
|
||||
- name: test win_stat module on file with sha256
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
checksum_algorithm: sha256
|
||||
register: actual
|
||||
|
||||
- name: check win_stat dir result
|
||||
- name: set expected fact for file with sha256
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Archive
|
||||
checksum: aec4cd5ed4c05ed5cf9dea5a8b30f5e655ad87b937b36e3c059840ce3cf3642f
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: file.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for file with sha256
|
||||
assert:
|
||||
that:
|
||||
- "win_stat_dir.stat.exists"
|
||||
- "win_stat_dir.stat.isdir"
|
||||
- "win_stat_dir.stat.extension == ''"
|
||||
- "win_stat_dir.stat.attributes"
|
||||
- "win_stat_dir.stat.owner"
|
||||
- "win_stat_dir.stat.creationtime"
|
||||
- "win_stat_dir.stat.lastaccesstime"
|
||||
- "win_stat_dir.stat.lastwritetime"
|
||||
- "not win_stat_dir|failed"
|
||||
- "not win_stat_dir|changed"
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat module on file with sha384
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
checksum_algorithm: sha384
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for file with sha384
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Archive
|
||||
checksum: 862076ed4ef117cb61395daa839ccfe20a880e8cd048e76b3b1503d39d72f4c09d58ab3c44cdd5a3272ca8da9d8d8666
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: file.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for file with sha384
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat module on file with sha512
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
checksum_algorithm: sha512
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for file with sha512
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Archive
|
||||
checksum: 6d821d068cd8f09582de9ef14550666547eb6d4ae1d34cfc5aea921e595dbb9c462bf7f4c88a90190a69e52d69ac157e8146b555ed679a3e997061ca69632d0f
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: file.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\file.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for file with sha512
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on hidden file
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\hidden.ps1"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for hidden file
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: "Hidden, Archive"
|
||||
checksum: 5943831380243c1269c8b68bb92de6e2f1844590
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: hidden.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: True
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\hidden.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for hidden file
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on readonly file
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\read-only.ps1"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for readonly file
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: "ReadOnly, Archive"
|
||||
checksum: 5943831380243c1269c8b68bb92de6e2f1844590
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: read-only.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: True
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\read-only.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for readonly file
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on hard link file
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\hard-link.ps1"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for hard link file
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Archive
|
||||
checksum: 5943831380243c1269c8b68bb92de6e2f1844590
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
extension: .ps1
|
||||
filename: hard-link.ps1
|
||||
isarchive: True
|
||||
isdir: False
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
md5: c627105fad747457b7e88ed1016e065f
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested\\hard-link.ps1"
|
||||
size: 8
|
||||
|
||||
- name: check actual for hard link file
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on directory
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\nested"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for directory
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Directory
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
filename: nested
|
||||
isarchive: False
|
||||
isdir: True
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\nested"
|
||||
size: 40
|
||||
|
||||
- name: check actual for directory
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on empty directory
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\folder"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for empty directory
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Directory
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
filename: folder
|
||||
isarchive: False
|
||||
isdir: True
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\folder"
|
||||
size: 0
|
||||
|
||||
- name: check actual for empty directory
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on directory with space in name
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\folder space"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for directory with space in name
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Directory
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
filename: folder space
|
||||
isarchive: False
|
||||
isdir: True
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\folder space"
|
||||
size: 8
|
||||
|
||||
- name: check actual for directory with space in name
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on hidden directory
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\hidden"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for hidden directory
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: "Hidden, Directory"
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
filename: hidden
|
||||
isarchive: False
|
||||
isdir: True
|
||||
ishidden: True
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: False
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\hidden"
|
||||
size: 0
|
||||
|
||||
- name: check actual for hidden directory
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on shared directory
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\shared"
|
||||
register: actual
|
||||
|
||||
- name: set expected fact for shared directory
|
||||
set_fact:
|
||||
expected:
|
||||
changed: False
|
||||
stat:
|
||||
attributes: Directory
|
||||
creationtime: 1477984205
|
||||
exists: True
|
||||
filename: shared
|
||||
isarchive: False
|
||||
isdir: True
|
||||
ishidden: False
|
||||
islink: False
|
||||
isreadonly: False
|
||||
isshared: True
|
||||
lastaccesstime: 1477984205
|
||||
lastwritetime: 1477984205
|
||||
owner: BUILTIN\Administrators
|
||||
path: "{{win_output_dir}}\\win_stat\\shared"
|
||||
sharename: folder-share
|
||||
size: 0
|
||||
|
||||
- name: check actual for shared directory
|
||||
assert:
|
||||
that:
|
||||
- "actual == expected"
|
||||
|
||||
- name: test win_stat on symlink
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\link"
|
||||
register: actual
|
||||
|
||||
# I cannot change modification time on links so we are resorting to checking the dict against known valuea
|
||||
- name: assert symlink actual
|
||||
assert:
|
||||
that:
|
||||
- "actual.stat.attributes == 'Directory, ReparsePoint'"
|
||||
- "actual.stat.creationtime is defined"
|
||||
- "actual.stat.exists == True"
|
||||
- "actual.stat.filename == 'link'"
|
||||
- "actual.stat.isarchive == False"
|
||||
- "actual.stat.isdir == True"
|
||||
- "actual.stat.ishidden == False"
|
||||
- "actual.stat.islink == True"
|
||||
- "actual.stat.isreadonly == False"
|
||||
- "actual.stat.isshared == False"
|
||||
- "actual.stat.lastaccesstime is defined"
|
||||
- "actual.stat.lastwritetime is defined"
|
||||
- "actual.stat.lnk_source == '{{win_output_dir|regex_replace('\\\\', '\\\\\\\\')}}\\\\win_stat\\\\link-dest'"
|
||||
- "actual.stat.owner == 'BUILTIN\\Administrators'"
|
||||
- "actual.stat.path == '{{win_output_dir|regex_replace('\\\\', '\\\\\\\\')}}\\\\win_stat\\\\link'"
|
||||
- "actual.stat.size is not defined"
|
||||
- "actual.stat.checksum is not defined"
|
||||
- "actual.stat.md5 is not defined"
|
||||
|
||||
- name: test win_stat on junction
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\junction-link"
|
||||
register: actual
|
||||
|
||||
- name: assert symlink actual
|
||||
assert:
|
||||
that:
|
||||
- "actual.stat.attributes == 'Directory, ReparsePoint'"
|
||||
- "actual.stat.creationtime is defined"
|
||||
- "actual.stat.exists == True"
|
||||
- "actual.stat.filename == 'junction-link'"
|
||||
- "actual.stat.isarchive == False"
|
||||
- "actual.stat.isdir == True"
|
||||
- "actual.stat.ishidden == False"
|
||||
- "actual.stat.islink == True"
|
||||
- "actual.stat.isreadonly == False"
|
||||
- "actual.stat.isshared == False"
|
||||
- "actual.stat.lastaccesstime is defined"
|
||||
- "actual.stat.lastwritetime is defined"
|
||||
- "actual.stat.lnk_source == '{{win_output_dir|regex_replace('\\\\', '\\\\\\\\')}}\\\\win_stat\\\\junction-dest'"
|
||||
- "actual.stat.owner == 'BUILTIN\\Administrators'"
|
||||
- "actual.stat.path == '{{win_output_dir|regex_replace('\\\\', '\\\\\\\\')}}\\\\win_stat\\\\junction-link'"
|
||||
- "actual.stat.size is not defined"
|
||||
- "actual.stat.checksum is not defined"
|
||||
- "actual.stat.md5 is not defined"
|
||||
|
||||
- name: test win_stat module non-existent path
|
||||
win_stat: path="C:/this_file_should_not_exist.txt"
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\this_file_should_not_exist"
|
||||
register: win_stat_missing
|
||||
|
||||
- name: check win_stat missing result
|
||||
assert:
|
||||
assert:
|
||||
that:
|
||||
- "not win_stat_missing.stat.exists"
|
||||
- "not win_stat_missing|failed"
|
||||
|
@ -96,3 +613,26 @@
|
|||
- "win_stat_no_args|failed"
|
||||
- "win_stat_no_args.msg"
|
||||
- "not win_stat_no_args|changed"
|
||||
|
||||
- name: check if junction symbolic link exists
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\junction-link"
|
||||
register: junction_link_exists
|
||||
|
||||
- name: delete junction symbolic link if it exists
|
||||
win_command: cmd.exe /c rmdir {{win_output_dir}}\win_stat\junction-link
|
||||
when: junction_link_exists.stat.exists
|
||||
|
||||
- name: check if symbolic link exists
|
||||
win_stat:
|
||||
path: "{{win_output_dir}}\\win_stat\\link"
|
||||
register: nested_link_exists
|
||||
|
||||
- name: delete nested symbolic link if it exists
|
||||
win_shell: cmd.exe /c rmdir {{win_output_dir}}\win_stat\link
|
||||
when: nested_link_exists.stat.exists
|
||||
|
||||
- name: remove testing folder
|
||||
win_file:
|
||||
path: "{{win_output_dir}}\\win_stat"
|
||||
state: absent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue