|
| 1 | +--- |
| 2 | +- name: Bootstrap step |
| 3 | + ansible.builtin.import_playbook: >- |
| 4 | + {{ |
| 5 | + [ |
| 6 | + ansible_user_dir, |
| 7 | + zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir, |
| 8 | + 'playbooks', |
| 9 | + '01-bootstrap.yml' |
| 10 | + ] | ansible.builtin.path_join |
| 11 | + }} |
| 12 | +
|
| 13 | +- name: Run ci/playbooks/meta_content_provider/meta_content_provider.yml |
| 14 | + hosts: "{{ cifmw_target_host | default('localhost') }}" |
| 15 | + gather_facts: true |
| 16 | + tasks: |
| 17 | + - name: Install necessary dependencies |
| 18 | + ansible.builtin.include_role: |
| 19 | + name: 'install_yamls_makes' |
| 20 | + tasks_from: 'make_download_tools' |
| 21 | + |
| 22 | + - name: Build OpenStack Services Packages using DLRN |
| 23 | + vars: |
| 24 | + cifmw_bop_yum_repos_dir: "{{ cifmw_build_containers_repo_dir }}" |
| 25 | + cifmw_bop_gating_repo_dest: "{{ cifmw_build_containers_repo_dir }}" |
| 26 | + ansible.builtin.include_role: |
| 27 | + name: build_openstack_packages |
| 28 | + |
| 29 | + - name: Check for gating repo |
| 30 | + ansible.builtin.stat: |
| 31 | + path: "{{ cifmw_build_containers_repo_dir }}/gating.repo" |
| 32 | + register: _gating_repo |
| 33 | + |
| 34 | + - name: Deploy content provider registry |
| 35 | + ansible.builtin.include_role: |
| 36 | + name: registry_deploy |
| 37 | + |
| 38 | + - name: Construct project change list |
| 39 | + ansible.builtin.set_fact: |
| 40 | + zuul_change_list: "{{ zuul_change_list | default([]) + [item.project.short_name] }}" |
| 41 | + cacheable: true |
| 42 | + with_items: "{{ zuul['items'] }}" |
| 43 | + when: |
| 44 | + - zuul is defined |
| 45 | + - "'change_url' in item" |
| 46 | + |
| 47 | + - name: Build openstack services container when gating repo exists |
| 48 | + when: |
| 49 | + - "'os-net-config' not in zuul_change_list" |
| 50 | + - _gating_repo.stat.exists |
| 51 | + block: |
| 52 | + - name: Build OpenStack services containers |
| 53 | + ansible.builtin.include_role: |
| 54 | + name: build_containers |
| 55 | + |
| 56 | + - name: Return registry_url |
| 57 | + ansible.builtin.set_fact: |
| 58 | + content_provider_os_registry_url: "{{ cifmw_build_containers_push_registry }}/{{ cifmw_build_containers_registry_namespace }}" |
| 59 | + |
| 60 | + - name: Build EDPM Images |
| 61 | + when: "'edpm-image-builder' in zuul_change_list" |
| 62 | + block: |
| 63 | + - name: Get latest commit when no PR is provided |
| 64 | + ansible.builtin.command: # noqa: command-instead-of-module |
| 65 | + cmd: git show-ref --head --hash head |
| 66 | + args: |
| 67 | + chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/edpm-image-builder" |
| 68 | + register: git_head_out |
| 69 | + |
| 70 | + - name: Set pr_sha to be used as image tag |
| 71 | + ansible.builtin.set_fact: |
| 72 | + pr_sha: "{{ git_head_out.stdout | trim }}" |
| 73 | + cacheable: true |
| 74 | + |
| 75 | + - name: Build edpm and ipa images |
| 76 | + ansible.builtin.include_role: |
| 77 | + name: edpm_build_images |
| 78 | + vars: |
| 79 | + cifmw_edpm_build_images_tag: "{{ pr_sha }}" |
| 80 | + |
| 81 | + - name: Push edpm-hardened-uefi image to registry |
| 82 | + containers.podman.podman_image: |
| 83 | + name: "{{ item }}" |
| 84 | + push_args: |
| 85 | + dest: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/{{ item }}:{{ pr_sha }}" |
| 86 | + tag: "{{ pr_sha }}" |
| 87 | + push: true |
| 88 | + loop: |
| 89 | + - edpm-hardened-uefi |
| 90 | + - ironic-python-agent |
| 91 | + |
| 92 | + - name: Set build images output |
| 93 | + ansible.builtin.set_fact: |
| 94 | + cifmw_build_images_output: |
| 95 | + images: |
| 96 | + edpm-hardened-uefi: |
| 97 | + image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/edpm-hardened-uefi:{{ pr_sha }}" |
| 98 | + ironic-python-agent: |
| 99 | + image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/ironic-python-agent:{{ pr_sha }}" |
| 100 | + cacheable: true |
| 101 | + |
| 102 | + - name: Set build images output when EDPM image is not built |
| 103 | + when: "'edpm-image-builder' not in zuul_change_list" |
| 104 | + ansible.builtin.set_fact: |
| 105 | + cifmw_build_images_output: {} |
| 106 | + |
| 107 | + - name: Set var for cifmw_operator_build_operators var |
| 108 | + # It handles the case of setting image_base for |
| 109 | + # openstack-ansibleee-operator and openstack-operator project |
| 110 | + # for openstack-ansibleee-operator, it will return openstack-ansibleee |
| 111 | + # and for openstack-operator, openstack will be returned |
| 112 | + when: |
| 113 | + - zuul is defined |
| 114 | + - "'project' in zuul" |
| 115 | + - "'short_name' in zuul.project" |
| 116 | + - "'operator' in zuul.project.short_name" |
| 117 | + ansible.builtin.set_fact: |
| 118 | + cifmw_operator_build_operators: |
| 119 | + - name: "openstack-operator" |
| 120 | + src: "~/src/github.com/{{ cifmw_operator_build_org }}/openstack-operator" |
| 121 | + image_base: >- |
| 122 | + {{ zuul.project.short_name | split('-') | reject('search','operator') | join('-') }} |
| 123 | +
|
| 124 | + - name: Build Operators |
| 125 | + ansible.builtin.include_role: |
| 126 | + name: operator_build |
| 127 | + |
| 128 | + - name: Get the containers list from container registry |
| 129 | + ansible.builtin.uri: |
| 130 | + url: "http://{{ cifmw_rp_registry_ip }}:5001/v2/_catalog" |
| 131 | + return_content: true |
| 132 | + register: cp_imgs |
| 133 | + |
| 134 | + - name: Add the container list to file |
| 135 | + ansible.builtin.copy: |
| 136 | + content: "{{ cp_imgs.content }}" |
| 137 | + dest: "{{ ansible_user_dir }}/local_registry.log" |
| 138 | + mode: "0644" |
| 139 | + |
| 140 | +- name: Run log related tasks |
| 141 | + ansible.builtin.import_playbook: >- |
| 142 | + {{ |
| 143 | + [ |
| 144 | + ansible_user_dir, |
| 145 | + zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir, |
| 146 | + 'playbooks', |
| 147 | + '99-logs.yml' |
| 148 | + ] | ansible.builtin.path_join |
| 149 | + }} |
0 commit comments