Skip to content

Commit 4bd247b

Browse files
authored
Merge pull request #43 from pratik2135/enhancements-setup
Addressing issue and Fixes for packer-based AMI's & Compatibility
2 parents 2b36be1 + 045bd7b commit 4bd247b

File tree

12 files changed

+76
-52
lines changed

12 files changed

+76
-52
lines changed

01-jenkins-setup/ansible/jenkins-controller.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
vars:
88
efs_mount_dir: "/data"
99
jenkins_data_dir: "/data/jenkins"
10-
jenkins_lts_version: "2.387.1"
10+
jenkins_lts_version: "2.492.1"
1111

1212

1313
roles:

01-jenkins-setup/ansible/roles/jenkins-agent/tasks/ssh.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
script: "{{ playbook_dir }}/scripts/get-ssh-pub.py {{ public_key_path }}"
44
args:
55
executable: /usr/bin/python3
6-
remote_src: yes
76
register: secret_value
87

98
- name: Print registered variable

01-jenkins-setup/ansible/roles/jenkins-agent/tasks/tools.yaml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,41 @@
99
name: python3-pip
1010
state: present
1111

12-
- name: Install boto3 using pip3
13-
become: true
14-
pip:
15-
name: boto3
12+
- name: Install boto3 using apt
13+
apt:
14+
name: python3-boto3
1615
state: present
16+
become: yes
1717

18-
- name: Install AWS CLI using pip
19-
become: true
20-
pip:
21-
name: awscli
22-
state: latest
23-
executable: pip3
18+
- name: Install dependencies
19+
apt:
20+
name:
21+
- curl
22+
- unzip
23+
state: present
24+
25+
- name: Download AWS CLI installation script
26+
shell: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"
27+
28+
- name: Unzip AWS CLI installation package
29+
unarchive:
30+
src: /tmp/awscliv2.zip
31+
dest: /tmp/
32+
remote_src: yes
33+
34+
- name: Install AWS CLI
35+
shell: sudo /tmp/aws/install
2436

2537
- name: Install Ansible
26-
pip:
38+
apt:
2739
name: ansible
2840
state: latest
2941

30-
- name: Add HashiCorp GPG key
31-
become: yes
32-
shell: "wget -qO- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg"
42+
- name: Download and convert HashiCorp GPG key in one step
43+
shell: |
44+
curl -fsSL https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
45+
args:
46+
creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
3347

3448
- name: Add HashiCorp APT repository
3549
become: yes

01-jenkins-setup/ansible/roles/jenkins-controller/tasks/base.yaml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,30 @@
1313
name: python3-pip
1414
state: present
1515

16-
- name: Install boto3 using pip3
17-
become: true
18-
pip:
19-
name: boto3
16+
- name: Install boto3 using apt
17+
apt:
18+
name: python3-boto3
19+
state: present
20+
become: yes
21+
22+
- name: Install dependencies
23+
apt:
24+
name:
25+
- curl
26+
- unzip
2027
state: present
2128

22-
- name: Install AWS CLI using pip
23-
become: true
24-
pip:
25-
name: awscli
26-
state: latest
27-
executable: pip3
29+
- name: Download AWS CLI installation script
30+
shell: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"
31+
32+
- name: Unzip AWS CLI installation package
33+
unarchive:
34+
src: /tmp/awscliv2.zip
35+
dest: /tmp/
36+
remote_src: yes
37+
38+
- name: Install AWS CLI
39+
shell: sudo /tmp/aws/install
2840

2941
- name: Install Java JDK 17
3042
apt:

01-jenkins-setup/ansible/scripts/get-ssh-pub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
import json
33
import sys
44

5-
client = boto3.client('ssm', region_name='us-west-2')
5+
client = boto3.client('ssm', region_name='us-east-1')
66
response = client.get_parameter(Name=sys.argv[1], WithDecryption=True)
77
print(response['Parameter']['Value'])

01-jenkins-setup/jenkins-agent.pkr.hcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
variable "ami_id" {
22
type = string
3-
default = "ami-0735c191cf914754d"
3+
default = "ami-04b4f1a9cf54c11d0"
44
}
55

