Skip to content

Improve setting up networking infra - #868

Open
lscalabrini01 wants to merge 13 commits into
rancher:mainfrom
lscalabrini01:qa-issue_2513-sg
Open

Improve setting up networking infra#868
lscalabrini01 wants to merge 13 commits into
rancher:mainfrom
lscalabrini01:qa-issue_2513-sg

Conversation

@lscalabrini01

@lscalabrini01 lscalabrini01 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the security and flexibility of the Jenkins E2E infrastructure provisioning pipelines by dynamically detecting the runner's public IP address and using it to restrict SSH and load balancer ingress rules. It also cleans up and standardizes AWS networking configuration across several Jenkinsfiles, removing hardcoded security groups and making VPC, subnet, and security group assignments more explicit and consistent.

Key changes include:

Dynamic Public IP Detection and Usage

  • Added logic to auto-detect the runner's public IPv4 address in all relevant Jenkinsfiles (Jenkinsfile.e2e, Jenkinsfile.multibranch.e2e, and pipeline files under validation/pipeline/qainfra/). This IP is then injected into the pipeline environment and used in Terraform/Ansible configurations to restrict ephemeral security group ingress to only the runner's IP, enhancing security. [1] [2] [3] [4]

Pipeline Environment and Configuration Updates

  • Updated environment variable injection throughout pipeline stages to include the detected RUNNER_PUBLIC_IP, ensuring all downstream steps and configuration templates can use the correct IP. [1] [2] [3]

Networking and Security Group Configuration Cleanup

  • Removed hardcoded AWS security group IDs from pipeline and configuration blocks, replacing them with explicit VPC, subnet, and security group assignments. This standardizes network configuration and makes it easier to manage across environments. [1] [2] [3] [4] [5] [6] [7] [8]

Template and Config Variable Propagation

  • Ensured that the detected public IP is properly propagated into all relevant Terraform and Ansible configuration templates by replacing the ${RUNNER_PUBLIC_IP} placeholder in the configuration files. [1] [2] [3]

These changes collectively improve security by minimizing SSH/LB exposure, increase maintainability, and reduce the risk of misconfiguration in CI/CD infrastructure automation.

@lscalabrini01 lscalabrini01 self-assigned this Aug 31, 2026
@lscalabrini01 lscalabrini01 added the team/pit-crew slack notifier for pit crew label Aug 31, 2026
@lscalabrini01
lscalabrini01 marked this pull request as ready for review August 31, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

validation/pipeline/qainfra/Jenkinsfile.capi.e2e:114

  • This log line prints env.RUNNER_PUBLIC_IP, but that environment variable is never set in this Jenkinsfile. This will typically log "null" and makes debugging harder.
              echo "Detected runner public IP: ${env.RUNNER_PUBLIC_IP}"

  • Files reviewed: 5/5 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread validation/Jenkinsfile.e2e Outdated
Comment thread validation/pipeline/qainfra/Jenkinsfile.capi.e2e Outdated
Comment thread validation/pipeline/qainfra/Jenkinsfile.elemental.e2e Outdated
Comment thread validation/pipeline/qainfra/Jenkinsfile.elemental.harvester.e2e Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
hamistao
hamistao previously approved these changes Sep 1, 2026

@hamistao hamistao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just would like to know what do you think of rancher/qa-infra-automation#199 (comment) since it could impact this,

Comment thread validation/pipeline/qainfra/Jenkinsfile.capi.e2e Outdated
Comment on lines +99 to +111
def publicIp = sh(
script: '''
(curl -4 -fsS --max-time 5 https://ifconfig.me ||
curl -4 -fsS --max-time 5 https://api.ipify.org ||
curl -4 -fsS --max-time 5 https://ipinfo.io/ip) | tr -d '[:space:]'
''',
returnStdout: true
).trim()

def octets = publicIp.tokenize('.')
if (octets.size() != 4 || !octets.every { it ==~ /\d{1,3}/ && it.toInteger() >= 0 && it.toInteger() <= 255 }) {
error "Failed to auto-detect a valid public IPv4 address (got: '${publicIp}')"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being repeated makes me think this would be a good addition to qa-jenkins-library

slickwarren
slickwarren previously approved these changes Sep 2, 2026
@lscalabrini01
lscalabrini01 dismissed stale reviews from slickwarren and hamistao via c15ca30 September 3, 2026 20:43
@lscalabrini01
lscalabrini01 force-pushed the qa-issue_2513-sg branch 2 times, most recently from b8eb302 to 7b1f8fe Compare September 4, 2026 21:21
Comment on lines +573 to +595
stage('Detect Public IP') {
steps {
script {
def publicIp = sh(
script: '''
(curl -4 -fsS --max-time 5 https://ifconfig.me ||
curl -4 -fsS --max-time 5 https://api.ipify.org ||
curl -4 -fsS --max-time 5 https://ipinfo.io/ip) | tr -d '[:space:]'
''',
returnStdout: true
).trim()

def octets = publicIp.tokenize('.')
if (octets.size() != 4 || !octets.every { it ==~ /\d{1,3}/ && it.toInteger() >= 0 && it.toInteger() <= 255 }) {
error "Failed to auto-detect a valid public IPv4 address (got: '${publicIp}')"
}

env.RUNNER_PUBLIC_IP = publicIp
echo "Detected runner public IP: ${env.RUNNER_PUBLIC_IP}"
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this will be used in multiple pipelines, it would be a good idea to move it to qa-jenkins-library.

error "Failed to auto-detect a valid public IPv4 address (got: '${publicIp}')"
}

echo "Detected runner public IP: ${env.RUNNER_PUBLIC_IP}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think env.RUNNER_PUBLIC_IP is ever assigned a value, so it's going to print null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team/pit-crew slack notifier for pit crew

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants