Modify the way override works
Now the generated app_helm_override_file and the list of
helm overrides is separate.
The former is to contain things like user provided overrides,
the latter is the list of absolute paths to preexisting helm value files.
The playbook joins all that into a final list of override files that is then
passed to helm.
Change-Id: I8b8ded38b39aa9a75e55fc63fa0e11b986556cb8
Issue-ID: OOM-1951
Signed-off-by: Michal Zegan <m.zegan@samsung.com>
diff --git a/ansible/roles/application/defaults/main.yml b/ansible/roles/application/defaults/main.yml
index 2ae668a..6a7472a 100644
--- a/ansible/roles/application/defaults/main.yml
+++ b/ansible/roles/application/defaults/main.yml
@@ -5,11 +5,15 @@
- { opt: '--timeout 1800'}
# Override file generation for Helm application can be customized by any role
# given by user and found by ansible from roles_path.
-# By default override file is generated by 'application-override' role that is
-# specific for offline installer (for onap) as it's generating server
-# certificate needed to simulate internet by offline installer.
+# By default override file is generated by 'application-override' role that
+# allows specifying custom helm overrides as the value of "override"
+# dictionary in inventory or extravars.
app_skip_helm_override: false
app_helm_override_role: application-override
app_helm_override_file: "{{ app_data_path }}/override.yaml"
-helm_overide_files:
- - "{{ app_helm_override_file }}"
+# List of additional helm override files, the one generated above overrides
+# every file listed here. In addition, the order of override files in this list
+# matters, settings in latter files override the former..
+# Paths provided here must be absolute.
+helm_override_files:
+ - "{{ app_helm_charts_infra_directory }}/onap/resources/overrides/onap-all.yaml"
diff --git a/ansible/roles/application/molecule/default/tests/test_default.py b/ansible/roles/application/molecule/default/tests/test_default.py
index 5edceff..22298e3 100644
--- a/ansible/roles/application/molecule/default/tests/test_default.py
+++ b/ansible/roles/application/molecule/default/tests/test_default.py
@@ -16,7 +16,8 @@
repo list
repo add local http://127.0.0.1:8879
install --name moleculetestapp local/moleculetestapp --namespace \
-moleculetestapp -f /opt/moleculetestapp/override.yaml \
+moleculetestapp -f /opt/moleculetestapp/helm_charts/onap/resources/\
+overrides/onap-all.yaml -f /opt/moleculetestapp/override.yaml \
--timeout 1800"""
assert fc == expected_content
diff --git a/ansible/roles/application/tasks/install.yml b/ansible/roles/application/tasks/install.yml
index 003631d..2ac2fd6 100644
--- a/ansible/roles/application/tasks/install.yml
+++ b/ansible/roles/application/tasks/install.yml
@@ -59,6 +59,16 @@
name: "{{ app_helm_override_role }}"
when: not app_skip_helm_override
+# The generated override file is added to override list unless skipped.
+- name: Add application helm override file to list of overrides unless skipped
+ set_fact:
+ helm_override_files: "{{ (helm_override_files | default([])) + [app_helm_override_file] }}"
+ when: not app_skip_helm_override
+
+- name: Print final list of override files
+ debug:
+ var: helm_override_files
+
- name: Check for deploy plugin presence
stat:
path: '{{ helm_home_dir.stdout }}/plugins/deploy/deploy.sh'
@@ -71,7 +81,7 @@
{{ app_helm_release_name }}
{{ helm_repository_name }}/{{ app_helm_chart_name }}
--namespace {{ app_kubernetes_namespace }}
- {% if not app_skip_helm_override %} {% for arg in helm_overide_files %} {{ '-f ' + arg }} {% endfor %} {% endif %}
+ {% for arg in helm_override_files %} {{ '-f ' + arg }} {% endfor %}
{% for arg in helm_extra_install_options %} {{ arg.opt }} {% endfor %}
changed_when: true # when executed its a changed type of action
register: helm_install