DEV Community

arielro85
arielro85

Posted on

4

Full Stack Deployment with Ansible

A few months ago I started practicing ansible and some Javascript with React and NodeJs.
As a playground im using some EC2 instances in AWS, and I did not want to re configure everything everytime that I test the site . For this I wrote an Ansible playbook that performs all the required actions to get the app online.

High level overview of what it does:

  • Extracts the repository names from the frontend_git_repo and backend_git_repo variables.
  • Updates the system packages and reboots the machine if updates were installed.
  • Installs gnupg and curl, which are required for MongoDB.
  • Sets up the NodeSource repository and installs Node.js.
  • Checks if the MongoDB GPG key is already set up, and if not, it sets it up.
  • Creates a list file for MongoDB and updates the package list.
  • Installs MongoDB and starts the mongod service.
  • Installs pm2 globally, which is a process manager for Node.js applications.
  • Installs the Nginx web server and configures it.
  • Copies the SSH key to the EC2 instance.
  • Clones the frontend and backend repositories from GitHub.
  • Creates a new folder in the backend directory.
  • Deletes the copied SSH key from the EC2 instance.
  • Builds the frontend application and moves it to the appropriate directory.
  • Configures pm2 for the backend application and starts it.
  • Restarts the Nginx service.

All the actions above described , are handled by Ansible and a UI called Ansible Semaphore.

Everything is in this repo where you can find the "Mean Stack playbook" and the Ansible Semaphore Docker comppose file to build the controller.

Image description

I really recommend to use Ansible or any tool you want to avoid spending lot of time installing and configuring test services.

For sure there is lot of room for improvements, but it saves a lot of time.
My humble collaboration:

https://github.com/imaerials/ansible-home-lab

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (1)

Collapse
 
su_subh1 profile image
Subh •

I really liked the project.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

AWS GenAI Live!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️