Modify the baremetal playbooks to use baseos undercloud

The baremetal deployment should follow OVB closely.
Add a baseos undercloud and build/fetch images
under the same conditions as OVB.

Story: https://tree.taiga.io/project/tripleo-ci-board/task/950
Change-Id: I67439f3497499f30801d185a298e01f112f01fbe
This commit is contained in:
Ronelle Landy 2019-03-28 15:44:13 -04:00
parent 600ed81b04
commit c86871ab45
5 changed files with 161 additions and 49 deletions

View File

@ -35,9 +35,17 @@
roles:
- environment/setup
- name: Check whether to build images
hosts: virthost
gather_facts: true
roles:
- check-to-build-or-not-to-build
- name: Setup undercloud and baremetal vms and networks in libvirt
hosts: virthost
gather_facts: true
vars:
baseos: true
roles:
- libvirt/setup
@ -51,31 +59,104 @@
roles:
- tripleo-inventory
- name: Setup the undercloud
hosts: undercloud
gather_facts: true
vars:
non_root_user_setup: false
roles:
- undercloud-setup
- name: Prepare the host for PXE forwarding
hosts: virthost
gather_facts: false
roles:
- baremetal-prep-virthost
- name: Set to_build on undercloud
hosts: undercloud
gather_facts: true
tasks:
- name: set_fact for to_build on undercloud
set_fact:
to_build: "{{ hostvars[groups['virthost'][0]]['to_build'] }}"
cacheable: true
- name: set_fact for image_cache_dir on undercloud
set_fact:
image_cache_dir: "{{ working_dir }}/images-cache"
cacheable: true
- name: set_fact for libguestfs_mode on undercloud
set_fact:
libguestfs_mode: false
cacheable: true
- name: Run DLRN gate role and install repo
hosts: undercloud
gather_facts: true
become: true
vars:
artg_compressed_gating_repo: "/home/{{ undercloud_user }}/gating_repo.tar.gz"
artg_repos_dir: "{{ repo_clone_dir|default('/opt/stack/new') }}"
ib_create_web_repo: "{{ hostvars[groups['virthost'][0]]['to_build'] }}"
tasks:
# Always build images even if running a periodic-* named job
# in a check pipeline for testing
- name: Always build images in periodic
set_fact:
to_build: true
cacheable: true
when: "'periodic' in zuul.job"
- include_role:
name: build-test-packages
vars:
artg_compressed_gating_repo: "/home/{{ undercloud_user }}/gating_repo.tar.gz"
artg_repos_dir: "{{ repo_clone_dir|default('/opt/stack/new') }}"
when: build_test_packages|default(false)|bool
- include_role:
name: install-built-repo
vars:
ib_create_web_repo: "{{ to_build|bool }}"
when: compressed_gating_repo is defined
- name: Get images for quickstart
hosts: undercloud
gather_facts: true
vars:
ib_repo_image_inject: "{{ not to_build|bool }}"
ib_repo_run_live: false
modify_image_vc_ram: 4096
modify_image_vc_cpu: 4
modify_image_vc_verbose: true
tasks:
- include_role:
name: fetch-images
when: not to_build|bool
- include_role:
name: repo-setup
vars:
repo_inject_image_path: "/home/{{ undercloud_user }}/overcloud-full.qcow2"
repo_run_live: false
when: not to_build|bool
- include_role:
name: repo-setup
vars:
repo_inject_image_path: "/home/{{ undercloud_user }}/ironic-python-agent.initramfs"
repo_run_live: false
initramfs_image: true
libguestfs_mode: false
when: not to_build|bool
- include_role:
name: install-built-repo
vars:
ib_repo_image_path: "/home/{{ undercloud_user }}/overcloud-full.qcow2"
when: compressed_gating_repo is defined
when: compressed_gating_repo is defined and not to_build|bool
- include_role:
name: install-built-repo
@ -83,4 +164,4 @@
ib_repo_image_path: "/home/{{ undercloud_user }}/ironic-python-agent.initramfs"
initramfs_image: true
libguestfs_mode: false
when: compressed_gating_repo is defined
when: compressed_gating_repo is defined and not to_build|bool

