January 23, 2024

Setting up Jenkins on Amazon AWS - EC2 RHEL 9 (Red Hat Enterprise Linux)

Step#1: Creating EC2 RHEL Instance

  1. Create AWS Account
  2. Login to https://ap-southeast-2.console.aws.amazon.com/ec2/home?region=ap-southeast-2#Home (AWS Credentials)
  3. Click on Launch Instance
    1. Provide Name
    2. Select RedHat
    3. Select Amazon Machine Image (AMI)
    4. Select Instance type(t2.micro - Default)
    5. Select/Create Key pair name
      1. Create KeyPar:
        1. Key Pair Name: mykeypair
        2. Key Pare Type: RSH
        3. Private key file format: .pem
        4. Save the private key securely in your local machine
    6. Click on Edit button "Network settings"
      1. Inbound Security Group Rules
        1. Add Security Group
          1. Type: Custom TCP
          2. Port Range: 8080
          3. Source Type: Any where
    7. Click on 'Launch Instance"
  4. EC2 Instance is created. Wait Until is started (Instance State: Running; Status check: 2/2 checks passed)
  5. Get the "Public IPv4 address"

Step#2: Accessing Instance from Console

I Used MobaXTerm App to access the EC2 instance
  1. Open CMD/ MobaXTerm (App)
  2. Click on Session
  3. Select SSH
    1. Enter Remote Host Name/ID (Public IPv4 address), Port 22
    2. Advanced SSH Settings: browser SSH Key (use private SSH key)
    3. Ok

Step#3: Command to Enter on the EC2 Instance

  1. sudo yum -y install wget
    • This is to install wget on RHEL
  2. sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  3. sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
    • These two lines are for downloading the stable version of jenkins from internet.
  4. sudo yum install fontconfig java-17-openjdk
    • We require java for the functioning of jenkins.
  5. java -version
    • Ensure Java installed properly
  6. sudo yum install jenkins
    • Install Jenkins
  7. sudo systemctl daemon-reload
    • Reload systemd manager configuration. This will rerun all generators
  8. sudo systemctl status jenkins
    • To check the status of the Jenkins service
  9. sudo systemctl start jenkins
    • To Start the Jenkins service
    • Jenkins Password (This may also be found at: var/lib/jenkins/secrets/initialAdminPassword)
  10. sudo systemctl status jenkins
    • To check the status of the Jenkins service
  11. sudo systemctl enable jenkins
    • To enable the Jenkins service to start at boot with the command

Step#4: Launching Jenkins

  1. Open Browser - http://<Public_IP>:8080 --> Public IP can be found at Step#1.5
  2. Enter Jenkins Password --> Jenkins Password can be found at Step#3.9.2 or var/lib/jenkins/secrets/initialAdminPassword
  3. Create admin user - Save & Next
  4. Jenkins URL will be shown (you can change if you want)
  5. Save and Finish

0 comments:

Post a Comment