feat: add proxy env variables
This commit is contained in:
parent
a505958ba8
commit
ca71040514
6 changed files with 40 additions and 0 deletions
|
@ -61,6 +61,14 @@ gitlab:
|
||||||
user: www-data
|
user: www-data
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* `swarm_proxy_url` - set a proxy url for http and https requests
|
||||||
|
* `swarm_proxy_ignore` - array with ignore host or subnet
|
||||||
|
|
||||||
|
```
|
||||||
|
- localhost
|
||||||
|
- 10.0.0.0/8
|
||||||
|
```
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
* Install:
|
* Install:
|
||||||
|
|
5
handlers/main.yml
Normal file
5
handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: restart docker
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: docker
|
||||||
|
state: restarted
|
|
@ -4,6 +4,7 @@
|
||||||
roles:
|
roles:
|
||||||
- swarm
|
- swarm
|
||||||
vars:
|
vars:
|
||||||
|
swarm_proxy_url: http://127.0.0.1:3128
|
||||||
swarm_manager: true
|
swarm_manager: true
|
||||||
swarm_init: true
|
swarm_init: true
|
||||||
swarm_networks:
|
swarm_networks:
|
||||||
|
|
|
@ -7,6 +7,15 @@ def test_packages(host):
|
||||||
package = host.package('docker.io')
|
package = host.package('docker.io')
|
||||||
assert package.is_installed
|
assert package.is_installed
|
||||||
|
|
||||||
|
def test_default_config_file(host):
|
||||||
|
path = host.file('/etc/default/docker')
|
||||||
|
assert path.exists
|
||||||
|
assert path.is_file
|
||||||
|
assert path.user == 'root'
|
||||||
|
assert path.group == 'root'
|
||||||
|
assert path.mode == 0o644
|
||||||
|
assert path.contains('https_proxy=http://127.0.0.1:3128')
|
||||||
|
|
||||||
def test_service(host):
|
def test_service(host):
|
||||||
service = host.service('docker')
|
service = host.service('docker')
|
||||||
assert service.is_running
|
assert service.is_running
|
||||||
|
|
|
@ -6,6 +6,16 @@
|
||||||
- python3-docker
|
- python3-docker
|
||||||
tags: swarm
|
tags: swarm
|
||||||
|
|
||||||
|
- name: copy default variables file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: default.j2
|
||||||
|
dest: /etc/default/docker
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart docker
|
||||||
|
tags: swarm
|
||||||
|
|
||||||
- name: enable and start service
|
- name: enable and start service
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: docker
|
name: docker
|
||||||
|
|
7
templates/default.j2
Normal file
7
templates/default.j2
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
{% if telegraf_proxy_url is defined %}
|
||||||
|
https_proxy={{ telegraf_proxy_url }}
|
||||||
|
http_proxy={{ telegraf_proxy_url }}
|
||||||
|
no_proxy={{ telegraf_proxy_ignore|join(',') }}
|
||||||
|
{% endif %}
|
Loading…
Reference in a new issue