Is there a clean way to manage stranded resources through cookbook modifications? For instance, let's say I have a recipe resource that writes a file from a template like so:
template 'C:\dir\somefile.txt' do
And then I update the cookbook to write that file to a different place like so:
template 'C:\some_different_dir\new_file_location.txt' do
The file from the original recipe doesn't get cleaned up automatically does it? So at that point C:\dir\somefile.txt is just stranded out there not being used.
The reason I care is because our app demands a lot of resources and I don't want a lot of disk drive space taken up over time with cookbook updates. I also don't like stranded files placed about the server because I don't want something to accidentally get picked up by one of our applications and get executed. The app I'm working on has a bunch of different services running all over the place and plus we have contracts with partners and other organizations concerning left over files and source code.
Also we can't easily move into a direction where we spin up fresh new servers when our app updates using something like Vagrant or Terraform. Once our servers are spun up, they are there for a long time. Some of them aren't even VMs.
Can anyone solve this query?