This task cleans sites-enabled dir from config files that should not be enabled anymore
Its quite easy to use a list of enabled sites
to link their config files to sites-enabled, as shown in the last entry.
There will still be links to the config files of sites that had been enabled in the previous ansible run, they need to be removed explicitly.
The simple way would be to remove the sites-enablied directory alltogether. But this would allways require
to create new links to the config files for enabled sites. Thus it would force a server restart even if there had really no changes at all. Defining a var disabled_sites
is not quite a good idea since you would probably forget to add or remove items from that list at one time.
So my solution is to list all config files that do not correspond to enabled sites and in a second step remove those.
I use it with nginx, but it should also work with apache/httpd or other configurations with a similar concept.
It would be easier to use just rm
with an extended gl