This pipeline via automation will deploy Jenkins on a AWS Fargate also the core infraestructure to support it.
Jenkins - an open source automation server which enables developers around the world to reliably build, test, and deploy their software.
The below diagram shows the AWS resources.
- These tools were installed:
- Update the file
group_vars/all/common.yml
accordingly.
---
cloudformation:
check_mode_override: false
region: ap-southeast-2
create_changeset: true
state: present
Route53:
HostedZoneName: "ugulino.com."
RecordName: "jenkins.ugulino.com"
CertificateId: "5eaa197e" # your ACM Id
ECS:
ASG_MinCapacity: 1
ASG_MaxCapacity: 10
The file deploy-role.yml
will deploy each role required to deploy this project.
---
- hosts: localhost
roles:
- vpc-baseline
- ecs-cluster
- ecs-jenkins
- route53
The below command will execute the tasks defined on the above file.
ansible-playbook deploy-role.yml -vvv
Output
You can verify the deployment via ansible output or via AWS CloudFormation console.
- Ansible Output:
- AWS CloudFormation Console:
An 'A' record was created pointing to Application Load Balancer via automation.
You can access and setup Jenkins accessing the URL https://jenkins.ugulino.com (be aware that this is my domain, probably you've setup a different one)
Automatic scaling is the ability to increase or decrease the desired count of tasks in your Amazon ECS service automatically.
Running the below command, we can stress the environment and then test the ASG.
autocannon -c 200 -d 200 -m GET https://jenkins.ugulino.com
As soon as the CPU will be consumed more than 50%, the ECS tasks will scale up.
Basically, to destroy this deployment you can either do it via ansible command or AWS CloudFormation.
Change the file group_vars/all/common.yml
cloudformation:
check_mode_override: false
region: ap-southeast-2
create_changeset: true
state: absent # this is the value you need to change to destroy the stacks
Execute the command:
ansible-playbook deploy-role.yml -vvv
Select the CloudFormation stack, click delete, and then Delete stack.