kayobe/ansible/proxy.yml
Pierre Riteau 71eb21a3dd Fix no_proxy configuration
The no_proxy list should only contain domains, hostnames, IP addresses
and networks, but docker_registry is often in the form ip_address:port.

Use urlsplit to extract the hostname from the docker_registry variable
after prepending http:// to turn it into a valid URL.

Also add missing infra-vms to hosts in proxy.yml.

Change-Id: I6424fc405894514a63fb2b641637bbb9d5c070c0
2022-04-19 08:58:22 +02:00

42 lines
1.2 KiB
YAML

- name: Configure HTTP(S) proxy settings
hosts: seed-hypervisor:seed:overcloud:infra-vms
vars:
ansible_python_interpreter: /usr/bin/python3
tags:
- proxy
tasks:
- name: Add HTTP proxy configuration to /etc/environment
lineinfile:
path: "/etc/environment"
create: yes
mode: 0644
state: present
regexp: "^http_proxy=.*"
line: "http_proxy={{ http_proxy }}"
become: True
when: http_proxy | length > 0
- name: Add HTTPS proxy configuration to /etc/environment
lineinfile:
path: "/etc/environment"
create: yes
mode: 0644
state: present
regexp: "^https_proxy=.*"
line: "https_proxy={{ https_proxy }}"
become: True
when: https_proxy | length > 0
- name: Add no_proxy configuration to /etc/environment
lineinfile:
path: "/etc/environment"
create: yes
mode: 0644
state: present
regexp: "^no_proxy=.*"
line: "no_proxy={{ no_proxy | select | join(',') }}"
become: True
when:
- no_proxy | length > 0
- http_proxy | length > 0 or https_proxy | length > 0