Add proxy support 83/45383/20
authorVictor Morales <victor.morales@intel.com>
Mon, 5 Feb 2018 18:45:46 +0000 (10:45 -0800)
committerVictor Morales <victor.morales@intel.com>
Tue, 20 Mar 2018 11:53:03 +0000 (04:53 -0700)
In some cases the XCI development environment can be located behind a
corporate proxy resulting in a additional layer to consider to
configure. These changes pretend to include proxy support for all
linux distros in all the posible flavors.

Change-Id: Iab469268809ac471d09e244bb3ccd83de1a41b88
Signed-off-by: Victor Morales <victor.morales@intel.com>
xci/files/requirements.yml [new file with mode: 0644]
xci/infra/bifrost/playbooks/opnfv-virtual.yaml
xci/installer/osa/deploy.sh
xci/installer/osa/files/user_variables_proxy.yml [new file with mode: 0644]
xci/installer/osa/playbooks/configure-opnfvhost.yml
xci/installer/osa/playbooks/configure-targethosts.yml
xci/playbooks/roles/bootstrap-host/tasks/time.yml
xci/playbooks/roles/clone-repository/tasks/main.yml

diff --git a/xci/files/requirements.yml b/xci/files/requirements.yml
new file mode 100644 (file)
index 0000000..a1b7feb
--- /dev/null
@@ -0,0 +1,10 @@
+---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018 Intel Corporation.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- src: peru.proxy_settings
index f44adb4..3429f2e 100644 (file)
   environment:
     http_proxy: "{{ lookup('env','http_proxy') }}"
     https_proxy: "{{ lookup('env','https_proxy') }}"
+    no_proxy: "{{ lookup('env','no_proxy') }}"
 
 - hosts: baremetal
   name: "Enrollment and Deployment"
     - role: ironic-enroll-dynamic
     - { role: ironic-inspect-node, when: inspect_nodes | default('false') | bool == true }
     - role: bifrost-configdrives-dynamic
+      ipv4_nameserver: 192.168.122.1
     - role: bifrost-deploy-nodes-dynamic
+  environment:
+    http_proxy: "{{ lookup('env','http_proxy') }}"
+    https_proxy: "{{ lookup('env','https_proxy') }}"
+    no_proxy: "{{ lookup('env','no_proxy') }}"
 
 - hosts: baremetal
   name: "Deploy machines."
index ce44626..6dada3f 100755 (executable)
@@ -57,6 +57,7 @@ echo "Info: Configured localhost host for openstack-ansible"
 echo "Info: Configuring opnfv deployment host for openstack-ansible"
 echo "-----------------------------------------------------------------------"
 cd $OSA_XCI_PLAYBOOKS
+ansible-galaxy install -r ${XCI_PATH}/xci/files/requirements.yml -p $HOME/.ansible/roles
 ansible-playbook ${XCI_ANSIBLE_PARAMS} -i ${XCI_FLAVOR_ANSIBLE_FILE_PATH}/inventory \
     configure-opnfvhost.yml
 echo "-----------------------------------------------------------------------"
diff --git a/xci/installer/osa/files/user_variables_proxy.yml b/xci/installer/osa/files/user_variables_proxy.yml
new file mode 100644 (file)
index 0000000..d25c318
--- /dev/null
@@ -0,0 +1,22 @@
+---
+# Copyright 2018, Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+http_proxy_env_url: ""
+no_proxy_env: "localhost,127.0.0.1,{{ internal_lb_vip_address }},{{ external_lb_vip_address }},{% for host in groups['all_containers'] %}{{ hostvars[host]['container_address'] }}{% if not loop.last %},{% endif %}{% endfor %}"
+global_environment_variables:
+  HTTP_PROXY: "{{ http_proxy_env_url }}"
+  NO_PROXY: "{{ no_proxy_env }}"
+  http_proxy: "{{ http_proxy_env_url }}"
+  no_proxy: "{{ no_proxy_env }}"
index 4c30f4d..647f175 100644 (file)
     - "{{ XCI_PATH }}/xci/var/opnfv.yml"
     - "{{ XCI_PATH }}/xci/installer/osa/files/openstack_services.yml"
 
