Skip to content

Unset proxy environment variables before running Ansible#654

Merged
evgeni merged 1 commit into
theforeman:masterfrom
Gauravtalreja1:unset-proxy-env-for-deploy
Jul 15, 2026
Merged

Unset proxy environment variables before running Ansible#654
evgeni merged 1 commit into
theforeman:masterfrom
Gauravtalreja1:unset-proxy-env-for-deploy

Conversation

@Gauravtalreja1

Copy link
Copy Markdown
Contributor

Why are you introducing these changes? (Problem description, related links)

When proxy environment variables (http_proxy/HTTPS_PROXY) are set on the host, Ansible tasks that make HTTP calls (ansible.builtin.uri,theforeman.foreman modules) route through the proxy and fail with Tunnel connection failed: 503 Service Unavailable. This affects health checks, smart proxy registration, and service readiness checks.
This is the same approach used by foreman-installer, which unsets proxy variables in hooks/boot/05-environment.rb before running Puppet.

Image pulls are unaffected, they go through Podman/systemd, which reads proxy settings from /etc/containers/containers.conf, not from the shell environment.

What are the changes introduced in this pull request?

  • Unset http_proxy, HTTP_PROXY, https_proxy, and HTTPS_PROXY in theforemanctl wrapper script before invoking Ansible, so no playbook inherits proxy settings from the host environment.

How to test this pull request

  • Deploy on a host with https_proxy set in the environment
  • Verify foremanctl deploy completes without proxy-related errors
  • Verify container image pulls still work (they use containers.conf)
  • Verify health checks pass: foremanctl health

Steps to reproduce:

  • Set proxy on the host: export https_proxy=http://proxy.example.com:3128
  • Run foremanctl deploy --foreman-initial-admin-password=changeme
  • Observe failures at "Wait for Foreman service to be accessible" or "Configure Foreman Proxy" with Tunnel connection failed: 503

Checklist

  • Tests added/updated (if applicable)
  • Documentation updated (if applicable)

Comment thread src/playbooks/backup/backup.yaml Outdated
Proxy env vars on the host cause Ansible HTTP tasks to route through the proxy and fail.
Unsetting them in the wrapper script covers all playbooks,
matching foreman-installer's approach, as similar to hooks/boot/05-environment.rb

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
@Gauravtalreja1
Gauravtalreja1 force-pushed the unset-proxy-env-for-deploy branch from 97b56a6 to 30b8b51 Compare July 15, 2026 10:03
@Gauravtalreja1

Copy link
Copy Markdown
Contributor Author

PRT passed on SatelliteQE/robottelo#22125 (remaining failures are unrelated to this changes)
And, migration failure is probably due to #661

@evgeni
evgeni merged commit 3e0b3a7 into theforeman:master Jul 15, 2026
14 of 16 checks passed
@Gauravtalreja1
Gauravtalreja1 deleted the unset-proxy-env-for-deploy branch July 15, 2026 14:06
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.

3 participants