Porting to Xenial

With the Jenkins jobs being switched to Xenial there are several
required changes:

1. Add  bindep.txt with necessary deps so as to moot the previous
   distro_packages builder in the jenkins job template. using
   distro_packages builder causes mysql to be installed twice which
   in turn fails the devstack code attempt to set the mysql password.
   The job template fix is merged but not yet being picked up by Jenkins

2. Add a MY_SQL password var to the devstack installation definition
   in install/swift/localrc.sample. This is probably requirted due to
   the different behavior of empty password with Xenial mysql

3. Fix the repo dir to include the distro suffix:
   ubuntu-trusty for 14.04
   ubuntu-xenial for 16.04

4. Adopt the Ansible installation scripts to Xenial. There were
   several issues around the docker installation. Also, while at it
   I got rid of the docker_registry usage which is anyway going to go
   away as we port the installation to devstack.

Note: some of the fixes to Ansible are quick and dirty, but again,
this code is going away soon anyway.

Change-Id: Iae9b762ac1f390dfb686e37f9ef2737baef0a079
This commit is contained in:
Eran Rom 2016-12-08 11:24:48 +02:00 committed by Takashi Kajinami
parent 647d41a369
commit 1e5bc9afb7
21 changed files with 76 additions and 184 deletions

17
bindep.txt Normal file
View File

@ -0,0 +1,17 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see http://docs.openstack.org/infra/bindep/ for additional information.
build-essential [platform:dpkg]
gcc [platform:rpm]
gettext
liberasurecode-dev [platform:dpkg]
liberasurecode-devel [platform:rpm]
libffi-dev [platform:dpkg]
libffi-devel [platform:rpm]
memcached
python-dev [platform:dpkg]
python-devel [platform:rpm]
rsync
xfsprogs
libssl-dev [platform:dpkg]
openssl-devel [platform:rpm]

View File

@ -16,6 +16,5 @@
- hosts: docker
roles:
- role: docker_client
- role: docker_registry
- role: docker_base_jre_image
- role: docker_storlet_engine_image

View File

@ -17,10 +17,5 @@
roles:
- role: enable_default_swift_account_for_storlets
- role: create_default_tenant_docker_image
tenant_image_name: "{{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}/{{ base_os_image }}_jre8_storlets"
tenant_name: "{{ storlets_default_tenant_name }}"
- hosts: storlet-proxy:storlet-storage
roles:
- role: pull_default_tenant_docker_image
tenant_image_name: "{{ base_os_image }}_jre8_storlets"
tenant_name: "{{ storlets_default_tenant_name }}"

View File

@ -74,7 +74,8 @@ else
sed -i 's/<SWIFT_RUNTIME_GROUP>/'$USER'/g' deploy/installation_vars.yml
sed -i 's/<SWIFT_RUNTIME_DIR>/\/opt\/stack\/data\/swift\/run/g' deploy/installation_vars.yml
if [ "$FLAVOR" == "jenkins" ]; then
sed -i 's/<STORLETS_REPO_ROOT>/\/home\/'$USER'\/workspace\/gate-storlets-functional\//g' deploy/installation_vars.yml
source /etc/lsb-release
sed -i 's/<STORLETS_REPO_ROOT>/\/home\/'$USER'\/workspace\/gate-storlets-functional-'${DISTRIB_ID,,}'-'$DISTRIB_CODENAME'\//g' deploy/installation_vars.yml
else
sed -i 's/<STORLETS_REPO_ROOT>/~\/storlets\//g' deploy/installation_vars.yml
fi

View File

