Skip to content

Addressing issue and Fixes for packer-based AMI's & Compatibility #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 01-jenkins-setup/ansible/jenkins-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
vars:
efs_mount_dir: "/data"
jenkins_data_dir: "/data/jenkins"
jenkins_lts_version: "2.387.1"
jenkins_lts_version: "2.492.1"


roles:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
script: "{{ playbook_dir }}/scripts/get-ssh-pub.py {{ public_key_path }}"
args:
executable: /usr/bin/python3
remote_src: yes
register: secret_value

- name: Print registered variable
Expand Down
42 changes: 28 additions & 14 deletions 01-jenkins-setup/ansible/roles/jenkins-agent/tasks/tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,41 @@
name: python3-pip
state: present

- name: Install boto3 using pip3
become: true
pip:
name: boto3
- name: Install boto3 using apt
apt:
name: python3-boto3
state: present
become: yes

- name: Install AWS CLI using pip
become: true
pip:
name: awscli
state: latest
executable: pip3
- name: Install dependencies
apt:
name:
- curl
- unzip
state: present

- name: Download AWS CLI installation script
shell: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"

- name: Unzip AWS CLI installation package
unarchive:
src: /tmp/awscliv2.zip
dest: /tmp/
remote_src: yes

- name: Install AWS CLI
shell: sudo /tmp/aws/install

- name: Install Ansible
pip:
apt:
name: ansible
state: latest

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

- name: Add HashiCorp APT repository
become: yes
Expand Down
32 changes: 22 additions & 10 deletions 01-jenkins-setup/ansible/roles/jenkins-controller/tasks/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,30 @@
name: python3-pip
state: present

- name: Install boto3 using pip3
become: true
pip:
name: boto3
- name: Install boto3 using apt
apt:
name: python3-boto3
state: present
become: yes

- name: Install dependencies
apt:
name:
- curl
- unzip
state: present

- name: Install AWS CLI using pip
become: true
pip:
name: awscli
state: latest
executable: pip3
- name: Download AWS CLI installation script
shell: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"

- name: Unzip AWS CLI installation package
unarchive:
src: /tmp/awscliv2.zip
dest: /tmp/
remote_src: yes

- name: Install AWS CLI
shell: sudo /tmp/aws/install

- name: Install Java JDK 17
apt:
Expand Down
2 changes: 1 addition & 1 deletion 01-jenkins-setup/ansible/scripts/get-ssh-pub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import json
import sys

client = boto3.client('ssm', region_name='us-west-2')
client = boto3.client('ssm', region_name='us-east-1')
response = client.get_parameter(Name=sys.argv[1], WithDecryption=True)
print(response['Parameter']['Value'])
8 changes: 4 additions & 4 deletions 01-jenkins-setup/jenkins-agent.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "ami_id" {
type = string
default = "ami-0735c191cf914754d"
default = "ami-04b4f1a9cf54c11d0"
}

variable "public_key_path" {
Expand All @@ -15,8 +15,8 @@ locals {
source "amazon-ebs" "jenkins" {
ami_name = "${local.app_name}"
instance_type = "t2.micro"
region = "us-west-2"
availability_zone = "us-west-2a"
region = "us-east-1"
availability_zone = "us-east-1c"
source_ami = "${var.ami_id}"
ssh_username = "ubuntu"
iam_instance_profile = "jenkins-instance-profile"
Expand All @@ -31,7 +31,7 @@ build {

provisioner "ansible" {
playbook_file = "ansible/jenkins-agent.yaml"
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" ]
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" ]
}

post-processor "manifest" {
Expand Down
10 changes: 5 additions & 5 deletions 01-jenkins-setup/jenkins-controller.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "ami_id" {
type = string
default = "ami-0735c191cf914754d"
default = "ami-04b4f1a9cf54c11d0"
}

variable "efs_mount_point" {
Expand All @@ -9,14 +9,14 @@ variable "efs_mount_point" {
}

locals {
app_name = "jenkins-controller"
app_name = "jenkins-controller-updated"
}

source "amazon-ebs" "jenkins" {
ami_name = "${local.app_name}"
instance_type = "t2.micro"
region = "us-west-2"
availability_zone = "us-west-2a"
region = "us-east-1"
availability_zone = "us-east-1d"
source_ami = "${var.ami_id}"
ssh_username = "ubuntu"
tags = {
Expand All @@ -30,7 +30,7 @@ build {

provisioner "ansible" {
playbook_file = "ansible/jenkins-controller.yaml"
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" ]
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" ]
}

post-processor "manifest" {
Expand Down
9 changes: 4 additions & 5 deletions 01-jenkins-setup/terraform/agent/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
provider "aws" {
region = "us-west-2"
region = "us-east-1"
}

module "ec2_instance" {
source = "../modules/ec2"

instance_name = "jenkins-agent"
ami_id = "ami-0e68ab34763bcba1f"
ami_id = "ami-0fe5ed92a8c77d79f"
instance_type = "t2.small"
key_name = "techiescamp"
subnet_ids = ["subnet-058a7514ba8adbb07", "subnet-0dbcd1ac168414927", "subnet-032f5077729435858"]
key_name = "jenkinskey"
subnet_ids = ["subnet-046c3f4390fc51b7e", "subnet-02727435b393c516c", "subnet-0ed1c80066f1be7ed"]
instance_count = 1
}
6 changes: 3 additions & 3 deletions 01-jenkins-setup/terraform/efs/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
provider "aws" {
region = "us-west-2"
region = "us-east-1"
}

module "efs_module" {
source = "../modules/efs"
vpc_id = "vpc-0a5ca4a92c2e10163"
subnet_ids = ["subnet-058a7514ba8adbb07", "subnet-0dbcd1ac168414927", "subnet-032f5077729435858"]
vpc_id = "vpc-0872a2ffd55e763ca"
subnet_ids = ["subnet-046c3f4390fc51b7e", "subnet-02727435b393c516c", "subnet-0ed1c80066f1be7ed"]
}
2 changes: 1 addition & 1 deletion 01-jenkins-setup/terraform/iam/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "aws" {
region = "us-west-2"
region = "us-east-1"
}

module "jenkins_iam" {
Expand Down
10 changes: 5 additions & 5 deletions 01-jenkins-setup/terraform/lb-asg/main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
provider "aws" {
region = "us-west-2"
region = "us-east-1"
}

module "lb-asg" {
source = "../modules/lb-asg"
subnets = ["subnet-058a7514ba8adbb07", "subnet-0dbcd1ac168414927", "subnet-032f5077729435858"]
ami_id = "ami-074d40b56472c5b9b"
subnets = ["subnet-046c3f4390fc51b7e", "subnet-02727435b393c516c", "subnet-0ed1c80066f1be7ed"]
ami_id = "ami-0e9419006a1fc1387"
instance_type = "t2.small"
key_name = "techiescamp"
key_name = "jenkinskey"
environment = "dev"
vpc_id = "vpc-0a5ca4a92c2e10163"
vpc_id = "vpc-0872a2ffd55e763ca"
}
4 changes: 2 additions & 2 deletions 01-jenkins-setup/terraform/modules/ec2/variable.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "aws" {
region = "us-west-2"
region = "us-east-1"
}

variable "instance_name" {
Expand All @@ -19,7 +19,7 @@ variable "instance_type" {

variable "key_name" {
type = string
default = "techiescamp"
default = "jenkinskey"
}

variable "security_group_ids" {
Expand Down