Jenkins pipeline runs Terraform to provision resources on aws, Ansible to configure 2 private instances to be a jenkins slave and install docker on it, and lastly invoking the pipelines responsible for deploying this node app on these two instances by build the docker image and using these jenkinsfiles Jenkinsfile, Jenkins_private2.
I deployed jenkins master server as a docker custom image on my machine.
First you need to install docker on your machine
I used a custom image I built to deploy the master server which is basically a jenkins image with docker-ce-cli. You would need it if you want to run docker command but in our case we will not need it, so you can use the official jenkins image.
docker run jenkins
docker run refay/jenkins_master:1.0
Before heading to Jenkins Configuration make sure to check Terraform resources and configuration.
Note: that other versions of tools or plugins may work but I mentioned the versions that worked for me.
Terraform:
I used terraform plugin version 1.0.10 check plugins reference for terraform for more info.
Then After Jenkins restarts, go to global tool configuration and terraform installation as follows.
Ansible:
I installed ansible as a deb package from apt package manager.
but first you need to exec into the container as root.
docker exec -it -u root <containe_name_or_id> bash
Then run
apt install ansible
after installing ansible you need to provide the binary path in the global tool configuration as follows:
