Changes for Helm v3 compatibility:
[infra/stack/kubernetes.git] / apps / spinnaker / kubespray / playbooks / roles / install / tasks / main.yml
index a72222242bf8bce4160a56c1d9730acc8dbe637b..e90fbade1d4ea4c7d3e2151f8a76e97e7ae45eec 100644 (file)
       src: "index.yaml.j2"
       dest: "{{ engine_workspace }}/offline/charts/stable/index.yaml"
       force: true
+
+  - name: Create local repo index (empty initially)
+    command: "helm repo index {{ engine_workspace }}/offline/charts/local/"
+    creates: "{{ engine_workspace }}/offline/charts/local/index.yaml"
   when: execution_mode == "offline-deployment"
 
 - name: Initialize Helm
   command: helm init --client-only --local-repo-url {{ local_repo_url }} --stable-repo-url {{ stable_repo_url }}
   register: helm_init_result
   changed_when: true
+  when: helm_version is version('v3', '<')
+
+- name: Check if stable helm repo exists (helm v3+)
+  command: "helm repo list"
+  changed_when: true
+  failed_when: false
+  register: helm_repo_list_result
+
+- name: Add stable helm repo (helm v3+)
+  command: "helm repo add stable {{ stable_repo_url }}"
+  register: helm_repo_add_stable_result
+  changed_when: true
+  when: >
+    helm_version is version('v3.0.0', '>=')
+    and execution_mode == "online-deployment"
+    and helm_repo_list_result is not search(stable_repo_url)
+
+- name: Add local helm repo (helm v3+)
+  command: "helm repo add local {{ local_repo_url }}"
+  register: helm_repo_add_local_result
+  changed_when: true
+  when: >
+    helm_version is version('v3.0.0', '>=')
+    and execution_mode == "offline-deployment"
+    and helm_repo_list_result is not search(local_repo_url)
 
 - name: Clone Helm Charts repository
   git:
 - name: Install Spinnaker using helm
   command: >
     helm install
-      --name "{{ spinnaker_service }}"
+      {% if helm_version is version('v3.0.0', '<')%} --name {% endif %}"{{ spinnaker_service }}"
       --namespace "{{ spinnaker_namespace }}"
-      --timeout 900
+      --timeout "900{% if helm_version is version('v3.0.0', '>=') %}s{% endif %}"
       {{ engine_cache }}/repos/charts/stable/spinnaker
   register: spinnaker_helm_log
   changed_when: true