ansible-roles/roles/system_proxy/tasks/main.yml

46 lines
1.6 KiB
YAML
Raw Normal View History

2021-12-01 19:13:34 +01:00
---
- name: Add a profile script
template: src=proxy.sh.j2 dest=/etc/profile.d/proxy.sh mode=755
tags: proxy
2022-02-10 13:00:05 +01:00
- name: Handle variables in environment file
2021-12-01 19:13:34 +01:00
lineinfile:
dest: /etc/environment
regexp: "^{{ item }}=.*"
line: "{{ item }}={{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
2022-02-10 13:00:05 +01:00
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
2021-12-01 19:13:34 +01:00
tags: proxy
2022-02-10 13:00:05 +01:00
- name: Handle proxy exceptions in environment file
2021-12-01 19:13:34 +01:00
lineinfile:
dest: /etc/environment
regexp: "^{{ item }}=.*"
line: "{{ item }}={{ (system_proxy is defined and system_proxy != '' and system_proxy_no_proxy is defined and system_proxy_no_proxy | length > 0) | ternary(system_proxy_no_proxy | join(','),'') }}"
state: "{{ (system_proxy is defined and system_proxy != '' and system_proxy_no_proxy is defined and system_proxy_no_proxy | length > 0) | ternary('present','absent') }}"
with_items:
- no_proxy
- NO_PROXY
tags: proxy
2022-02-09 17:00:06 +01:00
- when: ansible_service_mgr == 'systemd'
block:
- name: Creates systemd.conf.d dir
file: path=/etc/systemd/system.conf.d state=directory
2021-12-01 19:13:34 +01:00
2022-02-09 17:00:06 +01:00
- name: Deploy a systemd snippet for default proxy
template: src=systemd.conf.j2 dest=/etc/systemd/system.conf.d/proxy.conf
notify: reload systemd
2021-12-01 19:13:34 +01:00
tags: proxy
2022-03-07 14:00:06 +01:00
- include_tasks: "{{ ansible_os_family }}.yml"
tags: always
2021-12-01 19:13:34 +01:00