+  environment:
+    http_proxy: "{{ lookup('env','http_proxy') }}"
+    https_proxy: "{{ lookup('env','https_proxy') }}"
+    no_proxy: "{{ lookup('env','no_proxy') }}"
+    HTTP_PROXY: "{{ lookup('env','http_proxy') }}"
+    HTTPS_PROXY: "{{ lookup('env','https_proxy') }}"
+    NO_PROXY: "{{ lookup('env','no_proxy') }}"
   pre_tasks:
     - name: Load distribution variables
       include_vars:
   roles:
     - role: bootstrap-host
       configure_network: XCI_FLAVOR != 'aio'
+    - role: peru.proxy_settings
+      proxy_settings_http_proxy: "{{ lookup('env','http_proxy') }}"
+      proxy_settings_https_proxy: "{{ lookup('env','https_proxy') }}"
+      proxy_settings_ftp_proxy: "{{ lookup('env','ftp_proxy') }}"
+      proxy_settings_no_proxy: "{{ lookup('env','no_proxy') }}"
 
   tasks:
     - name: generate SSH keys
         - name: copy user_variables_ceph.yml
           shell: "/bin/cp -rf {{ remote_xci_flavor_files }}/user_variables_ceph.yml {{OPENSTACK_OSA_ETC_PATH}}/user_variables_ceph.yml"
       when: XCI_CEPH_ENABLED == "true"
+    - block:
+        - name: copy user_variables_proxy.yml
+          shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/user_variables_proxy.yml {{OPENSTACK_OSA_ETC_PATH}}/user_variables_proxy.yml"
+        - name: "Configure http_proxy_env_url"
+          lineinfile:
+            path: "{{OPENSTACK_OSA_ETC_PATH}}/user_variables_proxy.yml"
+            regexp: "^http_proxy_env_url:.*"
+            line: "{{ 'http_proxy_env_url: ' + lookup('env','http_proxy') }}"
+      when:
+        - lookup('env','http_proxy') != "randomfoobarstring"
     - name: copy OPNFV OpenStack playbook
       shell: "/bin/cp -rf {{ remote_xci_path }}/xci/installer/osa/files/setup-openstack.yml {{OPENSTACK_OSA_PATH}}/playbooks"
     - name: copy pinned versions of OSA Roles and global requirements
index 31c3e02..42822c9 100644 (file)
@@ -1,5 +1,12 @@
 ---
 - hosts: openstack
+  environment:
+    http_proxy: "{{ lookup('env','http_proxy') }}"
+    https_proxy: "{{ lookup('env','https_proxy') }}"
+    no_proxy: "{{ lookup('env','no_proxy') }}"
+    HTTP_PROXY: "{{ lookup('env','http_proxy') }}"
+    HTTPS_PROXY: "{{ lookup('env','https_proxy') }}"
+    NO_PROXY: "{{ lookup('env','no_proxy') }}"
   remote_user: root
   vars_files:
     - "{{ XCI_PATH }}/xci/var/opnfv.yml"
         - "{{ XCI_PATH }}/xci/var/{{ ansible_os_family }}.yml"
         - "{{ XCI_FLAVOR_ANSIBLE_FILE_PATH }}/flavor-vars.yml"
   roles:
+    - role: peru.proxy_settings
+      proxy_settings_http_proxy: "{{ lookup('env','http_proxy') }}"
+      proxy_settings_https_proxy: "{{ lookup('env','https_proxy') }}"
+      proxy_settings_ftp_proxy: "{{ lookup('env','ftp_proxy') }}"
+      proxy_settings_no_proxy: "{{ lookup('env','no_proxy') }}"
     - role: bootstrap-host
     - role: configure-nfs
       when:
index 8f94d33..4b3bf95 100644 (file)
@@ -21,3 +21,7 @@
   until: chrony_got_time.rc == 0
   retries: 5
   delay: 5
+  environment:
+    http_proxy: "{{ lookup('env','http_proxy') }}"
+    https_proxy: "{{ lookup('env','https_proxy') }}"
+    no_proxy: "{{ lookup('env','no_proxy') }}"
index a124003..0ba80c0 100644 (file)
@@ -13,3 +13,7 @@
     dest: "{{ dest }}"
     version: "{{ version }}"
     force: yes
+  environment:
+    http_proxy: "{{ lookup('env','http_proxy') }}"
+    https_proxy: "{{ lookup('env','https_proxy') }}"
+    no_proxy: "{{ lookup('env','no_proxy') }}"