From 44a4682da288508db3c995e98bf32fc658d109e0 Mon Sep 17 00:00:00 2001
From: SamYaple <sam@yaple.net>
Date: Fri, 12 Feb 2016 02:16:12 +0000
Subject: [PATCH] Fix detect_distro

It was run before ansible was installed and did not properly fail.
This prevented the mirrors for apt from being properly used.

TrivialFix

Change-Id: I5331020993b62c8635a4a97dc3a3d2e01e3d4360
---
 tools/setup_gate.sh | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh
index 882f0e00ff..c701e10edd 100755
--- a/tools/setup_gate.sh
+++ b/tools/setup_gate.sh
@@ -14,7 +14,14 @@ function setup_config {
     # Copy configs
     sudo cp -a etc/kolla /etc/
 
+    # Use Infra provided pypi
+    echo "RUN echo $(base64 -w0 /etc/pip.conf) | base64 -d > /etc/pip.conf" | sudo tee /etc/kolla/header
+    sed -i 's|^#include_header.*|include_header = /etc/kolla/header|' /etc/kolla/kolla-build.conf
+
     if [[ "${DISTRO}" == "Debian" ]]; then
+        # Infra does not sign thier mirrors so we ignore gpg signing in the gate
+        echo "RUN echo 'APT::Get::AllowUnauthenticated \"true\";' > /etc/apt/apt.conf" | sudo tee -a /etc/kolla/header
+
         # Optimize the repos to take advantage of the Infra provided mirrors for Ubuntu
         sed -i 's|^#apt_sources_list.*|apt_sources_list = /etc/kolla/sources.list|' /etc/kolla/kolla-build.conf
         sudo cp /etc/apt/sources.list /etc/kolla/sources.list
@@ -26,10 +33,6 @@ deb http://repo.percona.com/apt trusty main
 deb http://download.ceph.com/debian-hammer/ trusty main
 EOF
     fi
-
-    # Use Infra provided pypi
-    echo "RUN echo $(base64 -w0 /etc/pip.conf) | base64 -d > /etc/pip.conf" | sudo tee /etc/kolla/header
-    sed -i 's|^#include_header.*|include_header = /etc/kolla/header|' /etc/kolla/kolla-build.conf
 }
 
 function detect_distro {
@@ -79,6 +82,7 @@ function setup_ansible {
     mkdir /tmp/kolla
 
     sudo -H pip install "ansible<2" "docker-py>=1.6.0"
+    detect_distro
 
     setup_inventory
 
@@ -100,7 +104,6 @@ function setup_logging {
     mkdir -p /tmp/logs/{ansible,build}
 }
 
-detect_distro
 setup_logging
 tools/dump_info.sh
 setup_ssh