da402f31f77d92db014d8449df0c9c4867b37982
[oom/offline-installer.git] / ansible / roles / application / tasks / install-helm3-plugins.yml
1 ---
2 - name: Install helm plugins if needed
3   block:
4     - name: Get helm environment information
5       command: "{{ helm_bin_dir }}/helm env"
6       register: helm_env
7     - name: Set helm data dir
8       set_fact:
9         helm_data_dir: |
10           "{% if 'HELM_DATA_HOME' in helm_env.stdout %}
11            {{ (helm_env.stdout | replace('\"', '') | regex_search('HELM_DATA_HOME.*')).split('=')[1] }}
12            {% else %}
13            {{ '~/.local/share/helm' }}
14            {% endif %}"
15     - name: Ensure that dir for helm plugins exists
16       file:
17         path: "{{ helm_data_dir }}/plugins"
18         state: directory
19         mode: 0755
20     - name: Register all plugins to be inserted by dir names
21       find:
22         paths: "{{ app_helm_plugins_directory }}"
23         file_type: "directory"
24       register: list_of_plugins
25       delegate_to: localhost
26     - name: Install all helm plugins from {{ app_helm_plugins_directory }} dir
27       copy:
28         src: "{{ item.path }}"
29         dest: "{{ helm_data_dir }}/plugins"
30         directory_mode: true
31         mode: 0755
32       loop: "{{ list_of_plugins.files }}"
33   when: app_helm_plugins_directory is defined and app_helm_plugins_directory is not none