icon
Ansible Web application Deployment
Auto deploy web application with Ansible in multi base: EC2, VMachine, Container,..
contributors last update forks stars open issues license
Documentation β’ Report Bug β’ Request Feature
Table of Contents
Before proceeding with the installation and usage of this project, ensure that you have the following prerequisites in place:
-
Network Connectivity: Docker requires network connectivity to download images, communicate with containers, and access external resources.
-
Each machine base have its own require
If you wanna run this project with ec2 base, you must set up environment variables in .env
file in ./aws-ec2
EC2 config (.env
):
AWS_ACCESS_KEY_ID
*: Unique identifier for AWS authentication.AWS_SECRET_ACCESS_KEY
*: Confidential key for securely signing AWS API requests.Get access key id and secret at here
AWS_REGION
: AWS server location for services (default: ap-southeast-1)List AWS available region
AMI_ID
: Identifier for AMD processors (default: ami-0df7a207adb9748c7)- Find AMI_ID at here
- Make sure that
AMI_ID
running it in theAWS_REGION
that you want to deploy to.
INSTANCE_NAME
: Unique identifier for virtual servers. (default: quanblue)INSTANCE_TYPE
: AWS server configuration specification. (default: t2.micro)KEY_PAIR_NAME
: name of key pair (default: quanblue_key_pair)SECURITY_GROUP_NAME
: name of security group (default: quanblue_sg)
Example:
# .env
AWS_ACCESS_KEY_ID=[your access key]
AWS_SECRET_ACCESS_KEY=[your secret key]
AWS_REGION=ap-southeast-1
AMI_ID=ami-0df7a207adb9748c7
INSTANCE_NAME=quanblue
INSTANCE_TYPE=t2.micro
KEY_PAIR_NAME=quanblue_key_pair
SECURITY_GROUP_NAME=quanblue_sg
Note:
- Which environment variables not have default value, you need to add it to
.env
file.- You can also check out the file
.env.example
to see all required environment variables.- If you want to use this example environment, you need to rename it to .env.
To deploy this project, with each base, follow these steps:
Container base:
bash ./container_deploy.sh
You can watch IPv4 address of all container in ansible-net
network
$ docker network inspect --format='{{range .Containers}}{{.Name}}: {{.IPv4Address}}{{"\n"}}{{end}}' ansible-net
ansible-controller: 172.18.0.2/16
backend: 172.18.0.7/16
prometheus: 172.18.0.3/16
alertmanager: 172.18.0.4/16
grafana: 172.18.0.5/16
frontend: 172.18.0.6/16
Virtual machine base:
bash ./vmachine_deploy.sh
EC2 base:
bash ./ec2_deploy.sh
Automatic deploy web application with 3 base: container
, virtual machine
and ec2
follow these steps:
- Remove all old machine and component attach with them
- Create new machines (Ansible and remote machines)
- Set up ssh key for machines
- Generate inventory file
- From Ansible machine:
- Add remote machines to the known hosts list
- Copy all setup files from host machine
- Play playbook to setup remote machines
- Deploy
- Application
- Deploy monitoring and logging components
- Deploy Application on
- Docker - Container
- Vagrant - VMachine
- AWS - EC2
- Menu UI
Contributions are always welcome!
Distributed under the MIT License. See LICENSE
for more information.
Bento @quanblue Β· GitHub @QuanBlue Β· Gmail quannguyenthanh558@gmail.com