Browse Source

TripleO Container build CI job

We don't currently have coverage for the container build process in CI,
let's add some.

Depends-On: https://review.openstack.org/#/c/616022/
Change-Id: I97ceb9533a38ec7b175623784649de277aaf4274
changes/92/614392/31
Alex Schultz 1 year ago
parent
commit
73d40aec70
8 changed files with 245 additions and 0 deletions
  1. +49
    -0
      playbooks/tripleo-buildcontainers/post.yaml
  2. +66
    -0
      playbooks/tripleo-buildcontainers/pre.yaml
  3. +76
    -0
      playbooks/tripleo-buildcontainers/run.yaml
  4. +4
    -0
      playbooks/tripleo-buildcontainers/templates/docker-playbook.yaml.j2
  5. +9
    -0
      playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2
  6. +2
    -0
      playbooks/tripleo-buildcontainers/vars/common.yaml
  7. +38
    -0
      zuul.d/build-containers.yaml
  8. +1
    -0
      zuul.d/layout.yaml

+ 49
- 0
playbooks/tripleo-buildcontainers/post.yaml View File

@@ -0,0 +1,49 @@
- hosts: primary
tasks:
- name: Include common vars
include_vars:
file: "common.yaml"

- name: Grab job artifacts
become: true
args:
chdir: "{{ workspace }}"
shell: |
set -x
mkdir -p {{ workspace }}/conf/
mkdir -p {{ workspace }}/logs/system
mkdir -p {{ workspace }}/etc/docker

mv *.conf {{ workspace }}/conf/
mv *.log {{ workspace }}/logs/
rsync -var --no-links /var/log/ {{ workspace }}/logs/system/ || true
rsync -var --no-links /etc/docker/ {{ workspace }}/etc/docker/ || true
gzip -r "{{ workspace }}/logs" "{{ workspace }}/conf" "{{ workspace }}/etc"
chmod -R a+r "{{ workspace }}"
chown -R {{ ansible_user }}: "{{ workspace }}"

- name: Rename compressed text based files to end with txt.gz extension
become: true
shell: >
set -o pipefail &&
find {{ workspace }}/logs {{ workspace }}/conf {{ workspace }}/etc -type f |
awk 'function rename(orig)
{ new=orig; sub(/\.gz$/, ".txt.gz", new); system("mv " orig " " new) }
/\.(conf|ini|json|sh|log|yaml|yml|repo|cfg|j2|py)\.gz$/ { rename($0) }
/(\/logs\/|\/etc\/)[^ \/\.]+\.gz$/ { rename($0) }';

- name: Copy files from {{ ansible_user_dir }}/workspace/ on node
#no_log: true
synchronize:
src: '{{ ansible_user_dir }}/workspace/'
dest: '{{ zuul.executor.log_root }}'
mode: pull
copy_links: true
verify_host: true
rsync_opts:
- --include=/etc/**
- --include=/conf/**
- --include=/logs/**
- --include=*/
- --exclude=*
- --prune-empty-dirs

+ 66
- 0
playbooks/tripleo-buildcontainers/pre.yaml View File

@@ -0,0 +1,66 @@
- hosts: all
name: TripleO Setup Container Registry and repos mirror
roles:
- role: tripleo-repos
tripleo_repos_repository: "{{ ansible_user_dir }}/{{ zuul.projects['git.openstack.org/openstack/tripleo-repos'].src_dir }}"
tasks:
- name: Include common vars
include_vars:
file: "common.yaml"

- name: Ensure legacy workspace directory
file:
path: '{{ workspace }}'
state: directory

- name: Setup docker registry
block:
- name: Install ansible
become: true
package:
name: ansible
state: present

- name: Create playbook structure
file:
path: '{{ workspace }}/container-registry'
src: '{{ openstack_git_root }}/ansible-role-container-registry'
state: link

- name: Configure docker registry
template:
src: templates/docker-playbook.yaml.j2
dest: '{{ workspace }}/docker-playbook.yaml'
mode: 0644
force: yes

- name: Run ansible playbook to configure docker
args:
chdir: '{{ workspace }}'
shell: |
ansible-playbook docker-playbook.yaml --extra-vars "container_registry_deployment_user={{ ansible_user }}"

- name: Add docker masquerading rules
become: true
command: iptables -t nat -A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE

- name: Reset connection because of group changes for current user
meta: reset_connection

- name: Setup repo web service
become: true
block:
- name: Install apache
package:
name: httpd
state: present

- name: Start apache
service:
name: httpd
state: running

- name: Fetch delorean repos
shell: |
set -ex
cp /etc/yum.repos.d/delorean* /var/www/html/

