summaryrefslogtreecommitdiffstats
path: root/ansible/roles/application/tasks/install-helm3-plugins.yml
blob: da402f31f77d92db014d8449df0c9c4867b37982 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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