66
variable "public_key_path" {
@@ -15,8 +15,8 @@ locals {
1515
source "amazon-ebs" "jenkins" {
1616
ami_name = "${local.app_name}"
1717
instance_type = "t2.micro"
18-
region = "us-west-2"
19-
availability_zone = "us-west-2a"
18+
region = "us-east-1"
19+
availability_zone = "us-east-1c"
2020
source_ami = "${var.ami_id}"
2121
ssh_username = "ubuntu"
2222
iam_instance_profile = "jenkins-instance-profile"
@@ -31,7 +31,7 @@ build {
3131

3232
provisioner "ansible" {
3333
playbook_file = "ansible/jenkins-agent.yaml"
34-
extra_arguments = [ "--extra-vars", "public_key_path=${var.public_key_path}", "--scp-extra-args", "'-O'", "--ssh-extra-args", "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa" ]
34+
extra_arguments = [ "--extra-vars", "public_key_path=${var.public_key_path}", "--scp-extra-args", "'-O'", "--ssh-extra-args", "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa" ]
3535
}
3636

3737
post-processor "manifest" {

01-jenkins-setup/jenkins-controller.pkr.hcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
variable "ami_id" {
22
type = string
3-
default = "ami-0735c191cf914754d"
3+
default = "ami-04b4f1a9cf54c11d0"
44
}
55

66
variable "efs_mount_point" {
@@ -9,14 +9,14 @@ variable "efs_mount_point" {
99
}
1010

1111
locals {
12-
app_name = "jenkins-controller"
12+
app_name = "jenkins-controller-updated"
1313
}
1414

1515
source "amazon-ebs" "jenkins" {
1616
ami_name = "${local.app_name}"
1717
instance_type = "t2.micro"
18-
region = "us-west-2"
19-
availability_zone = "us-west-2a"
18+
region = "us-east-1"
19+
availability_zone = "us-east-1d"
2020
source_ami = "${var.ami_id}"
2121
ssh_username = "ubuntu"
2222
tags = {
@@ -30,7 +30,7 @@ build {
3030

3131
provisioner "ansible" {
3232
playbook_file = "ansible/jenkins-controller.yaml"
33-
extra_arguments = [ "--extra-vars", "ami-id=${var.ami_id} efs_mount_point=${var.efs_mount_point}", "--scp-extra-args", "'-O'", "--ssh-extra-args", "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa" ]
33+
extra_arguments = [ "--extra-vars", "ami-id=${var.ami_id} efs_mount_point=${var.efs_mount_point}", "--scp-extra-args", "'-O'", "--ssh-extra-args", "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa" ]
3434
}
3535

3636
post-processor "manifest" {
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
provider "aws" {
2-
region = "us-west-2"
2+
region = "us-east-1"
33
}
44

55
module "ec2_instance" {
66
source = "../modules/ec2"
7-
87
instance_name = "jenkins-agent"
9-
ami_id = "ami-0e68ab34763bcba1f"
8+
ami_id = "ami-0fe5ed92a8c77d79f"
109
instance_type = "t2.small"
11-
key_name = "techiescamp"
12-
subnet_ids = ["subnet-058a7514ba8adbb07", "subnet-0dbcd1ac168414927", "subnet-032f5077729435858"]
10+
key_name = "jenkinskey"
11+
subnet_ids = ["subnet-046c3f4390fc51b7e", "subnet-02727435b393c516c", "subnet-0ed1c80066f1be7ed"]
1312
instance_count = 1
1413
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
provider "aws" {
2-
region = "us-west-2"
2+
region = "us-east-1"
33
}
44

55
module "efs_module" {
66
source = "../modules/efs"
7-
vpc_id = "vpc-0a5ca4a92c2e10163"
8-
subnet_ids = ["subnet-058a7514ba8adbb07", "subnet-0dbcd1ac168414927", "subnet-032f5077729435858"]
7+
vpc_id = "vpc-0872a2ffd55e763ca"
8+
subnet_ids = ["subnet-046c3f4390fc51b7e", "subnet-02727435b393c516c", "subnet-0ed1c80066f1be7ed"]
99
}

01-jenkins-setup/terraform/iam/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "aws" {
2-
region = "us-west-2"
2+
region = "us-east-1"
33
}
44

55
module "jenkins_iam" {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
provider "aws" {
2-
region = "us-west-2"
2+
region = "us-east-1"
33
}
44

55
module "lb-asg" {
66
source = "../modules/lb-asg"
7-
subnets = ["subnet-058a7514ba8adbb07", "subnet-0dbcd1ac168414927", "subnet-032f5077729435858"]
8-
ami_id = "ami-074d40b56472c5b9b"
7+
subnets = ["subnet-046c3f4390fc51b7e", "subnet-02727435b393c516c", "subnet-0ed1c80066f1be7ed"]
8+
ami_id = "ami-0e9419006a1fc1387"
99
instance_type = "t2.small"
10-
key_name = "techiescamp"
10+
key_name = "jenkinskey"
1111
environment = "dev"
12-
vpc_id = "vpc-0a5ca4a92c2e10163"
12+
vpc_id = "vpc-0872a2ffd55e763ca"
1313
}

01-jenkins-setup/terraform/modules/ec2/variable.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "aws" {
2-
region = "us-west-2"
2+
region = "us-east-1"
33
}
44

55
variable "instance_name" {
@@ -19,7 +19,7 @@ variable "instance_type" {
1919

2020
variable "key_name" {
2121
type = string
22-
default = "techiescamp"
22+
default = "jenkinskey"
2323
}
2424

2525
variable "security_group_ids" {

0 commit comments

Comments
 (0)