tri*_*lef 3 command ansible ansible-playbook
我使用command
具有creates
ansible 2.9 角色的模块。
但是,有时我需要忽略creates
arg 并多次重新运行该命令。
有什么办法可以覆盖默认行为并强制执行任务吗?
一种非常基本的解决方案。在您的任务中:
- name: Do command optionally ignoring create option
command:
cmd: touch /tmp/toto.txt
creates: "{{ ignore_creates | default(false) | bool | ternary('', '/tmp/toto.txt') | default(omit, true) }}"
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用额外的 var 启动您的剧本,-e ignore_creates=true
以强制任务运行,即使文件存在。删除命令中额外的 var 将再次打开条件。
归档时间: |
|
查看次数: |
381 次 |
最近记录: |