diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 836e4010789a2d851d4947770376a6bcb9c53502..aa6ac54261c3d32a0eef9bb6629e357732071bf9 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -123,3 +123,8 @@ dns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(2)|ipaddr('address') # server master2 10.99.0.27:443 # balance roundrobin # apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local" + +##Set these proxy values in order to update docker daemon to use proxies +#http_proxy: "" +#https_proxy: "" +#no_proxy: "" diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 47e5d24a1ed151e91ba0b2396da988f8a3b42ce6..116f2f9f620462b79dae21a2d26928690694118c 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -53,6 +53,11 @@ with_items: "{{ docker_package_info.pkgs }}" when: docker_package_info.pkgs|length > 0 +- name: allow for proxies on RHEL systems + include: rhel-proxies.yml + when: ansible_distribution in ["CentOS","RedHat"] and + ansible_distribution_major_version >= 7 + - meta: flush_handlers - name: ensure docker service is started and enabled diff --git a/roles/docker/tasks/rhel-proxies.yml b/roles/docker/tasks/rhel-proxies.yml new file mode 100644 index 0000000000000000000000000000000000000000..10fafb618ed6a7c5bf1f9b5906703bacbd0f9a5f --- /dev/null +++ b/roles/docker/tasks/rhel-proxies.yml @@ -0,0 +1,21 @@ +--- +- name: create docker service directory for RHEL family + file: path=/etc/systemd/system/docker.service.d state=directory + when: ansible_distribution in ["CentOS","RedHat"] and + ansible_distribution_major_version >= 7 + +- name: drop docker environment for RHEL family + template: + src: http-proxy.conf.j2 + dest: /etc/systemd/system/docker.service.d/http-proxy.conf + when: ansible_distribution in ["CentOS","RedHat"] and + ansible_distribution_major_version >= 7 + register: rheldockerproxy + +- name: reload systemctl daemons for RHEL family + shell: systemctl daemon-reload + when: rheldockerproxy.changed + +- name: restart docker for RHEL family + service: name=docker state=restarted + when: rheldockerproxy.changed diff --git a/roles/docker/templates/http-proxy.conf.j2 b/roles/docker/templates/http-proxy.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..7e558837c14cb51f5a9f462affbe9b91e8c953e9 --- /dev/null +++ b/roles/docker/templates/http-proxy.conf.j2 @@ -0,0 +1,3 @@ +[Service] + +Environment={% if http_proxy %}"HTTP_PROXY={{ http_proxy }}"{% endif %} {% if https_proxy %}"HTTPS_PROXY={{ https_proxy }}"{% endif %} {% if no_proxy %}"NO_PROXY={{ no_proxy }}"{% endif %}