Merge "Convert tripleo-buildcontainers to a role"
This commit is contained in:
commit
a99695a3cd
|
@ -1,56 +1,6 @@
|
|||
- 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
|
||||
mkdir -p {{ workspace }}/logs/buildah-builds
|
||||
|
||||
mv *.conf {{ workspace }}/conf/
|
||||
mv {{ openstack_git_root }}/tripleo-common/container-images/overcloud_containers.yaml {{ workspace }}/conf/
|
||||
mv *.log {{ workspace }}/logs/
|
||||
mv *.sh {{ workspace }}/logs/
|
||||
mv /tmp/kolla-* {{ workspace }}/logs/buildah-builds/ || true
|
||||
rsync -var --no-links /var/log/ {{ workspace }}/logs/system/ || true
|
||||
rsync -var --no-links /etc/docker/ {{ workspace }}/etc/docker/ || true
|
||||
rsync -var --no-links /etc/containers/ {{ workspace }}/etc/containers/ || true
|
||||
rsync -var --no-links --include 'yum.repos.d/***' --include 'yum.conf' --include 'dnf/***' --exclude='*' /etc/ {{ workspace }}/etc/ || 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
|
||||
- name: Run build containers post tasks
|
||||
include_role:
|
||||
name: build-containers
|
||||
tasks_from: post
|
||||
|
|
|
@ -7,80 +7,7 @@
|
|||
- 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: 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: Reset connection because of group changes for current user
|
||||
meta: reset_connection
|
||||
|
||||
- name: Prepare Buildah
|
||||
become: true
|
||||
when: use_buildah | default(false) | bool
|
||||
block:
|
||||
- name: Install Buildah
|
||||
package:
|
||||
name: buildah
|
||||
state: present
|
||||
|
||||
- name: Configure insecure registry
|
||||
ini_file:
|
||||
path: /etc/containers/registries.conf
|
||||
section: 'registries.insecure'
|
||||
option: registries
|
||||
value:
|
||||
- localhost:8787
|
||||
|
||||
- name: Setup repo web service
|
||||
become: true
|
||||
block:
|
||||
- name: Install apache
|
||||
package:
|
||||
name: httpd
|
||||
state: present
|
||||
|
||||
- name: Start apache
|
||||
service:
|
||||
name: httpd
|
||||
state: started
|
||||
|
||||
- name: Fetch delorean repos
|
||||
shell: |
|
||||
set -ex
|
||||
cp /etc/yum.repos.d/delorean* /var/www/html/
|
||||
|
||||
- name: Add http iptables rules from containers
|
||||
command: iptables -I openstack-INPUT 1 -p tcp --dport 80 -s 172.17.0.0/16 -j ACCEPT
|
||||
become: true
|
||||
- name: Run build containers pre tasks
|
||||
include_role:
|
||||
name: build-containers
|
||||
tasks_from: pre
|
||||
|
|
|
@ -1,97 +1,6 @@
|
|||
- hosts: all
|
||||
name: TripleO container image building job
|
||||
tasks:
|
||||
- name: Include common vars
|
||||
include_vars:
|
||||
file: "common.yaml"
|
||||
|
||||
- name: Set branch for building containers check jobs
|
||||
set_fact:
|
||||
ci_branch: "{{ zuul.branch | replace('stable/','') }}"
|
||||
when: zuul is defined
|
||||
|
||||
- name: Set branch for building containers branchless
|
||||
set_fact:
|
||||
ci_branch: "{{ branch_override | replace('stable/','') }}"
|
||||
when: branch_override is defined
|
||||
|
||||
- name: Set branch for building containers periodic
|
||||
set_fact:
|
||||
ci_branch: "{{ release }}"
|
||||
when: release is defined
|
||||
|
||||
- name: Set facts for kolla-build.conf
|
||||
set_fact:
|
||||
push_registry: "{{ push_registry | default('127.0.0.1:8787') }}"
|
||||
push_containers: "{{ push_containers | default(false) | bool }}"
|
||||
container_config: ""
|
||||
|
||||
- name: Get contents of delorean repo baseurl for the version hash
|
||||
become: true
|
||||
shell: >
|
||||
set -o pipefail &&
|
||||
cat /etc/yum.repos.d/delorean.repo |awk -F= '/baseurl/ {print $2}'
|
||||
register: baseurl
|
||||
|
||||
- name: Set version_hash fact
|
||||
set_fact:
|
||||
version_hash: "{{ baseurl.stdout.split('/')[-1] }}"
|
||||
|
||||
- name: grab kolla patch if needed
|
||||
when: ansible_pkg_mgr == "dnf"
|
||||
shell: |
|
||||
set -euxo pipefail
|
||||
git config --global user.email "zuul@openstack.org"
|
||||
git config --global user.name "Zuul"
|
||||
git remote add upstream https://git.openstack.org/openstack/kolla
|
||||
git ls-remote https://git.openstack.org/openstack/kolla | \
|
||||
grep -E refs/changes/[[:digit:]]+/{{ kolla_f28_patch }}/ | \
|
||||
awk '{print $2}' | \
|
||||
sort -t / -k 5 -g -r | \
|
||||
head -1 | \
|
||||
xargs -I{} git fetch https://git.openstack.org/openstack/kolla {} && \
|
||||
git checkout -b f28 FETCH_HEAD && \
|
||||
git pull --rebase upstream master
|
||||
|
||||
args:
|
||||
chdir: "{{ openstack_git_root }}/kolla"
|
||||
warn: false
|
||||
register: result
|
||||
changed_when: "'nothing to commit, working directory clean' not in result.stdout_lines"
|
||||
|
||||
- name: pip install kolla
|
||||
pip:
|
||||
name:
|
||||
- "file://{{ openstack_git_root }}/kolla"
|
||||
- "file://{{ openstack_git_root }}/tripleo-common"
|
||||
- "file://{{ openstack_git_root }}/python-tripleoclient"
|
||||
virtualenv: "{{ workspace }}/venv"
|
||||
virtualenv_python: "{{ virtualenv_python[ansible_pkg_mgr] }}"
|
||||
virtualenv_site_packages: true
|
||||
|
||||
# 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: Set config-file
|
||||
set_fact:
|
||||
container_config: "--config-file $TRIPLEO_COMMON_PATH/container-images/overcloud_containers.yaml"
|
||||
when: ci_branch in ['pike', 'queens', 'rocky']
|
||||
|
||||
|
||||
- name: Generate building script
|
||||
template:
|
||||
src: templates/build.sh.j2
|
||||
dest: "{{ workspace }}/build_containers.sh"
|
||||
mode: 0777
|
||||
force: yes
|
||||
|
||||
- name: Run image build
|
||||
args:
|
||||
chdir: '{{ workspace }}'
|
||||
shell: set -o pipefail && bash build_containers.sh 2>&1 {{ timestamper_cmd }} > {{ workspace }}/build.log
|
||||
|
||||
- name: Run build containers tasks
|
||||
include_role:
|
||||
name: build-containers
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
- name: Include common vars
|
||||
include_vars:
|
||||
dir: "vars"
|
||||
|
||||
- name: Set branch for building containers check jobs
|
||||
set_fact:
|
||||
ci_branch: "{{ zuul.branch | replace('stable/','') }}"
|
||||
when: zuul is defined
|
||||
|
||||
- name: Set branch for building containers branchless
|
||||
set_fact:
|
||||
ci_branch: "{{ branch_override | replace('stable/','') }}"
|
||||
when: branch_override is defined
|
||||
|
||||
- name: Set branch for building containers periodic
|
||||
set_fact:
|
||||
ci_branch: "{{ release }}"
|
||||
when: release is defined
|
||||
|
||||
- name: Set facts for kolla-build.conf
|
||||
set_fact:
|
||||
push_registry: "{{ push_registry | default('127.0.0.1:8787') }}"
|
||||
push_containers: "{{ push_containers | default(false) | bool }}"
|
||||
container_config: ""
|
||||
|
||||
- name: Get contents of delorean repo baseurl for the version hash
|
||||
become: true
|
||||
shell: >
|
||||
set -o pipefail &&
|
||||
cat /etc/yum.repos.d/delorean.repo |awk -F= '/baseurl/ {print $2}'
|
||||
register: baseurl
|
||||
|
||||
- name: Set version_hash fact
|
||||
set_fact:
|
||||
version_hash: "{{ baseurl.stdout.split('/')[-1] }}"
|
||||
|
||||
- name: grab kolla patch if needed
|
||||
when: ansible_pkg_mgr == "dnf"
|
||||
shell: |
|
||||
set -euxo pipefail
|
||||
git config --global user.email "zuul@openstack.org"
|
||||
git config --global user.name "Zuul"
|
||||
git remote add upstream https://git.openstack.org/openstack/kolla
|
||||
git ls-remote https://git.openstack.org/openstack/kolla | \
|
||||
grep -E refs/changes/[[:digit:]]+/{{ kolla_f28_patch }}/ | \
|
||||
awk '{print $2}' | \
|
||||
sort -t / -k 5 -g -r | \
|
||||
head -1 | \
|
||||
xargs -I{} git fetch https://git.openstack.org/openstack/kolla {} && \
|
||||
git checkout -b f28 FETCH_HEAD && \
|
||||
git pull --rebase upstream master
|
||||
|
||||
args:
|
||||
chdir: "{{ openstack_git_root }}/kolla"
|
||||
warn: false
|
||||
register: result
|
||||
changed_when: "'nothing to commit, working directory clean' not in result.stdout_lines"
|
||||
|
||||
- name: pip install kolla
|
||||
pip:
|
||||
name:
|
||||
- "file://{{ openstack_git_root }}/kolla"
|
||||
- "file://{{ openstack_git_root }}/tripleo-common"
|
||||
- "file://{{ openstack_git_root }}/python-tripleoclient"
|
||||
virtualenv: "{{ workspace }}/venv_build"
|
||||
virtualenv_python: "{{ virtualenv_python[ansible_pkg_mgr] }}"
|
||||
virtualenv_site_packages: true
|
||||
|
||||
# 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: Set config-file
|
||||
set_fact:
|
||||
container_config: "--config-file $TRIPLEO_COMMON_PATH/container-images/overcloud_containers.yaml"
|
||||
when: ci_branch in ['pike', 'queens', 'rocky']
|
||||
|
||||
|
||||
- name: Generate building script
|
||||
template:
|
||||
src: templates/build.sh.j2
|
||||
dest: "{{ workspace }}/build_containers.sh"
|
||||
mode: 0777
|
||||
force: yes
|
||||
|
||||
- name: Run image build
|
||||
args:
|
||||
chdir: '{{ workspace }}'
|
||||
shell: set -o pipefail && bash build_containers.sh 2>&1 {{ timestamper_cmd }} > {{ workspace }}/build.log
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
- name: Include common vars
|
||||
include_vars:
|
||||
dir: "vars"
|
||||
|
||||
- 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
|
||||
mkdir -p {{ workspace }}/logs/buildah-builds
|
||||
|
||||
mv *.conf {{ workspace }}/conf/
|
||||
mv {{ openstack_git_root }}/tripleo-common/container-images/overcloud_containers.yaml {{ workspace }}/conf/
|
||||
mv *.log {{ workspace }}/logs/
|
||||
mv *.sh {{ workspace }}/logs/
|
||||
mv /tmp/kolla-* {{ workspace }}/logs/buildah-builds/ || true
|
||||
rsync -var --no-links /var/log/ {{ workspace }}/logs/system/ || true
|
||||
rsync -var --no-links /etc/docker/ {{ workspace }}/etc/docker/ || true
|
||||
rsync -var --no-links /etc/containers/ {{ workspace }}/etc/containers/ || true
|
||||
rsync -var --no-links --include 'yum.repos.d/***' --include 'yum.conf' --include 'dnf/***' --exclude='*' /etc/ {{ workspace }}/etc/ || 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
|
|
@ -0,0 +1,89 @@
|
|||
---
|
||||
- name: set tripleo repos
|
||||
include_role:
|
||||
name: tripleo-repos
|
||||
vars:
|
||||
override_repos: "{{ buildcontainers_override_repos | default('') }}"
|
||||
tripleo_repos_repository: "{{ ansible_user_dir }}/{{ zuul.projects['git.openstack.org/openstack/tripleo-repos'].src_dir }}"
|
||||
- name: install deps via bindep
|
||||
include_role:
|
||||
name: bindep
|
||||
vars:
|
||||
bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['git.openstack.org/openstack/python-tripleoclient'].src_dir }}"
|
||||
- name: Include common vars
|
||||
include_vars:
|
||||
dir: "vars"
|
||||
|
||||
- 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: Reset connection because of group changes for current user
|
||||
meta: reset_connection
|
||||
|
||||
- name: Prepare Buildah
|
||||
become: true
|
||||
when: use_buildah | default(false) | bool
|
||||
block:
|
||||
- name: Install Buildah
|
||||
package:
|
||||
name: buildah
|
||||
state: present
|
||||
|
||||
- name: Configure insecure registry
|
||||
ini_file:
|
||||
path: /etc/containers/registries.conf
|
||||
section: 'registries.insecure'
|
||||
option: registries
|
||||
value:
|
||||
- localhost:8787
|
||||
|
||||
- name: Setup repo web service
|
||||
become: true
|
||||
block:
|
||||
- name: Install apache
|
||||
package:
|
||||
name: httpd
|
||||
state: present
|
||||
|
||||
- name: Start apache
|
||||
service:
|
||||
name: httpd
|
||||
state: started
|
||||
|
||||
- name: Fetch delorean repos
|
||||
shell: |
|
||||
set -ex
|
||||
cp /etc/yum.repos.d/delorean* /var/www/html/
|
||||
|
||||
- name: Add http iptables rules from containers
|
||||
command: iptables -I openstack-INPUT 1 -p tcp --dport 80 -s 172.17.0.0/16 -j ACCEPT
|
||||
become: true
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash -eux
|
||||
source {{ workspace }}/venv/bin/activate
|
||||
source {{ workspace }}/venv_build/bin/activate
|
||||
TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common"
|
||||
|
||||
openstack overcloud container image build {{ container_config }}\
|
|
@ -199,6 +199,7 @@
|
|||
- kolla.*$
|
||||
# tripleo-ci
|
||||
- ^(playbooks|roles)/tripleo-buildcontainers/.*$
|
||||
- ^roles/build-containers/.*$
|
||||
- ^(playbooks|roles)/tripleo-repos/.*$
|
||||
- ^zuul.d/build-containers.yaml$
|
||||
- ^zuul.d/base.yaml$
|
||||
|
|
Loading…
Reference in New Issue