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

Conversation

pratik2135
Copy link

This PR addresses a series of issues encountered while creating a Packer-based AMI for the Jenkins controller and agent. The changes include configuration updates, compatibility fixes, and module improvements to ensure smooth AMI creation, Jenkins deployment, and Terraform integration.

🧩 Context / Problem Statement

While building Jenkins AMI images using Packer and Ansible, several issues were encountered due to outdated or unsupported configurations and package installation conflicts:

  • ❌ SSH Connection Failure due to pubkeyacceptedalgorithms not being recognized.
  • ❌ AWS CLI installation failure in an externally-managed Python environment.
  • ❌ GPG key download failure during HashiCorp repository setup.
  • ❌ Unsupported remote_src parameter in Ansible script module.
  • ❌ Jenkins controller used an outdated version that blocked essential plugin downloads.

Note: This setup and investigation were conducted on several different machines to better understand and replicate the errors encountered.


✅ Changes Implemented

🔧 Packer Configuration

  • Removed unsupported pubkeyacceptedalgorithms from the SSH configuration to resolve connectivity issues.

📦 AWS CLI & Python Environment Fix

  • Replaced pip-based CLI installation with apt-based and direct URL-based installation.
  • Ensured dependencies (curl, unzip, etc.) are installed via Ansible before CLI installation.

🔐 HashiCorp GPG Key Fix

  • Updated GPG key download using curl -fsSL for clean, silent fetch.
  • Used --dearmor to convert the GPG key to the required binary format.
  • Ensured idempotency with appropriate creates directive in Ansible.

🧾 Secret Retrieval Fix

  • Removed unsupported remote_src parameter from the Ansible script module to fix failure during AWS SSM secret retrieval.

🏗️ Jenkins AMI and Terraform Updates

  • Upgraded Jenkins to version 2.492.1.
  • Created a new Jenkins controller AMI with the updated version.
  • Updated Terraform configuration to use the new AMI.
    • Ensured only the launch template was modified — no disruption to other resources.

📸 Screenshots / Logs

Refer to the attached screenshots for:

  • Error traces
  • Configuration changes
  • Successful plugin install validation

image

image


🧪 Testing

  • ✅ Successfully built Jenkins controller and agent AMIs.
  • ✅ Verified AWS CLI installation through Ansible provisioning.
  • ✅ Ran terraform plan post-AMI creation — only the intended AMI change observed.
  • ✅ Jenkins controller

Request for Review

This PR is ready for review. I’d appreciate feedback on:

  • 🔍 Compatibility with the repository’s Ansible and Terraform standards.
  • 🧹 Opportunities to improve idempotency and maintainability in the automation scripts.

Let me know if any changes are needed!

…ncies like curl, unzip packages along with python boto3 library. Download & conversion of gpg key was modified using curl command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant