Easiest way to learn cloud technologies is to create a free account on Amazon Web Services. In here we will create a basic instance of ubuntu and setup that instance as Jenkins2.0 master and create another instance to make it a slave to master. I prefer step by step approach, so we will use AWS console instead of terminal which i will share later How To Install Jenkins using Ansible …
- Login to AWS console (assuming you have an AWS account they offer some free as well please do check on their site.
- Go to “Services” and click on “EC2”.
- Click on label “Security Groups” It renders on right side default security group.
- Click on button on top “Create Security Group”.
- Fill the fields like below screen shot
- Click on button “Create”.
- Click on “Instance” label and click on “Launch Instance”.
- Select Image type as “ubuntu 16.4 LTS”.
- Select instance type “t2.micro”.
- Click on “Review and Launch”.
- Click on “Edit Security Groups.”
- Select security group created in Step-6.
- Click on “Launch”.
- It will pop up window saying “Select an existing keypair or create a new keypair.”
- If you have already created a key pair select one or create one and download it on your local machine and keep it safe.
- Click on “Launch Instance”.
- You can see your instance “initializing” and running after in few mins.
- you can name your instance as “master001”.
- Run Command ssh -i keypair.pem ubuntu@instance_dns_default_by_aws
- Install java
-
$ sudo apt-get update
-
$ sudo apt-get install default-jre
-
$ sudo apt-get install default-jdk
-
- Install jenkins
$ wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - $ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install jenkins
- Run Jenkins:
$ sudo service jenkins start
- Create a slave instance as master on AWS.
- Setup basic JRE setup on AWS.
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install default-jre
- Create ssh key on master node by running
ssh-keygen -t rsa
- Copy the key from id_rsa.pub to slave instances .ssh/authorized_keys
-
Run command on your master node (default algorthim may not let you connect from jenkins) ssh -o HostKeyAlgorithms=ssh-rsa ubuntu@master_instance_node
- Navigate to url “master_instance_dns:8080/”
- It will ask the password and also show you the location of password which has to be retrieved by ssh to your master node.
- In Jenkins console go to Jenkins>>Manage Jenkins > manage nodes.
- Add node it opens up pop up window.
- in pop up window
- add name to your slave slave001.
- add remote root directory “/home/ubuntu/”.
- select from drop down “Launch Method” “Launch slave agents via ssh”.
- add Host “slave/node machine” and add credentials by copying private ssh key generated in master machine for user ubuntu.
- Click on “Save”.
- Now you have jenkins master/slave running.
Cheers!! Create a pipeline and run it on this setup.