summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
Diffstat (limited to 'ansible')
-rw-r--r--ansible/roles/application-install/tasks/custom_role.yml9
-rw-r--r--ansible/roles/application-install/tasks/install.yml17
-rw-r--r--ansible/roles/application-install/tasks/post-install.yml5
-rw-r--r--ansible/roles/application-install/tasks/pre-install.yml23
4 files changed, 49 insertions, 5 deletions
diff --git a/ansible/roles/application-install/tasks/custom_role.yml b/ansible/roles/application-install/tasks/custom_role.yml
new file mode 100644
index 00000000..3c6237e3
--- /dev/null
+++ b/ansible/roles/application-install/tasks/custom_role.yml
@@ -0,0 +1,9 @@
+---
+# Caller fills application_custom_role variable with actual role name.
+- name: "Execute custom role {{ application_custom_role }} {{ phase }} Helm install."
+ include_role:
+ name: "{{ application_custom_role }}"
+ when:
+ - application_custom_role is defined
+ - application_custom_role is not none
+ - application_custom_role | trim != ''
diff --git a/ansible/roles/application-install/tasks/install.yml b/ansible/roles/application-install/tasks/install.yml
index 54b64439..7ff6b62c 100644
--- a/ansible/roles/application-install/tasks/install.yml
+++ b/ansible/roles/application-install/tasks/install.yml
@@ -5,9 +5,14 @@
--upgrade
--skip-refresh
-- name: Wait for helm
- wait_for: timeout=10
- delegate_to: localhost
+#A correct way to implement this would be using --wait option in helm init invocation.
+#However, it does not work due to https://github.com/helm/helm/issues/4031 (fixed in newer helm release)
+- name: "Wait for helm upgrade to finish"
+ command: "{{ helm_bin_dir }}/helm version --tiller-connection-timeout 10"
+ register: result
+ until: result.rc == 0
+ delay: 10
+ retries: 12
- name: Get all helm repos
command: "{{ helm_bin_dir }}/helm repo list"
@@ -27,8 +32,10 @@
- name: Helm Make All
make:
- chdir: "{{ app_helm_charts_directory }}"
+ chdir: "{{ app_helm_charts_infra_directory }}"
target: all
+ environment:
+ PATH: "{{ helm_bin_dir }}:{{ ansible_env.PATH }}"
- name: Helm Install application {{ app_name }}
- command: "helm install {{ helm_repository_name }}/{{ app_helm_chart_name }} --name {{ app_helm_release_name }} --namespace {{ app_kubernetes_namespace }}"
+ command: "{{ helm_bin_dir }}/helm install {{ helm_repository_name }}/{{ app_helm_chart_name }} --name {{ app_helm_release_name }} --namespace {{ app_kubernetes_namespace }}"
diff --git a/ansible/roles/application-install/tasks/post-install.yml b/ansible/roles/application-install/tasks/post-install.yml
new file mode 100644
index 00000000..10594233
--- /dev/null
+++ b/ansible/roles/application-install/tasks/post-install.yml
@@ -0,0 +1,5 @@
+---
+- name: "Execute custome role {{ application_post_install_role }} if defined."
+ include_tasks: custom_role.yml
+ vars:
+ application_custom_role: "{{ application_post_install_role }}"
diff --git a/ansible/roles/application-install/tasks/pre-install.yml b/ansible/roles/application-install/tasks/pre-install.yml
new file mode 100644
index 00000000..b782ca76
--- /dev/null
+++ b/ansible/roles/application-install/tasks/pre-install.yml
@@ -0,0 +1,23 @@
+---
+# before custom specific code is executed we need to move helm charts to infra
+- name: Distribute helm charts to infra node
+ block:
+ - name: Archive helm charts
+ archive:
+ path: "{{ app_helm_charts_install_directory }}/*"
+ dest: "{{ app_helm_charts_install_directory }}.tgz"
+ delegate_to: localhost
+ - name: Create helm charts dir on infra
+ file:
+ path: "{{ app_helm_charts_infra_directory }}"
+ state: directory
+ mode: 0755
+ - name: Unarchive helm charts on infra node
+ unarchive:
+ src: "{{ app_helm_charts_install_directory }}.tgz"
+ dest: "{{ app_helm_charts_infra_directory }}"
+
+- name: "Execute custome role {{ application_pre_install_role }} if defined."
+ include_tasks: custom_role.yml
+ vars:
+ application_custom_role: "{{ application_pre_install_role }}"