0

I have an old website that runs on a single LEMP Ubuntu server where a bunch of services are installed: NGINX, MySQL, PHP, Redis, Certbot, Postfix, WP-CLI, AWS-CLI, Fail2Ban, cron jobs and some custom scripts.

Now since I don't want to upgrade Ubuntu on a live server, when the Ubuntu version would approach the end of life I always migrate the website on a fresh VM with new LTS Ubuntu, where I would beforehand manually make sure that every service is installed and configured.

I have a document that outlines what needs to be installed, configured and how, but I find this manual approach to be really tedious, time consuming and error prone. The server now runs on Ubuntu 18.04 and although I have ESM enabled on that server which grants me updates till 2028 I guess the time has come to move the website to Ubuntu 22.04. For example VS Code stopped supporting Ubuntu 18.04 for remote access.

What I want to do is write a Python script that automatically installs and configures every service on a fresh server OR use Docker to basically do the same where every service is meticulously defined in a giant docker compose file, where services are sharing volumes, and they are using custom config files.

What would you do? What is a more sound approach? Or should I just continue manually installing everything, the migration rarely happens anyways.

2 Answers 2

1

I would suggest that you spend some real effort looking at docker-compose, it is certainly the path of least resistance in terms of what is happening to the underlying OS and packages when it comes to version updates (now you would only care about docker version, and updates).

If you do want to or are more comfortable with a bare-metal or VM setup, it would be well worth your time to do the full process once manually in 22.04, as a great many things will have changed on the base OS over 4 years (even my upgrade from 20.04 to 22.04 wasn't smooth), and then convert that to Ansible scripts, which allows you to easily switch the destination (vSphere, AWS, GCP, or local like Oracle VirtualBox). IAC (Infrastructure As Code).

All the best.

2
  • I am comfortable with all three approaches: 1. Manual installation, 2. Python scripting or 3. Docker compose. I don't have any experience with Ansible scripts. The advantage of Docker though is that regardless of the VM's OS I could deploy the exact same setup every time with very little effort. With the scripting approach the script will probably be geared towards the Ubuntu 22.04 specifically and probably somewhat unusable out of the box on a different OS. I don't know if that's the case with Ansible though. Commented Feb 6, 2024 at 17:42
  • @Vila Ansible is just a way of doing the manual installation, but it is sequenced, scripted, gives you reproducible steps, retry options, failure routes to perform cleanup or alternative steps, so would suffer from all the same issues as manual installation on various operating systems. What you say about docker is also true if you never upgrade your OS. Docker container with 18.04 might work and then running the same steps in docker container with 22.04 might fail. Commented Feb 7, 2024 at 18:20
1

Opting for Docker Compose offers a standardized and streamlined approach to managing your services across different environments. By defining all your services in a single Docker Compose file, you gain portability, scalability, and consistency in deployment.

With Docker Compose, you can easily define each service, specify dependencies, and configure volumes and networking. This simplifies the setup process and ensures that your entire stack can be spun up with a single command, reducing the potential for errors and inconsistencies.

Additionally, Docker Compose makes it straightforward to version control your entire infrastructure configuration, facilitating collaboration and reproducibility. You can easily share your Docker Compose file with team members or use it to deploy your stack across different environments, from development to production.

Overall, leveraging Docker Compose offers a robust and flexible solution for managing your services, providing ease of deployment, scalability, and consistency while reducing the manual effort required for setup and maintenance.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.