kayobe/ansible/proxy.yml
Pierre Riteau e48960ecf2 Add support for configuring proxy settings
Change-Id: Ic5130a7512d4a26354bd292b0ab51ab4a9279f0a
2021-10-19 10:58:19 +02:00

42 lines
1.3 KiB
YAML

- name: Configure HTTP(S) proxy settings
hosts: seed-hypervisor:seed:overcloud
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 is defined and 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 is defined and 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 is defined and http_proxy | length > 0 or https_proxy is defined and https_proxy | length > 0