Creating a Jenkins
Pipeline which will provision several EC2
instances using terraform
and then installing Docker
on the EC2
instances using Ansible
- Jenkins master server on AWS
- Two Jenkins Agent (slaves)
- Must have
git
,terraform
, andansible
installed - Must have appropriate
IAM instance profile
attached
- Must have
- Jenkins pipeline job
- Terraform: Under the
infra-using-terraform
folder we haveterraform
code, which will provision multiple EC2 instances onAWS
. Note:EC2
instances will be provisioned fromUbuntu
AMI andAmazon linux2
AMI. Which represents different linux distributions. - Ansible playbook: We have
three
ansible-playbook.docker_install_on_ubuntu.yaml
docker_install_on_amazon_linux.yaml
docker_installation_playbook.yaml
for calling appropriateplaybook
as per linux distro.
Jenkinsfile
which will be used to configure Jenkins pipeline job.
Our pipeline will use two
jenkins slaves. One is labeled as common
and another one is ansible
.
On the common
labeled slave all the stages will be built, and for running ansible-playbook
we will use ansible
labeled slave.