Enable quickstart to work with clean base OS images.

Enables a deployment using clean base os RHEL/CentOS images.
A clean base os image would be the standard cloud images for
CentOS and RHEL.  The normal path for quickstart is to use
a prebuilt undercloud image with all the packages preinstalled.

* undercloud_image_url points to a base os image and includes
a md5sum for that image in the config.

* update fetch.yml to handle base os images

* create a baseos convert image script in convert-image that
does not install openstack packages.

* create a new variable call baseos_as_undercloud variable

Change-Id: Ia2394943c12f3bc6ac29235ca741e0eb2dd17db3
This commit is contained in:
Wes Hayutin 2017-03-07 15:05:30 -05:00
parent 8dc6d4c6df
commit 57443434af
10 changed files with 152 additions and 10 deletions

View File

@ -0,0 +1,53 @@
release: newton
undercloud_image_url: https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1701.qcow2
overcloud_image_url: http://buildlogs.centos.org/centos/7/cloud/x86_64/tripleo_images/newton/delorean/overcloud-full.tar
ipa_image_url: http://buildlogs.centos.org/centos/7/cloud/x86_64/tripleo_images/newton/delorean/ironic-python-agent.tar
images:
- name: centos
url: "{{ undercloud_image_url }}"
type: qcow2
md5sum: "bc62ad193b085680952edfa7face0f23 *CentOS-7-x86_64-GenericCloud-1701.qcow2"
- name: overcloud-full
url: "{{ overcloud_image_url }}"
type: tar
- name: ipa_images
url: "{{ ipa_image_url }}"
type: tar
baseos_as_undercloud: true
undercloud_setup: true
use_external_images: true
inject_images:
- "ironic-python-agent.initramfs"
- "ironic-python-agent.vmlinuz"
- "ironic-python-agent.kernel"
- "overcloud-full.qcow2"
- "overcloud-full.initrd"
- "overcloud-full.vmlinuz"
repos:
- type: generic
reponame: delorean
filename: delorean.repo
baseurl: http://buildlogs.centos.org/centos/7/cloud/x86_64/rdo-trunk-newton-tested/
hash_url: http://buildlogs.centos.org/centos/7/cloud/x86_64/rdo-trunk-newton-tested/delorean.repo
priority: 20
- type: file
filename: delorean-deps.repo
down_url: http://trunk.rdoproject.org/centos7-newton/delorean-deps.repo
- type: package
pkg_name: centos-release-ceph-jewel
custom_cmd: 'sudo yum install -y --enablerepo=extras'
repo_cmd_after: |
sudo yum-config-manager --save --setopt centos-ceph-jewel.gpgcheck=0
sudo yum repolist
sudo yum update -y
ovb_setup_connectivity: false
non_root_user_setup: true
package_installs: true
hostname_correction: true

View File

@ -31,6 +31,12 @@
tags:
- provision
# Allow the user to optionally perform a yum repo setup
# Default is set to false as the quickstart images will provide the
# correct yum repos.
- include: repo-setup.yml
when: virthost_repo_setup|default(false)
- name: Check if the target virthost distro is supported (RHEL or CentOS)
hosts: virthost
roles:

View File

@ -2,6 +2,15 @@
- include: quickstart.yml
# setup for the undercloud
- name: Setup the undercloud
hosts: undercloud
gather_facts: no
vars:
ansible_user: root
roles:
- { role: undercloud-setup, when: undercloud_setup|bool }
# Deploy the undercloud
- name: Deploy the undercloud
hosts: undercloud
@ -80,7 +89,8 @@
# overcloud_deploy_result = ["failed", "passed"]
- name: did the deployment pass or fail?
debug: var=overcloud_deploy_result
debug:
var: overcloud_deploy_result
failed_when: overcloud_deploy_result == "failed"
# Validate the deployment

6
playbooks/repo-setup.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: Setup yum repositories on the virthost
hosts: virthost
gather_facts: yes
roles:
- repo-setup

View File

@ -24,6 +24,17 @@ image_fetch_dir: "{{ working_dir}}"
# the fly. The default is to use a pre-built undercloud.qcow2.
overcloud_as_undercloud: false
# This determines whether or not to treat the undercloud.qcow2 as a
# stock CentOS or RHEL image. The default is a pre-built undercloud.qcow2
baseos_as_undercloud: false
# When a base os image is used in lieu of a quickstart prepared image
# additional setup steps are required for the undercloud install.
undercloud_setup: false
# Set selinux, by default RDO builds are always set to selinux permissive
selinux_enforcing: false
# These defaults are used if there are no flavor-specific
# overrides configured.
default_disk: 50

View File

@ -1,3 +1,4 @@
# By default do image conversion in the global working_dir
convert_image_working_dir: "{{ working_dir }}"
convert_image_template: convert_image.sh.j2

View File

@ -1,6 +1,6 @@
- name: generate convert script
template:
src: convert_image.sh.j2
src: "{{ convert_image_template }}"
dest: "{{ convert_image_working_dir}}/convert_image.sh"
- name: copy overcloud-full.qcow2 to undercloud.qcow2
@ -8,6 +8,7 @@
cp {{ convert_image_working_dir}}/overcloud-full.qcow2
{{ convert_image_working_dir}}/undercloud.qcow2
changed_when: true
when: overcloud_as_undercloud|bool
# Resize the undercloud image using qemu-img resize
- name: Resize the undercloud image using qemu-image resize

View File

@ -13,6 +13,8 @@ else
exit 1
fi
{% if not undercloud_setup %}
yum update -y
yum remove -y cloud-init python-django-horizon openstack-dashboard
@ -27,6 +29,8 @@ python-heat-tests python-ironic-tests python-keystone-tests python-manila-tests
python-mistral-tests python-neutron-tests python-sahara-tests python-zaqar-tests \
|| /bin/true
{% endif %}
useradd {{ undercloud_user }}
echo "{{ undercloud_user }} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/{{ undercloud_user }}
chmod 0440 /etc/sudoers.d/{{ undercloud_user }}
@ -46,5 +50,9 @@ chmod 600 /swapfile
# Enable it on start
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
{% if not selinux_enforcing %}
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
{% endif %}

View File

@ -1,3 +1,7 @@
- name: image name
debug:
msg: "checking for image {{ image.name }}"
# Set some convenience variables here to avoid boilerplate code
# elsewhere in this file. These are all set unconditionally to avoid
# any cruft leftover from a previous call to this file.
@ -28,8 +32,34 @@
image_cache_path: "{{ _latest }}"
when: latest_exists|success and _force_cached_image
# The md5sum for base OS images are not hosted, they are defined in a configuration file.
# Handle base os images slightly differently
- when: image.md5sum is defined
block:
# Get the expected checksum from settings vs. pulling the md5sum.
- name: Get image expected checksum for base OS images
set_fact:
md5_expected: "{{ image.md5sum.split()[0] }}"
- name: Set path to cached image
set_fact:
image_cache_path: "{{ image_cache_dir }}/{{ md5_expected }}.{{ image.type }}"
# See if a matching image exists locally.
- name: Check for base OS image in cache
command: >
test -f {{ image_cache_path }}
args:
chdir: "{{ image_cache_dir }}"
ignore_errors: true
register: base_image_exists
changed_when: false
# Otherwise, check if there's a new image available.
- when: not _force_cached_image or latest_exists|failed
- when:
- image.md5sum is not defined
- not _force_cached_image or latest_exists|failed
block:
# Get the expected checksum for the remote image.
@ -38,9 +68,13 @@
curl -sfL {{ image.url }}.md5
register: md5_expected
- name: sanitize the md5sum
set_fact:
md5_expected: "{{ md5_expected.stdout.split()[0] }}"
- name: Set path to cached image [upstream]
set_fact:
image_cache_path: "{{ image_cache_dir }}/{{ md5_expected.stdout.split()[0] }}.{{ image.type }}"
image_cache_path: "{{ image_cache_dir }}/{{ md5_expected }}.{{ image.type }}"
# See if a matching image exists locally.
- name: Check for image in cache
@ -53,7 +87,10 @@
changed_when: false
# Looks like we're going to have to download the image after all.
- when: image_exists is defined and image_exists|failed
# Note.. image_exists and base_image_exists are required variables because
# even unused variables will overwrite each other.
- when: image_exists is defined and (image_exists|failed or base_image_exists|failed)
block:
# This task will download the image. We're using `curl` here
@ -79,14 +116,17 @@
chdir: "{{ image_cache_dir }}"
register: md5_actual
- name: sanitize the md5sum for the downloaded image
set_fact:
md5_actual: "{{ md5_actual.stdout.split()[0] }}"
# Verify that what we have is what we wanted.
- name: Verify image checksum
fail:
msg: image checksum does not match
when: >
image_exists|failed and (
md5_expected.stdout.split()[0] !=
md5_actual.stdout.split()[0])
image_exists|failed and
(md5_expected != md5_actual)
- name: Cache image by checksum
command: >
@ -127,7 +167,13 @@
- name: Get qcow2 image from cache
command: >
cp {{ image_cache_path }} {{ image_fetch_dir }}/{{ image.name }}.{{ image.type }}
when: image.type == "qcow2"
when: image.type == "qcow2" and image.md5sum is not defined
# Same as the above just copy the base os image to the fetch_dir as undercloud
- name: Get base OS qcow2 image from cache
command: >
cp {{ image_cache_path }} {{ image_fetch_dir }}/undercloud.{{ image.type }}
when: image.type == "qcow2" and image.md5sum is defined
- name: Get tar images from cache
unarchive:

View File

@ -46,7 +46,7 @@
# Converts an overcloud-full.qcow2 into a undercloud.qcow2
- include: convert_image.yml
when: overcloud_as_undercloud|bool
when: overcloud_as_undercloud|bool or baseos_as_undercloud|bool
# Update images after we have converted the overcloud-full to an
# undercloud image when using devmode. This also clones tripleo-ci