I have a role for configuring nginx. As you'd expect, it adds files to a directory that is then included by the main config file. I've started to run into issues with the order in which these files are read so I'd like to move some of them into another directory that's included after this one.
The problem is that the role has already been run in several places so if I just change the path of some of the config files to the new directory then old copies will be left behind in the old directory. Solutions I've thought of are:
- Include tasks to delete the old files - this feels like clutter that's going to be stuck in the role forever.
- Delete everything in the directory and let the role recreate the files that are supposed to be there - files from other sources (e.g. other roles or the same role run multiple times) will be lost.
In this case I know everywhere that the role has been used so I could just wait until I know the old files are gone then remove the steps that get rid of them or even remove the files manually but that certainly doesn't scale. Are there any established practices for dealing with this sort of issue or ways of thinking about it that I should know about?