Add required applications to applications list automatically

We used to have a required applications list in ansible playbook. This
is checked against the user specified overrides file to ensure entries
for the required applications are present. This creates an issue when
the required applications versions are changed. If the required
applications list versions are not changed, bootstrap fails. This
commit changes the behavior of the setup. There is no longer a
required applications list with version numbers; the required
applications versions will be automatically detected by searching for
nginx and cert manager tarballs on the system. If the user overrides
file does not contain entries for these applications, default entries
with no overrides will be generated to keep things consistent with the
old setup.

Closes-bug: 1886742

Change-Id: I66e6a1c1934df64988212a960bccba8efcc62bd6
Signed-off-by: Jerry Sun <jerry.sun@windriver.com>
This commit is contained in:
Jerry Sun 2020-08-04 09:56:40 -04:00
parent a0682c7c24
commit a7c1f6fffb
3 changed files with 29 additions and 11 deletions

View File

@ -320,6 +320,4 @@ k8s_plugins:
# - chart: dex
# namespace: kube-system
# values-path: /home/sysinv/dex-overrides.yaml
applications:
- /usr/local/share/applications/helm/nginx-ingress-controller-1.0-0.tgz:
- /usr/local/share/applications/helm/cert-manager-1.0-6.tgz:
applications: []

View File

@ -568,6 +568,7 @@
- name: Validate applications
include: validate_application.yml application={{ item }}
with_items: "{{ applications }}"
when: applications
- name: Build application list
set_fact:
@ -578,11 +579,33 @@
all_applications: "{{ all_applications }} + [ '{{ item.keys()[0] }}' ]"
with_items: "{{ applications }}"
- name: Ensure mandatory applications are present in config
debug:
msg: "Mandatory application: {{ item }}"
failed_when: item not in all_applications
with_items: "{{ mandatory_applications }}"
- name: Get the name of the nginx tarball
find:
paths: "/usr/local/share/applications/helm/"
patterns: 'nginx-ingress-controller-[^-]*-[^-]*\.tgz'
use_regex: yes
register: find_nginx_tarball_output
- name: Get the name of the cert manager tarball
find:
paths: "/usr/local/share/applications/helm/"
patterns: 'cert-manager-[^-]*-[^-]*\.tgz'
use_regex: yes
register: find_cert_manager_tarball_output
# we prepend nginx and append cert manager to try and enforce ordering
# nginx need to be applied before cert manager
- name: Append default nginx entry if not present
set_fact:
applications: "[ {'{{ item.path }}': None}] + {{ applications }}"
with_items: "{{ find_nginx_tarball_output.files }}"
when: item.path not in all_applications
- name: Append default cert manager entry if not present
set_fact:
applications: "{{ applications }} + [ {'{{ item.path }}': None}]"
with_items: "{{ find_cert_manager_tarball_output.files }}"
when: item.path not in all_applications
- block:
- name: Retrieve list of applications from sysinv

View File

@ -15,6 +15,3 @@ system_controller_floating_address: none
system_controller_subnet: none
system_controller_oam_floating_address: none
system_controller_oam_subnet: none
mandatory_applications:
- /usr/local/share/applications/helm/nginx-ingress-controller-1.0-0.tgz
- /usr/local/share/applications/helm/cert-manager-1.0-6.tgz