View File

@ -1,51 +1,6 @@
---
- name: Decide whether we need to build images
hosts: undercloud
vars:
# We always want to build images when we have changes in this
# list becuase these repos can affect the image building itelf
# This list is overridable via the "always_build_list" var if
# needed.
default_projects_need_build_list:
- diskimage-builder
- tripleo-image-elements
- tripleo-puppet-elements
- instack-undercloud
- python-tripleoclient
- tripleo-common
tasks:
# The next two tasks make the list of ZUUL_CHANGES look like our build list
# after we cleanup the extra stuff there, we can just intersect the two
# lists in order to match.
- name: Cleanup front of ZUUL_CHANGES
set_fact:
zuul_changes: "{{ lookup('env', 'ZUUL_CHANGES')|regex_replace('openstack/', '') }}"
- name: Cleanup end of ZUUL_CHANGES
set_fact:
zuul_changes: "{{ zuul_changes|regex_replace(':[a-z]*:refs/changes/\\d{2}/\\d+/\\d+','') }}"
- name: Split zuul_changes to a list
set_fact:
zuul_changes: "{{ zuul_changes.split('^') }}"
- name: compare zuul_changes list to our always_build_list
set_fact:
projects_need_build: "{{ zuul_changes | intersect(projects_need_build_list|default(default_projects_need_build_list)) }}"
- name: Default to using cached images
set_fact:
to_build: false
cacheable: true
- name: Build images when we have a change in the always build list
set_fact:
to_build: true
cacheable: true
when: projects_need_build != []
- name: Always build images in the periodic jobs
set_fact:
to_build: true
cacheable: true
when: lookup('env', 'PERIODIC')|default('0')|int == 1
- include_role:
name: check-to-build-or-not-to-build

View File

@ -0,0 +1,32 @@
check-to-build-or-not-to-build
==============================
An Ansible role created from the original playbook
to decide whether we need to build images. The role
was created to allow this functionality to run on
hosts other than the undercloud.
This output of this role is a to_build variable,
that is set to true or false to make image build and
other related workflow decisions in later steps.
Role Variables:
---------------
* ` default_projects_need_build_list` -- list of repos can affect the image building itelf
Example Usage
-------------
```yaml
---
- name: Decide whether we need to build images
hosts: undercloud
tasks:
- include_role:
name: check-to-build-or-not-to-build
```
License
-------
Apache

View File

@ -0,0 +1,8 @@
---
default_projects_need_build_list:
- diskimage-builder
- tripleo-image-elements
- tripleo-puppet-elements
- instack-undercloud
- python-tripleoclient
- tripleo-common

View File

@ -0,0 +1,36 @@
---
# The next two tasks make the list of ZUUL_CHANGES look like our build list
# after we cleanup the extra stuff there, we can just intersect the two
# lists in order to match.
- name: Cleanup front of ZUUL_CHANGES
set_fact:
zuul_changes: "{{ lookup('env', 'ZUUL_CHANGES')|regex_replace('openstack/', '') }}"
- name: Cleanup end of ZUUL_CHANGES
set_fact:
zuul_changes: "{{ zuul_changes|regex_replace(':[a-z]*:refs/changes/\\d{2}/\\d+/\\d+','') }}"
- name: Split zuul_changes to a list
set_fact:
zuul_changes: "{{ zuul_changes.split('^') }}"
- name: compare zuul_changes list to our always_build_list
set_fact:
projects_need_build: "{{ zuul_changes | intersect(projects_need_build_list|default(default_projects_need_build_list)) }}"
- name: Default to using cached images
set_fact:
to_build: false
cacheable: true
- name: Build images when we have a change in the always build list
set_fact:
to_build: true
cacheable: true
when: projects_need_build != []
- name: Always build images in the periodic jobs
set_fact:
to_build: true
cacheable: true
when: lookup('env', 'PERIODIC')|default('0')|int == 1