Update to 2022-02-10 13:00

This commit is contained in:
Daniel Berteaud 2022-02-10 13:00:05 +01:00
parent 6f6d3b7382
commit 0c2892d14a
3 changed files with 12 additions and 6 deletions

View File

@ -4,16 +4,22 @@
template: src=proxy.sh.j2 dest=/etc/profile.d/proxy.sh mode=755
tags: proxy
- name: Add lines in environment file
- name: Handle variables in environment file
lineinfile:
dest: /etc/environment
regexp: "^{{ item }}=.*"
line: "{{ item }}={{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
with_items: "{{ system_proxy_proto | map('regex_replace', '^(.*)$', '\\1_proxy') | list }} + {{ system_proxy_proto | map('regex_replace', '^(.*)$', '\\1_proxy') | map('upper') | list }}"
state: "{{ (system_proxy is defined and system_proxy != '' and item | lower | regex_replace('(?i)_proxy$', '') in system_proxy_proto | map('lower') ) | ternary('present','absent') }}"
loop:
- http_proxy
- HTTP_PROXY
- https_proxy
- HTTPS_PROXY
- ftp_proxy
- FTP_PROXY
tags: proxy
- name: Set proxy exceptions
- name: Handle proxy exceptions in environment file
lineinfile:
dest: /etc/environment
regexp: "^{{ item }}=.*"

View File

@ -2,7 +2,7 @@
{% if system_proxy is defined and system_proxy != '' %}
{% for proto in system_proxy_proto %}
export {{ proto }}_proxy={{ system_proxy }}
export {{ proto | lower }}_proxy={{ system_proxy }}
export {{ proto | upper }}_PROXY={{ system_proxy }}
{% endfor %}
export no_proxy='{{ system_proxy_no_proxy | join(',') }}'

View File

@ -1,6 +1,6 @@
[Manager]
{% if system_proxy is defined and system_proxy != '' %}
DefaultEnvironment={% for proto in system_proxy_proto %}{{ proto }}_proxy={{ system_proxy }} {{ proto | upper }}_PROXY={{ system_proxy }} {% endfor %}no_proxy={{ system_proxy_no_proxy | join(',') }} NO_PROXY={{ system_proxy_no_proxy | join(',') }}
DefaultEnvironment={% for proto in system_proxy_proto %}{{ proto | lower }}_proxy={{ system_proxy }} {{ proto | upper }}_PROXY={{ system_proxy }} {% endfor %}no_proxy={{ system_proxy_no_proxy | join(',') }} NO_PROXY={{ system_proxy_no_proxy | join(',') }}
{% else %}
# No proxy configured
{% endif %}