standalone: add support to build containers before deployment

* Create a new role, container-build, that will install
  a Docker registry in a container, running on port 5001
  and run tripleo_container_image_build to build TripleO images from
  scratch.
* Update the standalone deploy role so it can deploy TripleO from
  locally built container images and not from a remote registry.

Change-Id: Ic3cb165b80ef7bed11381a3925a7d6294162ed78
This commit is contained in:
Emilien Macchi
2020-05-19 21:31:28 -04:00
parent c3a2d81104
commit bbee06f544
8 changed files with 104 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
container-build
===============
This role will deploy a simple Docker registry v2 in a container,
build and push container images into that local registry.

View File

@@ -0,0 +1,20 @@
---
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
local_registry_ip: 127.0.0.1
local_registry_port: 5001
container_registry_namespace: tripleomaster
container_tag: current-tripleo

View File

@@ -0,0 +1,18 @@
---
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
dependencies:
- extras-common

View File

@@ -0,0 +1,44 @@
---
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Deploy the local registry
become: true
podman_container:
name: docker_registry
image: registry:2
net: host
env:
REGISTRY_HTTP_ADDR: "{{ local_registry_ip }}:{{ local_registry_port }}"
tags:
- skip_ansible_lint
- name: Build and push container images to the local registry
collections:
- tripleo.operator
include_role:
name: tripleo_container_image_build
vars:
tripleo_container_image_build_debug: true
tripleo_container_image_build_generate_scripts: true
tripleo_container_image_build_namespace: "{{ container_registry_namespace }}"
tripleo_container_image_build_tag: "{{ container_tag }}"
tripleo_container_image_build_push: true
tripleo_container_image_build_registry: "{{ local_registry_ip }}:{{ local_registry_port }}"
tripleo_container_image_build_volumes:
- "/etc/yum.repos.d:/etc/yum.repos.d:z"
- "/etc/pki/rpm-gpg:/etc/pki/rpm-gpg:z"
- "/opt/gating_repo:/opt/gating_repo:z"
tripleo_container_image_build_work_dir: "{{ working_dir }}/container-builds"

View File

@@ -40,7 +40,7 @@ docker_registry_host: docker.io
docker_registry_namespace: "tripleo{{ release }}"
docker_image_tag: current-tripleo
# docker prefix
docker_prep_prefix: "{{ ansible_distribution | lower }}-binary-"
docker_prep_prefix: "{{ job.build_container_images|default(false)|bool | ternary('openstack-', (ansible_distribution | lower) ~ '-binary-') }}"
# docker suffix
docker_prep_suffix: ""
docker_ceph_namespace: docker.io/ceph

View File

@@ -43,3 +43,6 @@ standalone_custom_env_files: []
standalone_container_ceph_updates: true
standalone_tripleo_deploy_debug_arg: false
local_registry_ip: 127.0.0.1
local_registry_port: 5001

View File

@@ -53,6 +53,15 @@
- ' DnsServers: (.*)'
when: enable_tls|default(false)|bool
- name: Build and push containers into a local registry
when:
- job.build_container_images|default(false)|bool
include_role:
name: container-build
vars:
container_registry_namespace: "{{ docker_registry_namespace }}"
container_tag: "{{ container_build_id }}"
- name: Run container prepare legacy
when:
- release in ['queens', 'rocky', 'stein', 'train']
@@ -183,6 +192,7 @@
- name: Add updates to container-prepare-parameters.yaml
when:
- standalone_container_prep_updates
- not job.build_container_images|default(false)|bool
block:
- name: Replace tag_from_label value
replace:

View File

@@ -12,6 +12,9 @@ parameter_defaults:
{% if standalone_container_prep_updates is defined and standalone_container_prep_updates %}
DockerInsecureRegistryAddress:
- {{ standalone_ip }}:8787
{% if job.build_container_images|default(false)|bool %}
- {{ local_registry_ip }}:{{ local_registry_port }}
{% endif %}
{% endif %}
{% if undercloud_docker_registry_mirror is defined and undercloud_docker_registry_mirror %}
DockerRegistryMirror: {{undercloud_docker_registry_mirror}}