- name: Check if /var/run/app.lock exists
- name: Fail if the application is running
when: not lock.stat.exists
Can you validate if the excerpt of code is doing opposite of what it should. The when clause should be
rather than what is written.
Code is OK.
fail failed when when is True ;-)
lock.stat.exists is False if file does not exists.
you can verify if you look what the content of lock is.
- name: print var lock debug: var: lock
Pay attention. I think there was a change in one of the previous ansible versions with the stat module. Means, it could depend on the ansible version.
A collaborative learning environment, enabling open source skill development.