@ -6,5 +6,5 @@ log_dir = {{ docker_device }}/logs/scopes
script_dir = {{ docker_device }}/scripts
storlets_dir = {{ docker_device }}/storlets/scopes
pipes_dir = {{ docker_device }}/pipes/scopes
docker_repo = {{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}
docker_repo = ""
restart_linux_container_timeout = {{ restart_linux_container_timeout }}

View File

@ -35,13 +35,9 @@
become: true
- name: "Build the image {{ tenant_id.stdout_lines[0] }}"
command: "docker build -q -t {{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}/{{ tenant_id.stdout_lines[0] }} ."
command: "docker build -q -t {{ tenant_id.stdout_lines[0] }} ."
args:
chdir: "/data/registry/repositories/{{ tenant_id.stdout_lines[0] }}"
register: command_result
become: true
failed_when: "'sha256:' not in command_result.stdout"
- name: Push the image to the global registry
command: "docker push {{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}/{{ tenant_id.stdout_lines[0] }}"
become: true

View File

@ -102,11 +102,8 @@
when: "'1' in image_exists.stdout"
- name: Build the new default tenant container image
command: "docker build -t {{ inventory_hostname }}:{{ docker_registry_port }}/{{ tenant_id.stdout_lines[0] }} ."
command: "docker build -t {{ tenant_id.stdout_lines[0] }} ."
args:
chdir: "/data/registry/repositories/default_tenant_image"
register: command_result
failed_when: "'Successfully built' not in command_result.stdout"
- name: Push the default_tenant_image into the repository
command: "docker push {{ inventory_hostname }}:{{ docker_registry_port }}/{{ tenant_id.stdout_lines[0] }}"

View File

@ -13,7 +13,7 @@
# Limitations under the License.
#---------------------------------------------------------------------------
FROM {{ inventory_hostname }}:{{ docker_registry_port }}/{{base_os_image}}_jre8_storlets
FROM {{base_os_image}}_jre8_storlets
MAINTAINER root

View File

@ -21,7 +21,7 @@
mode: 0644
- name: Build the image {{ layer_suffix }}
command: "docker build -q -t {{ inventory_hostname }}:{{ docker_registry_port }}/{{ base_os_image }}_{{ layer_suffix }} ."
command: "docker build -q -t {{ base_os_image }}_{{ layer_suffix }} ."
args:
chdir: "/data/registry/repositories/{{ base_os_image }}_{{ layer_suffix }}"
register: command_result

View File

@ -13,14 +13,14 @@
# Limitations under the License.
#---------------------------------------------------------------------------
- name: Tag the Ubuntu 14.04 image as "{{ inventory_hostname }}:{{ docker_registry_port }}/ubuntu_14.04"
shell: docker images | grep "{{ inventory_hostname }}:{{ docker_registry_port }}/ubuntu_14.04" | wc -l
- name: Tag the Ubuntu 14.04 image
shell: docker images | grep ubuntu_14.04 | wc -l
register: ubuntu_image
- command: "{{ item }}"
with_items:
- "docker pull ubuntu:14.04"
- "docker tag ubuntu:14.04 {{ inventory_hostname }}:{{ docker_registry_port }}/ubuntu_14.04"
- "docker tag ubuntu:14.04 ubuntu_14.04"
when: "'0' in ubuntu_image.stdout_lines[0]"
- name: Create Repository for building the image

View File

@ -13,7 +13,7 @@
# Limitations under the License.
#---------------------------------------------------------------------------
FROM {{ inventory_hostname }}:{{ docker_registry_port }}/ubuntu_14.04
FROM ubuntu:14.04
MAINTAINER {{ base_image_maintainer }}

View File

@ -25,20 +25,37 @@
- shell: dpkg --get-selections | grep docker-engine | awk {'print $2'} | grep -w install | wc -l
register: docker_engine
become: yes
when: "ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'"
- shell: dpkg --get-selections | grep docker.io | awk {'print $2'} | grep -w install | wc -l
register: docker_engine
become: yes
when: "ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial'"
- command: uname -r
register: uname
- apt:
- name: install necessary linux-image-extra
apt:
name: linux-image-extra-{{ uname.stdout_lines[0] }}
update-cache: yes
force: yes
when: "'0' in linux_image_extra.stdout_lines[0]"
- apt:
- name: install aufs-tools
apt:
name: aufs-tools=1:3.2+20130722-1.1
update-cache: yes
force: yes
when: "'0' in aufs.stdout_lines[0]"
when: "'0' in aufs.stdout_lines[0] and ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'"
become: yes
- name: install aufs-tools
apt:
name: aufs-tools
update-cache: yes
force: yes
when: "'0' in aufs.stdout_lines[0] and ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial'"
become: yes
- name: Set Docker Ubuntu Repo Key
@ -59,7 +76,14 @@
apt_repository:
repo: 'deb https://apt.dockerproject.org/repo ubuntu-trusty main'
state: present
when: "'0' in docker_engine.stdout_lines[0]"
when: "'0' in docker_engine.stdout_lines[0] and ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'"
become: yes
- name: Add Docker Apt repository
apt_repository:
repo: 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
state: present
when: "'0' in docker_engine.stdout_lines[0] and ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'"
become: yes
- name: Install Docker Client
@ -68,7 +92,16 @@
state: present
update-cache: yes
force: yes
when: "'0' in docker_engine.stdout_lines[0]"
when: "'0' in docker_engine.stdout_lines[0] and ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'"
become: yes
- name: Install Docker Client
apt:
name: docker.io
state: present
update-cache: yes
force: yes
when: "'0' in docker_engine.stdout_lines[0] and ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial'"
become: yes
# There seem to be a bug in the installation where config files are not installed.
@ -84,7 +117,7 @@
lineinfile:
dest: /etc/default/docker
regexp: "^DOCKER_OPTS.*"
line: DOCKER_OPTS="-g {{ docker_device }}/docker --insecure-registry {{ groups['docker'][0]}}:{{ docker_registry_port }}"
line: DOCKER_OPTS="-g {{ docker_device }}/docker"
backup: yes
state: present
when: st1.stat.exists and '0' in edited.stdout
@ -110,18 +143,6 @@
template: src=etc_init.d_docker dest=/etc/init.d/docker owner=root mode=0755
when: not st4.stat.exists
# Patch the docker config files to use the insecure registry
- name: ADD --insecure {{ groups['docker'][0] }}:{{ docker_registry_port }} to docker daemon defaults
shell: grep DOCKER_OPTS /etc/default/docker | wc -l
register: opt_lines_count
- lineinfile:
dest: /etc/default/docker
state: present
line: DOCKER_OPTS="$DOCKER_OPTS --insecure-registry {{ groups['docker'][0] }}:{{ docker_registry_port }}"
insertafter: "^DOCKER_OPTS="
when: "'2' in opt_lines_count.stdout"
- name: Stop Docker Daemon
shell: bash -c "/usr/sbin/service docker stop"
become: yes

View File

@ -4,7 +4,7 @@
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="-g {{ docker_device }}/docker --insecure-registry {{groups['docker'][0] }}:{{ docker_registry_port }}"
DOCKER_OPTS="-g {{ docker_device }}/docker"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

View File

@ -1,41 +0,0 @@
#---------------------------------------------------------------------------
# Copyright IBM Corp. 2015, 2015 All Rights Reserved
# 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.
#---------------------------------------------------------------------------
- name: Create docker-registry service
stat: path=/etc/init.d/docker-registry
register: st0
- template:
src: etc/init.d/docker-registry
dest: /etc/init.d/docker-registry
owner: root
mode: 0755
when: not st0.stat.exists
- name: Start Docker repository service
shell: bash -c "/usr/sbin/service docker-registry start"
- name: Test repository
shell: docker images | grep my_busybox | wc -l
register: busy_box
- command: docker pull busybox
when: "'0' in busy_box.stdout_lines[0]"
- command: docker tag busybox "{{ inventory_hostname }}:{{ docker_registry_port }}/my_busybox"
when: "'0' in busy_box.stdout_lines[0]"
- command: docker push "{{ inventory_hostname }}:{{ docker_registry_port }}/my_busybox"
when: "'0' in busy_box.stdout_lines[0]"

View File

@ -1,53 +0,0 @@
#!/bin/bash
status() {
{% raw %}
state=`docker inspect --format="{{ .State.Running }}" registry`
{% endraw %}
if [ $? -eq 0 ] && [ $state == 'true' ]; then
echo docker-registry is running
return 1
else
echo docker-registry not running
return 0
fi
}
start() {
status
if [ $? -eq 0 ]; then
docker stop registry &> /dev/null
docker rm registry &> /dev/null
docker run --restart unless-stopped -d -p {{ docker_registry_port }}:5000 -v /var/lib/registry:/var/lib/registry --name registry registry:2
echo docker-registry started
fi
}
stop() {
status
if [ $? -eq 1 ]; then
docker stop registry &> /dev/null
docker rm registry &> /dev/null
echo docker-registry stopped
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0

View File

@ -21,11 +21,8 @@
mode: 0644
- name: Build the image {{ layer_suffix }}
command: "docker build -q -t {{ inventory_hostname }}:{{ docker_registry_port }}/{{ base_os_image }}_{{ layer_suffix }} ."
command: "docker build -q -t {{ base_os_image }}_{{ layer_suffix }} ."
args:
chdir: "/data/registry/repositories/{{ base_os_image }}_{{ layer_suffix }}"
register: command_result
failed_when: "'sha256:' not in command_result.stdout"
- name: Push the Image {{ layer_suffix }} in the repository
command: "docker push {{ inventory_hostname }}:{{ docker_registry_port }}/{{ base_os_image }}_{{ layer_suffix }}"

View File

@ -13,7 +13,7 @@
# Limitations under the License.
#---------------------------------------------------------------------------
FROM {{ inventory_hostname }}:{{ docker_registry_port }}/{{base_os_image}}_jre8
FROM {{base_os_image}}_jre8
MAINTAINER {{ base_image_maintainer }}

View File

@ -1,26 +0,0 @@
# Copyright (c) 2016 OpenStack Foundation
#
# 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.
# TODO(eranr): Chaneg the below to use Ansible os_project_facts
- name: Get the tenant id from Keystone
shell: openstack --os-auth-url={{keystone_public_url}} --os-username={{keystone_admin_user}} --os-password={{keystone_admin_password}} --os-project-name={{keystone_admin_project}} project list | grep {{ tenant_name }} | awk '{print $2}'
register: tenant_id
- name: docker pull
command: docker pull {{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}/{{ tenant_id.stdout_lines[0] }}
become: true
- name: shutdown_container
shell: "/usr/bin/python {{ docker_device }}/scripts/send_halt_cmd_to_daemon_factory.py {{ docker_device }}/pipes/scopes/AUTH_{{ tenant_id.stdout_lines[0] }}/factory_pipe"

View File

@ -4,10 +4,9 @@ set -eu
# Invokes a devstack install that consists of
# keyastone and swift.
if [ "$#" -ne 2 ] && [ "$#" -ne 3 ]; then
if [ "$#" -ne 2 ]; then
echo "Usage: $0 [target] [ip] [flavour]"
echo "target = host | docker"
echo "optionally specify flavour=dev installation"
exit
fi
@ -19,12 +18,6 @@ fi
SWIFT_IP=$2
if [ "$#" -eq 3 ]; then
FLAVOR=$3
else
FLAVOR=''
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DEVSTACK_DIR=~/devstack
@ -34,11 +27,7 @@ if [ ! -e $DEVSTACK_DIR ]; then
git clone git://github.com/openstack-dev/devstack.git $DEVSTACK_DIR
cp $DIR/localrc.sample $DEVSTACK_DIR/localrc
sed -i 's/<set ip!>/'$SWIFT_IP'/g' $DEVSTACK_DIR/localrc
if [ $FLAVOR = 'dev' ]; then
sed -i 's/<set db password!>/admin/g' $DEVSTACK_DIR/localrc
else
sed -i '/<set db password!>/d' $DEVSTACK_DIR/localrc
fi
sed -i 's/<set db password!>/admin/g' $DEVSTACK_DIR/localrc
fi
# run devstack

View File

@ -5,7 +5,7 @@ ENABLED_SERVICES=key,swift,mysql
ADMIN_USER=admin
ADMIN_PASSWORD=admin
ADMIN_PROJECT=admin
DATABASE_PASSWORD=<set db password!>
MYSQL_PASSWORD=<set db password!>
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
export OS_IDENTITY_API_VERSION=2

View File

@ -85,7 +85,7 @@ if [ "$TARGET" == "docker" ]; then
sudo docker cp install/swift/localrc.sample s2aio:/home/stack/localrc.sample
sudo docker exec s2aio chown -R stack:stack /home/stack
sudo docker exec --user stack s2aio chmod -R 0755 /home/stack
sudo docker exec --user stack s2aio /home/stack/install_swift.sh docker $S2AIO_IP $FLAVOR
sudo docker exec --user stack s2aio /home/stack/install_swift.sh docker $S2AIO_IP
sudo docker exec s2aio service rsyslog restart
else
export S2AIO_IP='127.0.0.1'
@ -111,7 +111,7 @@ else
# Install Swift
cd install/swift
./install_swift.sh host $S2AIO_IP $FLAVOR
./install_swift.sh host $S2AIO_IP
cd -
fi