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

46 lines
1.6 KiB
YAML

---
- name: Add a profile script
template: src=proxy.sh.j2 dest=/etc/profile.d/proxy.sh mode=755
tags: proxy
- 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 != '' 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: Handle proxy exceptions in environment file
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
- when: ansible_service_mgr == 'systemd'
block:
- name: Creates systemd.conf.d dir
file: path=/etc/systemd/system.conf.d state=directory
- name: Deploy a systemd snippet for default proxy
template: src=systemd.conf.j2 dest=/etc/systemd/system.conf.d/proxy.conf
notify: reload systemd
tags: proxy
- include_tasks: "{{ ansible_os_family }}.yml"
tags: always