summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playbooks/tripleo-buildcontainers/post.yaml49
-rw-r--r--playbooks/tripleo-buildcontainers/pre.yaml66
-rw-r--r--playbooks/tripleo-buildcontainers/run.yaml76
-rw-r--r--playbooks/tripleo-buildcontainers/templates/docker-playbook.yaml.j24
-rw-r--r--playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j29
-rw-r--r--playbooks/tripleo-buildcontainers/vars/common.yaml2
-rw-r--r--zuul.d/build-containers.yaml38
-rw-r--r--zuul.d/layout.yaml1
8 files changed, 245 insertions, 0 deletions
diff --git a/playbooks/tripleo-buildcontainers/post.yaml b/playbooks/tripleo-buildcontainers/post.yaml
new file mode 100644
index 0000000..62979ec
--- /dev/null
+++ b/playbooks/tripleo-buildcontainers/post.yaml
@@ -0,0 +1,49 @@
1- hosts: primary
2 tasks:
3 - name: Include common vars
4 include_vars:
5 file: "common.yaml"
6
7 - name: Grab job artifacts
8 become: true
9 args:
10 chdir: "{{ workspace }}"
11 shell: |
12 set -x
13 mkdir -p {{ workspace }}/conf/
14 mkdir -p {{ workspace }}/logs/system
15 mkdir -p {{ workspace }}/etc/docker
16
17 mv *.conf {{ workspace }}/conf/
18 mv *.log {{ workspace }}/logs/
19 rsync -var --no-links /var/log/ {{ workspace }}/logs/system/ || true
20 rsync -var --no-links /etc/docker/ {{ workspace }}/etc/docker/ || true
21 gzip -r "{{ workspace }}/logs" "{{ workspace }}/conf" "{{ workspace }}/etc"
22 chmod -R a+r "{{ workspace }}"
23 chown -R {{ ansible_user }}: "{{ workspace }}"
24
25 - name: Rename compressed text based files to end with txt.gz extension
26 become: true
27 shell: >
28 set -o pipefail &&
29 find {{ workspace }}/logs {{ workspace }}/conf {{ workspace }}/etc -type f |
30 awk 'function rename(orig)
31 { new=orig; sub(/\.gz$/, ".txt.gz", new); system("mv " orig " " new) }
32 /\.(conf|ini|json|sh|log|yaml|yml|repo|cfg|j2|py)\.gz$/ { rename($0) }
33 /(\/logs\/|\/etc\/)[^ \/\.]+\.gz$/ { rename($0) }';
34
35 - name: Copy files from {{ ansible_user_dir }}/workspace/ on node
36 #no_log: true
37 synchronize:
38 src: '{{ ansible_user_dir }}/workspace/'
39 dest: '{{ zuul.executor.log_root }}'
40 mode: pull
41 copy_links: true
42 verify_host: true
43 rsync_opts:
44 - --include=/etc/**
45 - --include=/conf/**
46 - --include=/logs/**
47 - --include=*/
48 - --exclude=*
49 - --prune-empty-dirs
diff --git a/playbooks/tripleo-buildcontainers/pre.yaml b/playbooks/tripleo-buildcontainers/pre.yaml
new file mode 100644
index 0000000..7ac6ff2
--- /dev/null
+++ b/playbooks/tripleo-buildcontainers/pre.yaml
@@ -0,0 +1,66 @@
1- hosts: all
2 name: TripleO Setup Container Registry and repos mirror
3 roles:
4 - role: tripleo-repos
5 tripleo_repos_repository: "{{ ansible_user_dir }}/{{ zuul.projects['git.openstack.org/openstack/tripleo-repos'].src_dir }}"
6 tasks:
7 - name: Include common vars
8 include_vars:
9 file: "common.yaml"
10
11 - name: Ensure legacy workspace directory
12 file:
13 path: '{{ workspace }}'
14 state: directory
15
16 - name: Setup docker registry
17 block:
18 - name: Install ansible
19 become: true
20 package:
21 name: ansible
22 state: present
23
24 - name: Create playbook structure
25 file:
26 path: '{{ workspace }}/container-registry'
27 src: '{{ openstack_git_root }}/ansible-role-container-registry'
28 state: link
29
30 - name: Configure docker registry
31 template:
32 src: templates/docker-playbook.yaml.j2
33 dest: '{{ workspace }}/docker-playbook.yaml'
34 mode: 0644
35 force: yes
36
37 - name: Run ansible playbook to configure docker
38 args:
39 chdir: '{{ workspace }}'
40 shell: |
41 ansible-playbook docker-playbook.yaml --extra-vars "container_registry_deployment_user={{ ansible_user }}"
42
43 - name: Add docker masquerading rules
44 become: true
45 command: iptables -t nat -A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
46
47 - name: Reset connection because of group changes for current user
48 meta: reset_connection
49
50 - name: Setup repo web service
51 become: true
52 block:
53 - name: Install apache
54 package:
55 name: httpd
56 state: present
57
58 - name: Start apache
59 service:
60 name: httpd
61 state: running
62
63 - name: Fetch delorean repos
64 shell: |
65 set -ex
66 cp /etc/yum.repos.d/delorean* /var/www/html/
diff --git a/playbooks/tripleo-buildcontainers/run.yaml b/playbooks/tripleo-buildcontainers/run.yaml
new file mode 100644
index 0000000..d6843c4
--- /dev/null
+++ b/playbooks/tripleo-buildcontainers/run.yaml
@@ -0,0 +1,76 @@
1- hosts: all
2 name: TripleO container image building job
3 roles:
4 - role: bindep
5 bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['git.openstack.org/openstack/python-tripleoclient'].src_dir }}"
6 tasks:
7 - name: Include common vars
8 include_vars:
9 file: "common.yaml"
10
11 - name: Get branch
12 set_fact:
13 ci_branch: "{{ zuul.branch | default('master') | replace('stable/','') }}"
14
15 - name: Swap is essential as we are not meeting memory requirements
16 include_role:
17 name: configure-swap
18
19 - name: Set legacy log path
20 include_role:
21 name: set-zuul-log-path-fact
22
23 - name: Ensure legacy workspace directory
24 file:
25 path: '{{ workspace }}'
26 state: directory
27
28 - name: Ensure legacy logs directory
29 file:
30 path: '{{ workspace }}/logs'
31 state: directory
32
33 - name: Install pip
34 become: true
35 package:
36 name: python-pip
37 state: present
38
39 - name: Install virtualenv
40 become: true
41 package:
42 name: python-virtualenv
43 state: present
44
45 - name: pip install required items
46 become: true
47 pip:
48 name: "{{ item }}"
49 state: present
50 virtualenv: "{{ workspace }}/venv"
51 with_items:
52 - "file://{{ openstack_git_root }}/kolla"
53 - "file://{{ openstack_git_root }}/tripleo-common"
54 - "file://{{ openstack_git_root }}/python-tripleoclient"
55
56 # TODO(aschultz): make the kolla-build branch aware
57 - name: Generate kolla-build.conf
58 template:
59 src: templates/kolla-build.conf.j2
60 dest: "{{ workspace }}/kolla-build.conf"
61 mode: 0644
62 force: yes
63
64 - name: Run image build
65 args:
66 chdir: '{{ workspace }}'
67 shell: |
68 set -x
69 source {{ workspace }}/venv/bin/activate
70 TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common"
71
72 openstack overcloud container image build \
73 --config-file $TRIPLEO_COMMON_PATH/container-images/overcloud_containers.yaml \
74 --kolla-config-file {{ workspace }}/kolla-build.conf > {{ workspace }}/build.log 2> {{ workspace }}/build-err.log
75 RESULT=$?
76 exit $RESULT
diff --git a/playbooks/tripleo-buildcontainers/templates/docker-playbook.yaml.j2 b/playbooks/tripleo-buildcontainers/templates/docker-playbook.yaml.j2
new file mode 100644
index 0000000..c1806ae
--- /dev/null
+++ b/playbooks/tripleo-buildcontainers/templates/docker-playbook.yaml.j2
@@ -0,0 +1,4 @@
1- hosts: localhost
2 become: true
3 roles:
4 - container-registry
diff --git a/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2 b/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2
new file mode 100644
index 0000000..06a52fc
--- /dev/null
+++ b/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2
@@ -0,0 +1,9 @@
1[DEFAULT]
2base=centos
3type=binary
4namespace='{{ ci_branch | replace("/", "") }}'
5registry=127.0.0.1:8787
6tag=latest
7template_override={{ openstack_git_root }}/tripleo-common/container-images/tripleo_kolla_template_overrides.j2
8rpm_setup=http://localhost/delorean.repo,http://localhost/delorean-deps.repo
9
diff --git a/playbooks/tripleo-buildcontainers/vars/common.yaml b/playbooks/tripleo-buildcontainers/vars/common.yaml
new file mode 100644
index 0000000..6138324
--- /dev/null
+++ b/playbooks/tripleo-buildcontainers/vars/common.yaml
@@ -0,0 +1,2 @@
1workspace: "{{ ansible_user_dir }}/workspace"
2openstack_git_root: "{{ ansible_user_dir }}/src/git.openstack.org/openstack"
diff --git a/zuul.d/build-containers.yaml b/zuul.d/build-containers.yaml
new file mode 100644
index 0000000..d01440a
--- /dev/null
+++ b/zuul.d/build-containers.yaml
@@ -0,0 +1,38 @@
1---
2# zuul.d/build-containers.yaml
3# Zuul layout for TripleO Build Containers jobs.
4
5- project-template:
6 name: tripleo-build-containers-jobs
7 check:
8 jobs:
9 - tripleo-build-containers-centos-7
10
11- job:
12 name: tripleo-build-containers-centos-7
13 parent: tripleo-ci-base-singlenode
14 pre-run:
15 - playbooks/tripleo-buildcontainers/pre.yaml
16 run: playbooks/tripleo-buildcontainers/run.yaml
17 post-run: playbooks/tripleo-buildcontainers/post.yaml
18 timeout: 7200
19 nodeset: single-centos-7-node
20 voting: false
21 required-projects:
22 - git.openstack.org/openstack/ansible-role-container-registry
23 - git.openstack.org/openstack/kolla
24 - git.openstack.org/openstack/python-tripleoclient
25 - git.openstack.org/openstack/requirements
26 - git.openstack.org/openstack/tripleo-common
27 - git.openstack.org/openstack/tripleo-repos
28 irrelevant-files:
29 - ^.*\.rst$
30 - ^releasenotes/.*$
31 files:
32 # tripleo-ci
33 - ^playbooks/tripleo-buildcontainers/.*$
34 # tripleo-common
35 - ^container-images/.*$
36 - ^tripleo_common/image/.*$
37 # python-tripleoclient
38 - ^tripleoclient/v1/container.*$
diff --git a/zuul.d/layout.yaml b/zuul.d/layout.yaml
index 72d122c..a4c07ec 100644
--- a/zuul.d/layout.yaml
+++ b/zuul.d/layout.yaml
@@ -11,6 +11,7 @@
11 - tripleo-multinode-experimental 11 - tripleo-multinode-experimental
12 - tripleo-undercloud-jobs 12 - tripleo-undercloud-jobs
13 - tripleo-multinode-branchful 13 - tripleo-multinode-branchful
14 - tripleo-build-containers-jobs
14 check: 15 check:
15 jobs: 16 jobs:
16 - openstack-tox-linters 17 - openstack-tox-linters