Invisible stop-book if file is present

Is it possible to stop the play during its execution if the definition file is present on my node, and also output it to explain why the player stopped?

This should prevent my playbook from accidentally re-executing on a node that already has my application installed, because I generate a password during this installation and I do not want to reinitialize this password.

+4
source share
1 answer

You can use the failure module to cause a failure with a custom error message.

, stat module, .

:

- 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
+3

All Articles