For some tasks, you want to run them only once on server creating.
For example create an empty database on server creating, or you can even restore the last known backup on creating a new database VM. Surely you do not want to run it on subsequent ansible runs to not to overwrite the latest changes to the database.
There are many ways in ansible to achieve this:
create a custom fact on the first run touch some file to signal to the subsequent runs, that one run already happened But I prefer behaviour-based checks, the same way I used to do it in JavaScript - never check for the browser agent-string, check for the desired behaviour.
read more