From 070621a45df11fd2487ddc38f715c1075524ee93 Mon Sep 17 00:00:00 2001 From: Maksim Malchuk Date: Thu, 9 Jun 2022 22:54:07 +0300 Subject: [PATCH] Allow to use own repos.y[a]ml file to build containers Followup the I0b07da22fea27e0ff4e90aaad19e50d84ff9a121 from Kolla. This change allow to use own repos.y[a]ml file to build containers. Multiple Environments supported. Change-Id: I0d7ab0d8ff5b16ac5de8e50e63400bd455996555 Signed-off-by: Maksim Malchuk --- ansible/roles/kolla-build/tasks/main.yml | 26 +++++++++++++++++++ .../templates/kolla/kolla-build.conf | 4 +++ doc/source/multiple-environments.rst | 1 + ...-provided-repos-yaml-07e1f872225059a6.yaml | 7 +++++ 4 files changed, 38 insertions(+) create mode 100644 releasenotes/notes/user-provided-repos-yaml-07e1f872225059a6.yaml diff --git a/ansible/roles/kolla-build/tasks/main.yml b/ansible/roles/kolla-build/tasks/main.yml index 82d5a2d43..c9c570bf8 100644 --- a/ansible/roles/kolla-build/tasks/main.yml +++ b/ansible/roles/kolla-build/tasks/main.yml @@ -1,4 +1,30 @@ --- +- name: Set facts for repos.y[a]ml + set_fact: + repos_yaml_dest: "{{ kolla_build_config_path }}/repos.yml" + repos_yaml_sources: "{{ kolla_build_config_paths | product(['/kolla/repos.yaml', '/kolla/repos.yml']) | map('join') | unique | list }}" + +- name: Check for the presence of any custom repos.y[a]ml file + stat: + path: "{{ item }}" + get_md5: False + get_checksum: False + mime: False + with_items: "{{ repos_yaml_sources }}" + register: repos_yaml_stat + +- name: Set kolla_build_repos_yaml_path if any custom repos.y[a]ml file exists + set_fact: + kolla_build_repos_yaml_path: "{{ repos_yaml_dest }}" + when: repos_yaml_stat.results | map(attribute='stat.exists') | select | length > 0 + +- name: Ensure the Kolla repos.yaml configuration file exists + merge_yaml: + sources: "{{ repos_yaml_sources }}" + dest: "{{ repos_yaml_dest }}" + mode: 0644 + when: kolla_build_repos_yaml_path is defined + - name: Ensure the Kolla build configuration file exists merge_configs: sources: "{{ kolla_build_config_paths | product(['/kolla/kolla-build.conf']) | map('join') | list }}" diff --git a/ansible/roles/kolla-build/templates/kolla/kolla-build.conf b/ansible/roles/kolla-build/templates/kolla/kolla-build.conf index 700269ec8..762f86c41 100644 --- a/ansible/roles/kolla-build/templates/kolla/kolla-build.conf +++ b/ansible/roles/kolla-build/templates/kolla/kolla-build.conf @@ -16,6 +16,10 @@ network_mode=host # Docker image tag to apply. tag={{ kolla_tag }} +{% if kolla_build_repos_yaml_path is defined %} +# Path to a file containing repos overrides. +repos_yaml={{ kolla_build_repos_yaml_path }} +{% endif %} # Path to a file containing template overrides. template_override={{ kolla_build_config_path }}/template-override.j2 diff --git a/doc/source/multiple-environments.rst b/doc/source/multiple-environments.rst index ecf89dab9..fa086eb60 100644 --- a/doc/source/multiple-environments.rst +++ b/doc/source/multiple-environments.rst @@ -163,6 +163,7 @@ environment-specific and shared configuration file content: * ``kolla/config/bifrost/servers.yml`` * ``kolla/globals.yml`` * ``kolla/kolla-build.conf`` +* ``kolla/repos.yml`` or ``kolla/repos.yaml`` Options in the environment-specific files take precedence over those in the shared files. diff --git a/releasenotes/notes/user-provided-repos-yaml-07e1f872225059a6.yaml b/releasenotes/notes/user-provided-repos-yaml-07e1f872225059a6.yaml new file mode 100644 index 000000000..af0b19e94 --- /dev/null +++ b/releasenotes/notes/user-provided-repos-yaml-07e1f872225059a6.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Since Kolla containers can built with user provided ``repos.yaml`` Kayobe + can override the file with their own content. The override files can be + ``${KAYOBE_CONFIG_PATH}/kolla/repos.yaml`` (default Kolla filename) or + ``${KAYOBE_CONFIG_PATH}/kolla/repos.yml``. Multiple Environments supported.