如果在我的节点上存在定义文件,那么在playbook执行过程中停止它是否可能,并输出解释为什么playbook已经停止?
这是为了防止在已安装应用程序的节点上意外重新执行playbook,因为我在安装过程中生成了密码,不希望重新初始化此密码。
如果在我的节点上存在定义文件,那么在playbook执行过程中停止它是否可能,并输出解释为什么playbook已经停止?
这是为了防止在已安装应用程序的节点上意外重新执行playbook,因为我在安装过程中生成了密码,不希望重新初始化此密码。
你可以使用fail 模块来强制执行自定义的失败消息。
结合使用stat 模块来检查文件,这样应该就足够容易地工作了。
一个快速示例或单次运行的playbook可能如下所示:
- name: check for foo.conf
stat: path=/etc/foo.conf
register: foo
- name: fail if already run on host
fail: msg="This host has already had this playbook run against it"
when: foo.stat.exists
- name: create foo.conf
file: path=/etc/foo.conf state=touch