Hi there!
I have a problem when reprovisioning a site. To make it more clear I will describe first what I want to achieve. ATM we have a staging server where I provisioned Trellis. We want to use this server as a preview server for our customer websites. So we need to add, delete, undelete and destroy sites. All sites are using letsencrypt.
Adding a new site is straight forward:
- Setup Letsencrypt
$ ansible-playbook server.yml -e “env= site=” --tags letsencrypt - Setup WordPress
$ ansible-playbook server.yml -e “env= site=” --tags wordpress - Deploy
$ ansible-playbook deploy.yml -e “env= site=”
To delete, undelete and destroy a site I wrote new ansible playbooks.
The delete playbook basically takes all files for that site (the www-folder, nginx confs, ssl certs and keys), makes a db dump and moves all to a specified “delete folder” and after that it restarts nginx.
The destroy playbook will than really delete those files. These two playbooks work fine.
But I also want to have an undelete playbook where you can undo the changes done by the delete playbook and this is it where it gets complicated. To re-add the site I do the following:
-
Setup Letsencrypt
$ ansible-playbook server.yml -e “env= site=” --tags letsencrypt -
Setup WordPress
$ ansible-playbook server.yml -e “env= site=” --tags wordpress -
Undelete site
$ ansible-playbook undelete.yml -e “env= site=”
–> imports the db dump and moves the site back to srv/www/
But it fails at step 1 on the letsencrypt task “Test Acme Challenges” for the site I want to re-add. The Task “Notify of challenge failures” tells me than that it can not access the challenge file for that domain. Restarting nginx is also not working anymore. It says: “nginx: configuration file /etc/nginx/nginx.conf test failed”, “Process: 32077 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)” and “Failed to start A high performance web server and a reverse proxy server.”
So I am pretty sure that my delete playbook does not work properly. Since I can not upload the playbook/role here I will tell you what I am doing in that role exactly:
- Create database dump and delete database
- Remove .conf files for that site from …nginx/sites-available and remove symlink from …nginx/sites-enabled
- Remove cron job file from …cron.d folder
- Remove certificates and keys for that site from …nginx/ssl/letsencrypt
- Restart nginx
On monday (in three days) I have to present my solution for our dedicated webserver in my office. So I would really appreciate if someone can help me out here.
Thanks in advance!
- Philipp