From e4e94f02af945d5780a9df7793ce560dd1605caa Mon Sep 17 00:00:00 2001
From: Ana Aviles <ana@greenhost.nl>
Date: Mon, 6 May 2019 11:07:04 +0000
Subject: [PATCH] Resolve "Remove failed helm deployments before running
 helmfile"

---
 README.md                          |  1 +
 ansible/roles/setup/tasks/main.yml | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/README.md b/README.md
index c4a4576bf..9856d4ff9 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
 
 The OpenAppStack bootstrap script allows you to easily set up a new OpenAppStack cluster.
 
+
 Please refer to https://openappstack.net/documentation.html for further details,
 and to https://openappstack.net/tutorial.html for a step by step installation tutorial
 how to bootstrap your cluster.
diff --git a/ansible/roles/setup/tasks/main.yml b/ansible/roles/setup/tasks/main.yml
index d288a7adc..8a148c10b 100644
--- a/ansible/roles/setup/tasks/main.yml
+++ b/ansible/roles/setup/tasks/main.yml
@@ -213,9 +213,24 @@
   with_items:
     - /oas/config/values/apps/nginx.yaml
 
+- name: Check if there are failed helm deployments
+  tags:
+    - helmfile      
+  command: 'helm ls --failed --short'
+  failed_when: false
+  register: helm_failed_deployments
+  changed_when: false
+
+- name: Remove failed helm deployments
+  tags:
+    - helmfile
+  shell: 'helm ls --failed --short | xargs -L1 helm delete --purge'
+  when: helm_failed_deployments.stdout != ""
+
 - name: Apply helmfiles
   tags:
     - helmfile
   environment:
     - NEXTCLOUD_PASSWORD: "{{ nextcloud_password }}"
   command: '/usr/local/bin/helmfile -b /snap/bin/helm -e oas -f /oas/source/repos/helmfiles/helmfile.d/ apply --suppress-secrets'
+
-- 
GitLab