How to clean up provisioned, deployed and deleted websites?

Hi guys,

I’m using Trellis and Bedrock to provision and deploy WordPress websites, and so far it works out great. I’m wondering about one thing though. How do I keep my Digital Ocean droplet clean?

Flow

  1. Add website example.com and its credentials to wordpress_sites.yml and vault.yml
  2. Provision server and deploy website
  3. Remove example.com and its credentials from wordpress_sites.yml and vault.yml
  4. Re-provision server (without example.com credentials)

Now, when I SSH into my server I can still see the nginx configuration files in /etc/nginx/sites-available, the folders in /srv/www/example.com and the database of example.com. Is it weird I expected to see these files removed? If not, how can or should I clean these files up?

Thanks in advance,

Dave van Hoorn

1 Like

No, I’d probably expect that as well. It’s actually never come up until now. I have a feeling people don’t remove sites too often.

It’s not very easy to dynamically remove things via Ansible. Here’s one existing place we do it: https://github.com/roots/trellis/blob/cbe647a26a95126a3cf7fd8ace7f1f2f0454adf0/roles/wordpress-setup/tasks/nginx.yml#L26-L48

It’s not nice :frowning: I suggest just manually deleting folders/confs/databases.

Allright, I’ll manually remove the files. Thanks for getting back to me.

Could you maybe provide steps what/where/how to manually delete the files, without resorting to full purge of the box?

I guess rm -rf /srv/www/<SITE> would be the first step. How to delete databases for old sites?

Thanks in advance!

3 Likes