--- - name: Clear proxy settings on hcp1 and hcp2 hosts: hcp1,hcp2 become: yes tasks: - name: Check current proxy environment variables shell: env | grep -i proxy || echo "No proxy vars found" register: proxy_env_before - name: Display current proxy settings debug: msg: "Current proxy env: {{ proxy_env_before.stdout_lines }}" - name: Clear proxy from /etc/environment lineinfile: path: /etc/environment regexp: "{{ item }}" state: absent loop: - "^http_proxy=" - "^https_proxy=" - "^HTTP_PROXY=" - "^HTTPS_PROXY=" - "^ftp_proxy=" - "^FTP_PROXY=" - "^no_proxy=" - "^NO_PROXY=" - name: Clear proxy from /etc/apt/apt.conf.d/ file: path: "{{ item }}" state: absent loop: - /etc/apt/apt.conf.d/95proxies - /etc/apt/apt.conf.d/proxy.conf - /etc/apt/apt.conf.d/00proxy - name: Clear proxy from user profiles lineinfile: path: "{{ item }}" regexp: ".*proxy.*" state: absent loop: - /root/.bashrc - /root/.profile - /home/root/.bashrc - /home/root/.profile ignore_errors: yes - name: Unset proxy variables in current session shell: | unset http_proxy unset https_proxy unset HTTP_PROXY unset HTTPS_PROXY unset ftp_proxy unset FTP_PROXY unset no_proxy unset NO_PROXY - name: Check APT proxy configuration shell: apt-config dump | grep -i proxy || echo "No APT proxy found" register: apt_proxy_check - name: Display APT proxy status debug: msg: "APT proxy config: {{ apt_proxy_check.stdout_lines }}" - name: Test direct connection to HashiCorp shell: curl -I --connect-timeout 10 https://releases.hashicorp.com/ || echo "Connection failed" register: connection_test - name: Display connection test result debug: msg: "Connection test: {{ connection_test.stdout_lines }}"