From a5f3a2554623ebc71f24e2d1deff1f3a9e57a70d Mon Sep 17 00:00:00 2001 From: yatinkarel Date: Wed, 18 Dec 2019 10:38:30 +0530 Subject: [PATCH] Add option to build containers from package This patch adds an option to build containers using tripleoclient and kolla installed via package not from source keeping default installation via source. The initial usage of this feature would be to build containers from cloudsig RDO repos. The idea is to use same source(packages) for building containers and content of containers. Change-Id: Id7cde12a687a1e2a55717ba6fbc0bb78c80c51f6 --- roles/build-containers/defaults/main.yaml | 1 + roles/build-containers/tasks/main.yaml | 15 +++++---------- roles/build-containers/tasks/package_setup.yml | 10 ++++++++++ roles/build-containers/tasks/venv_setup.yml | 14 ++++++++++++++ roles/build-containers/templates/build.sh.j2 | 5 +++-- .../templates/kolla-build.conf.j2 | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 roles/build-containers/tasks/package_setup.yml create mode 100644 roles/build-containers/tasks/venv_setup.yml diff --git a/roles/build-containers/defaults/main.yaml b/roles/build-containers/defaults/main.yaml index a4325860b..19de7b939 100644 --- a/roles/build-containers/defaults/main.yaml +++ b/roles/build-containers/defaults/main.yaml @@ -13,6 +13,7 @@ kolla_base_pull: true use_buildah: false buildcontainers_override_repos: "" buildcontainers_rpm_setup_config: "http://172.17.0.1/delorean.repo,http://172.17.0.1/delorean-{{ ci_branch }}-testing.repo" +buildcontainers_venv: true openstack_repo_name: delorean container_cli_opt: "" # component_ci_containers used by component-ci jobs to build e.g. nova only diff --git a/roles/build-containers/tasks/main.yaml b/roles/build-containers/tasks/main.yaml index 305710342..5ce7344bd 100644 --- a/roles/build-containers/tasks/main.yaml +++ b/roles/build-containers/tasks/main.yaml @@ -77,16 +77,11 @@ 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" - - decorator - virtualenv: "{{ workspace }}/venv_build" - virtualenv_python: "{{ virtualenv_python[ansible_pkg_mgr] }}" - virtualenv_site_packages: true +- include_tasks: venv_setup.yml + when: buildcontainers_venv is defined and buildcontainers_venv + +- include_tasks: package_setup.yml + when: buildcontainers_venv is defined and not buildcontainers_venv # TODO(aschultz): make the kolla-build branch aware - name: Generate kolla-build.conf diff --git a/roles/build-containers/tasks/package_setup.yml b/roles/build-containers/tasks/package_setup.yml new file mode 100644 index 000000000..1cb392ad8 --- /dev/null +++ b/roles/build-containers/tasks/package_setup.yml @@ -0,0 +1,10 @@ +- name: install kolla and tripleoclient from package + become: true + package: + name: + - "openstack-kolla" + - "python*-tripleoclient" + +- name: set template override + set_fact: + kolla_override_path: "/usr/share/openstack-tripleo-common-containers/container-images/tripleo_kolla_template_overrides.j2" diff --git a/roles/build-containers/tasks/venv_setup.yml b/roles/build-containers/tasks/venv_setup.yml new file mode 100644 index 000000000..76e5ce7d7 --- /dev/null +++ b/roles/build-containers/tasks/venv_setup.yml @@ -0,0 +1,14 @@ +- name: Installation from source + pip: + name: + - "file://{{ openstack_git_root }}/kolla" + - "file://{{ openstack_git_root }}/tripleo-common" + - "file://{{ openstack_git_root }}/python-tripleoclient" + - decorator + virtualenv: "{{ workspace }}/venv_build" + virtualenv_python: "{{ virtualenv_python[ansible_pkg_mgr] }}" + virtualenv_site_packages: true + +- name: set template override + set_fact: + kolla_override_path: "{{ openstack_git_root }}/tripleo-common/container-images/tripleo_kolla_template_overrides.j2" diff --git a/roles/build-containers/templates/build.sh.j2 b/roles/build-containers/templates/build.sh.j2 index c47c7afa2..36b99a7b6 100644 --- a/roles/build-containers/templates/build.sh.j2 +++ b/roles/build-containers/templates/build.sh.j2 @@ -1,10 +1,11 @@ #!/bin/bash -eux +{% if buildcontainers_venv is defined and buildcontainers_venv %} source {{ workspace }}/venv_build/bin/activate +pip install -U decorator +{% endif %} TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common" TRIPLEO_CI_PATH="{{ openstack_git_root }}/tripleo-ci" -pip install -U decorator - ### list containers to build openstack overcloud container image build {{ container_config }}\ --kolla-config-file {{ workspace }}/kolla-build.conf \ diff --git a/roles/build-containers/templates/kolla-build.conf.j2 b/roles/build-containers/templates/kolla-build.conf.j2 index c7c51cd72..1808c6886 100644 --- a/roles/build-containers/templates/kolla-build.conf.j2 +++ b/roles/build-containers/templates/kolla-build.conf.j2 @@ -7,7 +7,7 @@ base_tag={{ kolla_base_tag }} type=binary registry={{ push_registry }} tag={{ version_hash }}{{ arch_tag }} -template_override={{ openstack_git_root }}/tripleo-common/container-images/tripleo_kolla_template_overrides.j2 +template_override={{ kolla_override_path }} # we use the repos off the main host as they will already have the correct mirror info in them rpm_setup_config="{{ buildcontainers_rpm_setup_config }}" push={{ push_containers }}