Enable http proxy and no proxy configuration in engine
The proxy information will be achieved from idf with the following
format:
proxy_settings:
http_proxy: <http_proxy>
https_proxy: <https_proxy>
no_proxy: <localhost and all the ports in k8s inventory file>
This change supposes that jumphost(localhost) and target hosts have
same proxy configuration. After post-deployment, re-login to the
jumphost is needed to let 'no_proxy' configuration on jumphost take effect
Otherwise, kubectl will get 'Unable to connect to the server: EOF' error.
Change-Id: I50f74d630dfd5d3bdf14f1e22824961cf99427ba
diff --git a/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml b/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml
index 729fed8..600d5d6 100644
--- a/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml
+++ b/playbooks/roles/configure-targethosts/tasks/configure-network-RedHat.yml
@@ -48,6 +48,30 @@
with_items:
- "{{ if_mac_dict | dict2items }}"
+- name: Proxy configuration for yum
+ block:
+ - name: Check that the /etc/yum.conf exists
+ stat:
+ path: /etc/yum.conf
+ register: stat_result
+
+ - name: Create /etc/yum.conf, if it doesn't exist
+ file:
+ path: /etc/yum.conf
+ state: touch
+ when: stat_result.stat.exists == False
+
+ - name: Add proxy setting to /etc/yum.conf
+ lineinfile:
+ dest: /etc/yum.conf
+ state: present
+ regexp: "^{{ item.name }}"
+ line: "{{ item.name }}={{ item.value }} "
+ with_items:
+ - {name: 'proxy', value: '"{{ idf.proxy_settings.http_proxy }}"' }
+ when:
+ idf.proxy_settings is defined
+
- name: Restart network
service:
name: network