From 2c7299fa340e6918a59d92981f01652e9464ee86 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Fri, 22 Jan 2021 15:09:51 +0100 Subject: Add Helm v3 plugin deployment playbook Change-Id: I3999dd64dd87f163a3306b74cec88019d821759e Issue-ID: OOM-2665 Signed-off-by: Bartek Grzybowski --- .../application/tasks/install-helm3-plugins.yml | 33 ++++++++++++++++++++++ ansible/roles/application/tasks/install.yml | 8 +++--- ansible/roles/application/tasks/setup-helm2.yml | 5 ++++ ansible/roles/application/tasks/setup-helm3.yml | 5 ++++ .../application/tasks/transfer-helm-charts.yml | 2 ++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/application/tasks/install-helm3-plugins.yml create mode 100644 ansible/roles/application/tasks/setup-helm2.yml create mode 100644 ansible/roles/application/tasks/setup-helm3.yml (limited to 'ansible/roles/application/tasks') diff --git a/ansible/roles/application/tasks/install-helm3-plugins.yml b/ansible/roles/application/tasks/install-helm3-plugins.yml new file mode 100644 index 00000000..da402f31 --- /dev/null +++ b/ansible/roles/application/tasks/install-helm3-plugins.yml @@ -0,0 +1,33 @@ +--- +- name: Install helm plugins if needed + block: + - name: Get helm environment information + command: "{{ helm_bin_dir }}/helm env" + register: helm_env + - name: Set helm data dir + set_fact: + helm_data_dir: | + "{% if 'HELM_DATA_HOME' in helm_env.stdout %} + {{ (helm_env.stdout | replace('\"', '') | regex_search('HELM_DATA_HOME.*')).split('=')[1] }} + {% else %} + {{ '~/.local/share/helm' }} + {% endif %}" + - name: Ensure that dir for helm plugins exists + file: + path: "{{ helm_data_dir }}/plugins" + state: directory + mode: 0755 + - name: Register all plugins to be inserted by dir names + find: + paths: "{{ app_helm_plugins_directory }}" + file_type: "directory" + register: list_of_plugins + delegate_to: localhost + - name: Install all helm plugins from {{ app_helm_plugins_directory }} dir + copy: + src: "{{ item.path }}" + dest: "{{ helm_data_dir }}/plugins" + directory_mode: true + mode: 0755 + loop: "{{ list_of_plugins.files }}" + when: app_helm_plugins_directory is defined and app_helm_plugins_directory is not none diff --git a/ansible/roles/application/tasks/install.yml b/ansible/roles/application/tasks/install.yml index 81e145a7..9e27e2de 100644 --- a/ansible/roles/application/tasks/install.yml +++ b/ansible/roles/application/tasks/install.yml @@ -78,10 +78,10 @@ debug: var: helm_override_files -- name: Check for deploy plugin presence - stat: - path: '{{ helm_home_dir.stdout }}/plugins/deploy/deploy.sh' - register: deploy_plugin_presence +- include_tasks: setup-helm2.yml + when: helm_version | regex_search("^v2" ) +- include_tasks: setup-helm3.yml + when: helm_version | regex_search("^v3" ) - name: "Helm Install application {{ app_name }}" command: > diff --git a/ansible/roles/application/tasks/setup-helm2.yml b/ansible/roles/application/tasks/setup-helm2.yml new file mode 100644 index 00000000..77f0ee91 --- /dev/null +++ b/ansible/roles/application/tasks/setup-helm2.yml @@ -0,0 +1,5 @@ +--- +- name: Check for deploy plugin presence + stat: + path: '{{ helm_home_dir.stdout }}/plugins/deploy/deploy.sh' + register: deploy_plugin_presence diff --git a/ansible/roles/application/tasks/setup-helm3.yml b/ansible/roles/application/tasks/setup-helm3.yml new file mode 100644 index 00000000..ce8cbb3a --- /dev/null +++ b/ansible/roles/application/tasks/setup-helm3.yml @@ -0,0 +1,5 @@ +--- +- name: Check for deploy plugin presence + stat: + path: '{{ helm_data_dir }}/plugins/deploy/deploy.sh' + register: deploy_plugin_presence diff --git a/ansible/roles/application/tasks/transfer-helm-charts.yml b/ansible/roles/application/tasks/transfer-helm-charts.yml index ac910735..2101a5ab 100644 --- a/ansible/roles/application/tasks/transfer-helm-charts.yml +++ b/ansible/roles/application/tasks/transfer-helm-charts.yml @@ -22,3 +22,5 @@ - include_tasks: install-helm2-plugins.yml when: helm_version | regex_search("^v2" ) +- include_tasks: install-helm3-plugins.yml + when: helm_version | regex_search("^v3" ) -- cgit 1.2.3-korg