Restarting HTTPD is not idempotence in nature , suggest a way to rectify this challenge.
An operation is idempotent if the result of performing it once is exactly the same as the result of performing it repeatedly without any intervening actions.
Sometimes you want a task to run only when a change is made on a machine. Ansible uses handlers to address this use case. Handlers are tasks that only run when notified. Each handler should have a globally unique name.
So, to solve this problem of idempotence we will use handlers.
When we run this playbook handlers will get notified if there is change in the file we have copied. so, if handlers will be notified they will restart the service otherwise it won’t.
Now if we try running the same playbook again . It won’t restart the service.
Like this we can solve the problem of idempotence