+ 76
- 0
playbooks/tripleo-buildcontainers/run.yaml View File

@@ -0,0 +1,76 @@
- hosts: all
name: TripleO container image building job
roles:
- role: bindep
bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['git.openstack.org/openstack/python-tripleoclient'].src_dir }}"
tasks:
- name: Include common vars
include_vars:
file: "common.yaml"

- name: Get branch
set_fact:
ci_branch: "{{ zuul.branch | default('master') | replace('stable/','') }}"

- name: Swap is essential as we are not meeting memory requirements
include_role:
name: configure-swap

- name: Set legacy log path
include_role:
name: set-zuul-log-path-fact

- name: Ensure legacy workspace directory
file:
path: '{{ workspace }}'
state: directory

- name: Ensure legacy logs directory
file:
path: '{{ workspace }}/logs'
state: directory

- name: Install pip
become: true
package:
name: python-pip
state: present

- name: Install virtualenv
become: true
package:
name: python-virtualenv
state: present

- name: pip install required items
become: true
pip:
name: "{{ item }}"
state: present
virtualenv: "{{ workspace }}/venv"
with_items:
- "file://{{ openstack_git_root }}/kolla"
- "file://{{ openstack_git_root }}/tripleo-common"
- "file://{{ openstack_git_root }}/python-tripleoclient"

# TODO(aschultz): make the kolla-build branch aware
- name: Generate kolla-build.conf
template:
src: templates/kolla-build.conf.j2
dest: "{{ workspace }}/kolla-build.conf"
mode: 0644
force: yes

- name: Run image build
args:
chdir: '{{ workspace }}'
shell: |
set -x
source {{ workspace }}/venv/bin/activate
TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common"

openstack overcloud container image build \
--config-file $TRIPLEO_COMMON_PATH/container-images/overcloud_containers.yaml \
--kolla-config-file {{ workspace }}/kolla-build.conf > {{ workspace }}/build.log 2> {{ workspace }}/build-err.log
RESULT=$?
exit $RESULT

+ 4
- 0
playbooks/tripleo-buildcontainers/templates/docker-playbook.yaml.j2 View File

@@ -0,0 +1,4 @@
- hosts: localhost
become: true
roles:
- container-registry

+ 9
- 0
playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2 View File

@@ -0,0 +1,9 @@
[DEFAULT]
base=centos
type=binary
namespace='{{ ci_branch | replace("/", "") }}'
registry=127.0.0.1:8787
tag=latest
template_override={{ openstack_git_root }}/tripleo-common/container-images/tripleo_kolla_template_overrides.j2
rpm_setup=http://localhost/delorean.repo,http://localhost/delorean-deps.repo


+ 2
- 0
playbooks/tripleo-buildcontainers/vars/common.yaml View File

@@ -0,0 +1,2 @@
workspace: "{{ ansible_user_dir }}/workspace"
openstack_git_root: "{{ ansible_user_dir }}/src/git.openstack.org/openstack"

+ 38
- 0
zuul.d/build-containers.yaml View File

@@ -0,0 +1,38 @@
---
# zuul.d/build-containers.yaml
# Zuul layout for TripleO Build Containers jobs.

- project-template:
name: tripleo-build-containers-jobs
check:
jobs:
- tripleo-build-containers-centos-7

- job:
name: tripleo-build-containers-centos-7
parent: tripleo-ci-base-singlenode
pre-run:
- playbooks/tripleo-buildcontainers/pre.yaml
run: playbooks/tripleo-buildcontainers/run.yaml
post-run: playbooks/tripleo-buildcontainers/post.yaml
timeout: 7200
nodeset: single-centos-7-node
voting: false
required-projects:
- git.openstack.org/openstack/ansible-role-container-registry
- git.openstack.org/openstack/kolla
- git.openstack.org/openstack/python-tripleoclient
- git.openstack.org/openstack/requirements
- git.openstack.org/openstack/tripleo-common
- git.openstack.org/openstack/tripleo-repos
irrelevant-files:
- ^.*\.rst$
- ^releasenotes/.*$
files:
# tripleo-ci
- ^playbooks/tripleo-buildcontainers/.*$
# tripleo-common
- ^container-images/.*$
- ^tripleo_common/image/.*$
# python-tripleoclient
- ^tripleoclient/v1/container.*$

+ 1
- 0
zuul.d/layout.yaml View File

@@ -11,6 +11,7 @@
- tripleo-multinode-experimental
- tripleo-undercloud-jobs
- tripleo-multinode-branchful
- tripleo-build-containers-jobs
check:
jobs:
- openstack-tox-linters

Loading…
Cancel
Save