在Ansible shell模块中使用’creates’arg

前端之家收集整理的这篇文章主要介绍了在Ansible shell模块中使用’creates’arg前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
shell模块中使用“creates”参数时,这可以是目录的路径吗?或者它必须是一个文件
你为什么不亲自尝试一下?简短的回答是:是的,它可以是文件系统中可见的任何内容
  1. ---
  2. - name: Test create arg of shell
  3. hosts: localhost
  4.  
  5. tasks:
  6. - name: Set up working area
  7. shell: mktemp -d
  8. register: workdir
  9. - name: Working Area
  10. debug:
  11. msg: "{{ workdir }}"
  12.  
  13. - name: Create a file
  14. shell: touch {{ workdir.stdout }}/test-file
  15. args:
  16. creates: "{{ workdir.stdout }}/test-file"
  17. - name: "Test if it get's created again"
  18. shell: touch {{ workdir.stdout }}/test-file
  19. args:
  20. creates: "{{ workdir.stdout }}/test-file"
  21.  
  22. - name: Create a directory
  23. shell: mkdir {{ workdir.stdout }}/test-directory
  24. args:
  25. creates: "{{ workdir.stdout }}/test-directory"
  26. - name: "Test if it get's created again"
  27. shell: mkdir {{ workdir.stdout }}/test-directory
  28. args:
  29. creates: "{{ workdir.stdout }}/test-directory"
  30. - name: Cleanup
  31. shell: "rm -rf {{ workdir.stdout }}"
  32.  
  33. # vim: set ts=2 sts=2 fenc=utf-8 list:

猜你在找的Bash相关文章