Skip to content

Guard against REQUESTS_CA_BUNDLE pointing to a non-existent path - #186

Open
rohitthakur2590 wants to merge 4 commits into
ansible:stable-2.7from
rohitthakur2590:pr-185
Open

rohitthakur2590 wants to merge 4 commits into
ansible:stable-2.7from
rohitthakur2590:pr-185

Conversation

@rohitthakur2590

Copy link
Copy Markdown
Collaborator

Description

  • What is being changed?
  • Why is this change needed?
  • How does this change address the issue?

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test update
  • Refactoring (no functional changes)
  • Development environment change
  • Configuration change

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

Steps to Test

Expected Results

Additional Context

Required Actions

  • Requires documentation updates
  • Requires downstream repository changes
  • Requires infrastructure/deployment changes
  • Requires coordination with other teams
  • Blocked by PR/MR: #XXX

Screenshots/Logs

The SSL_CERT_FILE -> REQUESTS_CA_BUNDLE shim now checks os.path.isfile()
before applying the mapping. If the path does not exist on the controller
(e.g. the installer sets SSL_CERT_FILE to a path on the remote host that
has not been created yet, or only exists on the managed node), the mapping
is skipped and a debug message is logged instead of letting requests raise
"Could not find a suitable TLS CA certificate bundle, invalid path: ...".

Previously the mapping was unconditional, which broke the containerized
installer postinstall tasks that set SSL_CERT_FILE to a path that does not
exist on the Ansible controller (AAP-75386).

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
The controller shell environment (set by a prior installer step) may
already contain REQUESTS_CA_BUNDLE pointing to a path that does not yet
exist on the controller when the ansible.platform action plugin runs.
os.environ.copy() inherits it and passes it to the manager subprocess,
causing requests to raise "Could not find a suitable TLS CA certificate
bundle, invalid path: ...".

Guard REQUESTS_CA_BUNDLE itself — regardless of whether it came from the
shell env or task env — by removing it when os.path.isfile() returns False,
so requests falls back to the system CA store instead of crashing.

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
@github-actions

Copy link
Copy Markdown

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

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

Labels

safe to test PR is safe to run integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants