baremetal: Add support for Docker http/https proxy setup

Change-Id: I947c2940518c0f4872acaa977edeaca370dc9a96
This commit is contained in:
Michal Nasiadka 2020-10-21 09:13:53 +02:00
parent d1e7964a8d
commit 7fa419cfc3
5 changed files with 37 additions and 3 deletions

View File

@ -34,6 +34,10 @@ docker_storage_driver: ""
docker_custom_option: "" docker_custom_option: ""
docker_custom_config: {} docker_custom_config: {}
docker_http_proxy: ""
docker_https_proxy: ""
docker_no_proxy: ""
# Version of python used to execute Ansible modules. # Version of python used to execute Ansible modules.
host_python_version: "{{ ansible_python.version.major }}.{{ ansible_python.version.minor }}" host_python_version: "{{ ansible_python.version.major }}.{{ ansible_python.version.minor }}"

View File

@ -137,6 +137,9 @@
when: when:
- not docker_custom_option - not docker_custom_option
- not docker_configure_for_zun | bool - not docker_configure_for_zun | bool
- not docker_http_proxy
- not docker_https_proxy
- not docker_no_proxy
- name: Ensure docker service directory exists - name: Ensure docker service directory exists
become: True become: True
@ -144,14 +147,24 @@
path: /etc/systemd/system/docker.service.d path: /etc/systemd/system/docker.service.d
state: directory state: directory
recurse: yes recurse: yes
when: docker_custom_option | length > 0 or docker_configure_for_zun|bool when: >
docker_custom_option | length > 0 or
docker_configure_for_zun | bool or
docker_http_proxy | length > 0 or
docker_https_proxy | length > 0 or
docker_no_proxy | length > 0
- name: Configure docker service - name: Configure docker service
become: True become: True
template: template:
src: docker_systemd_service.j2 src: docker_systemd_service.j2
dest: /etc/systemd/system/docker.service.d/kolla.conf dest: /etc/systemd/system/docker.service.d/kolla.conf
when: docker_custom_option | length > 0 or docker_configure_for_zun|bool when: >
docker_custom_option | length > 0 or
docker_configure_for_zun | bool or
docker_http_proxy | length > 0 or
docker_https_proxy | length > 0 or
docker_no_proxy | length > 0
- name: Reload docker service file - name: Reload docker service file
become: True become: True

View File

@ -1,4 +1,13 @@
[Service] [Service]
{% if docker_http_proxy | length > 0 %}
Environment="HTTP_PROXY={{ docker_http_proxy }}"
{% endif %}
{% if docker_https_proxy | length > 0 %}
Environment="HTTPS_PROXY={{ docker_https_proxy }}"
{% endif %}
{% if docker_no_proxy | length > 0 %}
Environment="NO_PROXY={{ docker_no_proxy }}"
{% endif %}
ExecStart= ExecStart=
# ExecStart commandline copied from 'docker-ce' package. Same on CentOS/Debian/Ubuntu systems. # ExecStart commandline copied from 'docker-ce' package. Same on CentOS/Debian/Ubuntu systems.
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock{% if docker_custom_option %} {{ docker_custom_option }}{% endif %}{% if docker_configure_for_zun|bool %} {{ docker_zun_options }}{% endif %} ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock{% if docker_custom_option %} {{ docker_custom_option }}{% endif %}{% if docker_configure_for_zun|bool %} {{ docker_zun_options }}{% endif %}

View File

@ -178,6 +178,10 @@ maximum number of log files to retain per container. The
``docker_log_max_size`` variable, which defaults to ``50m``, defines the ``docker_log_max_size`` variable, which defaults to ``50m``, defines the
maximum size of each rotated log file per container. maximum size of each rotated log file per container.
The ``docker_http_proxy``, ``docker_https_proxy`` and ``docker_no_proxy``
variables can be used to configure Docker Engine to connect to the internet
using http/https proxies.
Additional options for the Docker engine can be passed in Additional options for the Docker engine can be passed in
``docker_custom_config`` variable. It will be stored in ``daemon.json`` config ``docker_custom_config`` variable. It will be stored in ``daemon.json`` config
file. Example: file. Example:

View File

@ -0,0 +1,4 @@
---
features:
- |
Add support for configuring Docker Engine http/https proxy.