mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
Fix 'touch' mode so it creates zero size files. (#20876)
This commit is contained in:
parent
ed52714dba
commit
2c70450e23
2 changed files with 11 additions and 1 deletions
|
@ -35,7 +35,7 @@ if ($state -eq "touch") {
|
||||||
if (Test-Path $path) {
|
if (Test-Path $path) {
|
||||||
(Get-ChildItem $path).LastWriteTime = Get-Date
|
(Get-ChildItem $path).LastWriteTime = Get-Date
|
||||||
} else {
|
} else {
|
||||||
echo $null > $path
|
Write-Output $null | Out-File -FilePath $path -Encoding ASCII
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
|
|
|
@ -52,6 +52,16 @@
|
||||||
# - "file3_result.state == 'file'"
|
# - "file3_result.state == 'file'"
|
||||||
# - "file3_result.mode == '0644'"
|
# - "file3_result.mode == '0644'"
|
||||||
|
|
||||||
|
- name: stat the touched file
|
||||||
|
win_stat: path={{win_output_dir}}/baz.txt state=touch
|
||||||
|
register: file3_stat_result
|
||||||
|
|
||||||
|
- name: verify that the touched file exists and is size 0
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "file3_stat_result.changed == false"
|
||||||
|
- "file3_stat_result.stat.size == 0"
|
||||||
|
- "file3_stat_result.stat.exists == true"
|
||||||
#- name: change file mode
|
#- name: change file mode
|
||||||
# win_file: path={{win_output_dir}}/baz.txt mode=0600
|
# win_file: path={{win_output_dir}}/baz.txt mode=0600
|
||||||
# register: file4_result
|
# register: file4_result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue