Hey,
It’s Sarvar Nadaf again, a senior developer at Luxoft. I worked on several technologies like cloud operations (Azure and AWS), DataOps, Serverless Analytics, and DevOps for various clients across the globe.
In this article, we will examine the step-by-step instructions for installing Jenkins on Amazon Linux 2. Today, I’m writing about installing Jenkins on AWS. Amazon Linux 2 requires a slightly different installation process than other Linux distributions like Ubuntu, CentOS, and RedHat. If you’ve already found this article, I’ll assume you’re familiar with the fundamentals of the Amazon cloud, what Jenkins is, why we use it, and where it’s used. So let’s get going.
Prerequisites
- You Should have an AWS account.
- Create Amazon EC2 key pair.
- Create a Security group with an 8080 Custom TCP port and 22 SSH Port Open.
Lunch Instance
Choose the AWS EC2 Instance Service and start with the Lunch Instance Option.
Select the Amazon Linux 2 AMI, as shown in the screenshot above, and the default settings will work. Just two things need to be added: first, choose an existing security group if you’ve already created one; otherwise, you can continue with the default selections; and second, choose a security key in a PEM file.
Once the EC2 instance has been fully installed. Explore our access to the EC2 instance.
Ways to Connect EC2 Instance
Here, I’ll go over the simplest methods for connecting an EC2 instance. let’s see…….
1. Connect through Web Console (Simplest way)
I personally advise you to use the below connecting method because it is fully managed by Amazon and makes it simple to access any Linux EC2 instance on the same browser without the need for a security key or any SSH Linux commands.
2. Connect through CLI (Need PEM file Handy)
This is the second technique and is frequently used in actual production environments. You have any SSH client software from a third party, such as mobaxterm, putty, or a Linux terminal. For you to access the EC2 instance, you needed a PEM file. The steps are displayed below. Simply follow those instructions to access EC2 instances.
Installing Jenkins on Amazon Linux 2
We are precisely where our discussion began here. The installation of Jenkins is about to begin. I’ll simply give you a quick overview of Jenkins right now. Jenkins is well-known for its DevOps CI-CD technology. Continuous Integration and Continued Delivery are referred to as CICD. The cornerstone of DevOps technology is Jenkins. Using AMI Amazon Linux 2, let’s examine how to configure Jenkins on Amazon EC2 Instant.
1. Use the following command to become a root. so no need for an extra command to perform the Sudo privilege.
[ec2-user ~]$ sudo su -
2. Use the following command to carry out a fast software upgrade to make sure your instance’s software packages are up to date:
[root ~]$ sudo yum update –y
3. Use the following command to add a Jenkins repo from the official Jenkins website:
[root ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.repo
4. Use the following command to import a key file from Jenkins-CI to enable installation from the package:
[root ~]$ sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
4. Use the following command to upgrade the Jenkins repo:
[ec2-user ~]$ sudo yum upgrade
5. Use the following command to install Java:
[ec2-user ~]$ sudo amazon-linux-extras install java-openjdk11 -y
6. Use the following command to install Jenkins:
[ec2-user ~]$ sudo yum install jenkins -y
7. Use the following command to enable the Jenkins service it means whenever we reboot the EC2 instance Jenkins service, it will automatically start after the reboot.
[ec2-user ~]$ sudo systemctl enable jenkins
8. Use the following command to check the status of the Jenkins service:
[ec2-user ~]$ sudo systemctl status jenkins
9. let’s start Jenkins as a service:
[ec2-user ~]$ sudo systemctl start jenkins
You have successfully configured Jenkins.
Let’s Access Jenkins Dashboard:
Now, in order to access the Jenkins user interface, you must know the public IP address of the EC2 instance where Jenkins is installed. To obtain the public IP of the EC2 instance, use the command listed below.
[root ~]$ host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
Once you have the public IP, copy the public IP address and enter it in the search bar with port 8080. My public IP address is 54.152.32.85 therefore when you search with that address and press Enter, Jenkins UI will appear, as shown in the screenshot below. If you can’t see Jenkins’ UI, please verify that the 8080 port is open in your security group.
Jenkins requires a password for login. As seen in the screenshot above, the initial admin password is often saved in /var/lib/jenkins/secrets/initialAdminPassword.
1. Use the following command to display this password:
[root ~]$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
2. Continue with the Install suggested plugins.
3. The Create First Admin User window will open after the installation is finished. After entering your data, click Save and Continue.
4. Configure Jenkins URL:
5. Here is the Jenkins Dashboard:
Congratulations! You’ve configured and installed Jenkins on the Amazon Linux 2 AMI successfully. We have witnessed the Jenkins installation process from beginning to end. I’ll publish more articles like this one, so like this one and comment below if you have any problems. I’ll try to respond to your questions as soon as I can.
— — — — — — — —
Here is the End!
I hope you like my article. I’m going to share my knowledge with you in order to make it easier for you to grasp AWS DevOps. I’ll be publishing more articles like this soon.
happy studying!