Skip to content

Commit f17e331

Browse files
committed
add proxy_remove
1 parent cebc719 commit f17e331

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

ansible/final.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@
1717
- include_role:
1818
name: compute_init
1919
tasks_from: export.yml
20+
21+
- hosts: proxy
22+
gather_facts: false
23+
tags: proxy
24+
become: yes
25+
tasks:
26+
- include_role:
27+
name: proxy
28+
vars:
29+
proxy_state: absent
30+
when: proxy_remove | bool == true

ansible/roles/proxy/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ Define http/s proxy configuration.
1717
- `proxy_systemd`: Optional bool. Whether to give processes started by systemd
1818
the above http, https and no_proxy configuration. **NB** Running services will
1919
need restarting if this is changed. Default `true`.
20+
- `proxy_remove`: Optional bool. Whether to remove the proxy configuration at
21+
the end of the `site.yml` playbook (this is actually a variable on the play,
22+
not a role variable).

ansible/roles/proxy/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ proxy_no_proxy_extras: []
55
proxy_no_proxy: "{{ (proxy_no_proxy_defaults + proxy_no_proxy_extras) | unique | sort | join(',') }}"
66
proxy_dnf: true
77
proxy_systemd: true
8+
proxy_state: present
9+
# proxy_remove: false

ansible/roles/proxy/tasks/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
- name: Validate http_proxy definition
2+
ansible.builtin.assert:
3+
that: proxy_http_proxy != '' # this is default if squid not active
4+
fail_msg: >-
5+
Variable proxy_http_proxy cannot be the empty string for hosts in the
6+
proxy group. See environment/common/inventory/group_vars/all/proxy.yml.
17
- name: Define configuration in /etc/environment
28
tags: proxy
39
lineinfile:
@@ -6,7 +12,7 @@
612
owner: root
713
group: root
814
mode: o=rw,go=r
9-
state: present
15+
state: "{{ proxy_state }}"
1016
regexp: "{{ item.key }}=.*"
1117
line: "{{ item.key }}={{ item.value }}"
1218
loop:
@@ -24,6 +30,7 @@
2430
option: "proxy"
2531
value: "{{ proxy_http_proxy }}"
2632
no_extra_spaces: true
33+
state: "{{ proxy_state }}"
2734
owner: root
2835
group: root
2936
mode: o=rw,go=r
@@ -48,6 +55,7 @@
4855
"https_proxy={{ proxy_http_proxy }}"
4956
"no_proxy={{ proxy_no_proxy }}"
5057
no_extra_spaces: true
58+
state: "{{ proxy_state }}"
5159
owner: root
5260
group: root
5361
mode: ug=rw,o=r

0 commit comments

Comments
 (0)