overwrite module-name tmp file
mrqwer88 opened this issue · 1 comments
mrqwer88 commented
If enable -
set -o noclobber
it have errors like
ansible myhost -m bash: /tmp/25576.module-name.ansible.completion: cannot overwrite existing file
As variant it fixed -
- local cache_file=/tmp/${$}.${module_path:+"$hash_module_path".}module-name.ansible.completion
+ # /tmp/<pid>.<hash of the module path if exsist>.module-name.ansible.completion and time for set -o noclobber
+ local cache_file=/tmp/${$}.$(date +%s).${module_path:+"$hash_module_path".}module-name.ansible.completion
And it work, but it doesnt good solution, i think -
find /tmp/ -name "*.completion"
/tmp/25576.1399165774.module-name.ansible.completion
/tmp/25576.1399165789.module-name.ansible.completion
/tmp/25576.1399165767.module-name.ansible.completion
/tmp/25576.module-name.ansible.completion
/tmp/25576.1399165783.module-name.ansible.completion
/tmp/25576.1399165770.module-name.ansible.completion
mrqwer88 commented
I think more good solution -
@@ -92,5 +92,4 @@
if [ "$timestamp" -gt "$ANSIBLE_COMPLETION_CACHE_TIMEOUT" ]; then
#@todo refactor ?
- rm -rf $cache_file
ansible-doc ${module_path:+-M "$module_path"} -l | awk '{print $1}' > $cache_file
fi
Whith noclobber on it work fine now.