aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/setup_Debian.sh (renamed from tests/setup_ubuntu.sh)5
-rwxr-xr-xtests/setup_RedHat.sh (renamed from tests/setup_centos.sh)5
-rwxr-xr-xtests/setup_deploy.sh31
-rwxr-xr-xtests/setup_gate.sh105
-rw-r--r--tests/setup_nodes.yml28
-rw-r--r--tox.ini3
6 files changed, 126 insertions, 51 deletions
diff --git a/tests/setup_ubuntu.sh b/tests/setup_Debian.sh
index 66280da34..c9159e003 100755
--- a/tests/setup_ubuntu.sh
+++ b/tests/setup_Debian.sh
@@ -3,7 +3,10 @@
set -o xtrace
set -o errexit
-sudo mount
+DEV=$1
+
+# (SamYaple)TODO: Remove the path overriding
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Setup Docker repo and add signing key
echo 'deb http://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee /etc/apt/sources.list.d/docker.list
diff --git a/tests/setup_centos.sh b/tests/setup_RedHat.sh
index 5800cce3c..e9920a0da 100755
--- a/tests/setup_centos.sh
+++ b/tests/setup_RedHat.sh
@@ -3,6 +3,11 @@
set -o xtrace
set -o errexit
+DEV=$1
+
+# (SamYaple)TODO: Remove the path overriding
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
cat | sudo tee /etc/yum.repos.d/docker.repo << EOF
[docker]
name=Docker Main Repository
diff --git a/tests/setup_deploy.sh b/tests/setup_deploy.sh
deleted file mode 100755
index 366bbf5a8..000000000
--- a/tests/setup_deploy.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-set -o xtrace
-set -o errexit
-
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
-function create_keys {
- # Setup ssh key as required
- sudo -H ssh-keygen -f /root/.ssh/id_rsa -N ""
- sudo -H cat /root/.ssh/id_rsa.pub | sudo -H tee /root/.ssh/authorized_keys
-}
-
-function install_deps {
- # Install Ansible and docker-py
- sudo -H pip install "ansible<2" docker-py
- pip freeze | egrep "docker|ansible"
-}
-
-function copy_configs {
- # Copy configs
- sudo cp -a etc/kolla /etc/
-}
-
-create_keys
-install_deps
-copy_configs
-
-# Link the logs directory into root
-mkdir -p logs
-sudo ln -s $(pwd)/logs /root/logs
diff --git a/tests/setup_gate.sh b/tests/setup_gate.sh
index 7919f4ae9..b270c03c2 100755
--- a/tests/setup_gate.sh
+++ b/tests/setup_gate.sh
@@ -3,25 +3,98 @@
set -o xtrace
set -o errexit
-export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
-# TODO(SamYaple): This check could be much better, but should work for now
-if [[ $(hostname | grep rax) ]]; then
- export DEV="xvde"
-else
- echo "Assuming this is an hpcloud box"
- export DEV="vdb"
-fi
-
# Just for mandre :)
if [[ ! -f /etc/sudoers.d/jenkins ]]; then
echo "jenkins ALL=(:docker) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/jenkins
fi
-# This creates a logs directory for the devstack logs publisher
-mkdir logs
-# We symlink the logs dir to a known location
-ln -s $(pwd)/logs /tmp/logs
+function detect_disk {
+ # TODO(SamYaple): This check could be much better, but should work for now
+ if [[ $(hostname | grep rax) ]]; then
+ export DEV="xvde"
+ else
+ echo "Assuming this is an hpcloud box"
+ export DEV="vdb"
+ fi
+}
+
+function setup_config {
+ # Copy configs
+ sudo cp -a etc/kolla /etc/
+}
+
+function detect_distro {
+ DISTRO=$(ansible all -i "localhost," -msetup -clocal | awk -F\" '/ansible_os_family/ {print $4}')
+}
+
+function setup_ssh {
+ # Generate a new keypair that Ansible will use
+ ssh-keygen -f /home/jenkins/.ssh/kolla -N ''
+ cat /home/jenkins/.ssh/kolla.pub >> /home/jenkins/.ssh/authorized_keys
+
+ # Push the the public key around to all of the nodes
+ for ip in $(cat /etc/nodepool/sub_nodes_private); do
+ scp /home/jenkins/.ssh/kolla.pub ${ip}:/home/jenkins/.ssh/authorized_keys
+ # TODO(SamYaple): Remove this root key pushing once Kolla doesn't
+ # require root anymore.
+ ssh ${ip} -i /home/jenkins/.ssh/kolla 'sudo mkdir -p /root/.ssh; sudo cp /home/jenkins/.ssh/* /root/.ssh/'
+ done
+
+ # From now on use the new IdentityFile for connecting to other hosts
+ echo "IdentityFile /home/jenkins/.ssh/kolla" >> /home/jenkins/.ssh/config
+}
+
+function setup_inventory {
+ local counter=0
+
+ detect_distro
+ if [[ "${DISTRO}" == "Debian" ]]; then
+ ANSIBLE_CONNECTION_TYPE=ssh
+ else
+ ANSIBLE_CONNECTION_TYPE=local
+ fi
+
+ echo -e "127.0.0.1\tlocalhost" > /tmp/hosts
+ for ip in $(cat /etc/nodepool/{node_private,sub_nodes_private}); do
+ : $((counter++))
+ echo -e "${ip}\tnode${counter} $(ssh ${ip} hostname)" >> /tmp/hosts
+ echo "node${counter} ansible_connection=${ANSIBLE_CONNECTION_TYPE}" >> ${RAW_INVENTORY}
+ done
+
+ sudo chown root: /tmp/hosts
+ sudo chmod 644 /tmp/hosts
+ sudo mv /tmp/hosts /etc/hosts
+}
+
+function setup_ansible {
+ RAW_INVENTORY=/tmp/kolla/raw_inventory
+ mkdir /tmp/kolla
+
+ sudo -H pip install "ansible<2" docker-py
+
+ setup_inventory
+
+ # Record the running state of the environment as seen by the setup module
+ ansible all -i ${RAW_INVENTORY} -m setup > /tmp/logs/ansible/initial-setup
+}
+
+function setup_node {
+ detect_disk
+ ansible-playbook -i ${RAW_INVENTORY} -edocker_dev=${DEV} tests/setup_nodes.yml
+}
+
+function setup_logging {
+ # This directory is the directory that is copied with the devstack-logs
+ # publisher. It must exist at /home/jenkins/workspace/<job-name>/logs
+ mkdir logs
+
+ # For ease of access we symlink that logs directory to a known path
+ ln -s $(pwd)/logs /tmp/logs
+ mkdir -p /tmp/logs/{ansible,build}
+}
-distro=$(awk -F'[="]'+ '/^ID/ {print tolower($2); exit}' /etc/*-release)
-exec tests/setup_${distro}.sh
+setup_logging
+setup_ssh
+setup_ansible
+setup_node
+setup_config
diff --git a/tests/setup_nodes.yml b/tests/setup_nodes.yml
new file mode 100644
index 000000000..e23da173d
--- /dev/null
+++ b/tests/setup_nodes.yml
@@ -0,0 +1,28 @@
+---
+- hosts: all
+ sudo: yes
+ tasks:
+ - name: Setup /etc/hosts
+ copy:
+ src: /etc/hosts
+ dest: /etc/hosts
+
+ - name: Assign hostname
+ hostname:
+ name: "{{ inventory_hostname }}"
+
+ - name: Copy setup script
+ copy:
+ src: setup_{{ ansible_os_family }}.sh
+ dest: /tmp/setup.sh
+ mode: 0755
+
+- hosts: all
+ tasks:
+ - name: Create log directory for node
+ file:
+ state: directory
+ path: /tmp/{{ inventory_hostname }}
+
+ - name: Run node setup
+ shell: sudo /tmp/setup.sh {{ docker_dev }}
diff --git a/tox.ini b/tox.ini
index 3ae566149..c7909a2ab 100644
--- a/tox.ini
+++ b/tox.ini
@@ -70,7 +70,6 @@ commands =
find . -type f -name "*.pyc" -delete
bash -c "if [ ! -d .testrepository ]; then testr init; fi"
sudo -g docker testr run test_build.DeployTestCentosBinary
- bash tests/setup_deploy.sh
sudo tests/deploy_aio.sh centos binary
[testenv:deploy-centos-source]
@@ -81,7 +80,6 @@ commands =
find . -type f -name "*.pyc" -delete
bash -c "if [ ! -d .testrepository ]; then testr init; fi"
sudo -g docker testr run test_build.DeployTestCentosSource
- bash tests/setup_deploy.sh
sudo tests/deploy_aio.sh centos source
[testenv:deploy-ubuntu-source]
@@ -92,7 +90,6 @@ commands =
find . -type f -name "*.pyc" -delete
bash -c "if [ ! -d .testrepository ]; then testr init; fi"
sudo -g docker testr run test_build.DeployTestUbuntuSource
- bash tests/setup_deploy.sh
sudo tests/deploy_aio.sh ubuntu source
[testenv:deploy-multinode-ubuntu-source]