仅当ansible中满足x任务条件时才运行yz任务
团队, 我有10个任务,只有在满足task1中的条件时,我才想运行2-10仅当ansible中满足x任务条件时才运行yz任务,ansible,ansible-2.x,Ansible,Ansible 2.x,团队, 我有10个任务,只有在满足task1中的条件时,我才想运行2-10 - name: 1Check if the node needs to be processed stat: /tmp/fscache-cleaned-up1.log register: dc_status 。。 .. ..您必须在stat模块调用中使用“path”和“block”来组合相关任务,如下所示: - name: Check if the node needs to be processed st
- name: 1Check if the node needs to be processed
stat: /tmp/fscache-cleaned-up1.log
register: dc_status
。。
..
..您必须在stat模块调用中使用“path”和“block”来组合相关任务,如下所示:
- name: Check if the node needs to be processed
stat:
path: /tmp/fscache-cleaned-up1.log
register: dc_status
- name: Run this only when the log file exists
block:
- name: Install something
yum:
name:
- somepackage
state: present
- name: Apply a config template
template:
src: templates/src.j2
dest: /etc/foo.conf
- name: Start a service and enable it
service:
name: bar
state: started
enabled: True
when:
- dc_status.stat.exists
- dc_status.stat.is_file
其他资料:
- name: Check if the node needs to be processed
stat:
path: /tmp/fscache-cleaned-up1.log
register: dc_status
- name: Run this only when the log file exists
block:
- name: Install something
yum:
name:
- somepackage
state: present
- name: Apply a config template
template:
src: templates/src.j2
dest: /etc/foo.conf
- name: Start a service and enable it
service:
name: bar
state: started
enabled: True
when:
- dc_status.stat.exists
- dc_status.stat.is_file