blob: cdc7ced027e5af1e600b01d5d5850b3c060d4895 [file] [log] [blame]
Tomas Levora5ea00a92018-12-19 14:36:36 +01001---
2- name: Helm init and upgrade
3 command: |
4 {{ helm_bin_dir }}/helm init
5 --upgrade
6 --skip-refresh
Samuli Silvius8fd23142019-04-17 19:42:59 +03007 changed_when: true # init is always changed type of action
Tomas Levora5ea00a92018-12-19 14:36:36 +01008
Samuli Silvius51d7d012019-03-19 08:45:54 +02009# A correct way to implement this would be using --wait option in helm init invocation.
10# However, it does not work due to https://github.com/helm/helm/issues/4031 (fixed in newer helm release)
Michal Ptacek11e2af52018-12-19 19:42:03 +000011- name: "Wait for helm upgrade to finish"
12 command: "{{ helm_bin_dir }}/helm version --tiller-connection-timeout 10"
13 register: result
14 until: result.rc == 0
15 delay: 10
16 retries: 12
Samuli Silvius8fd23142019-04-17 19:42:59 +030017 changed_when: false # for idempotency
Tomas Levora5ea00a92018-12-19 14:36:36 +010018
19- name: Get all helm repos
20 command: "{{ helm_bin_dir }}/helm repo list"
21 register: repos
Samuli Silvius8fd23142019-04-17 19:42:59 +030022 changed_when: false # for idempotency
Tomas Levora5ea00a92018-12-19 14:36:36 +010023
24- name: Remove stable repo
25 command: "{{ helm_bin_dir }}/helm repo remove stable"
Samuli Silvius8fd23142019-04-17 19:42:59 +030026 changed_when: true # when executed its a changed type of action
Tomas Levora5ea00a92018-12-19 14:36:36 +010027 when: "'stable' in repos.stdout"
28
29- name: Helm Serve
30 shell: "{{ helm_bin_dir }}/helm serve &"
31 async: 45
Samuli Silvius8fd23142019-04-17 19:42:59 +030032 poll: 3 # wait 3sec to get a chance for some stderr
Michal Ptacek200ae722019-03-21 12:32:20 +000033 register: helm_serve
34 changed_when: "'address already in use' not in helm_serve.stderr"
35
36- name: List helm repos
37 command: "{{ helm_bin_dir }}/helm repo list"
38 register: helm_repo_list
Samuli Silvius8fd23142019-04-17 19:42:59 +030039 changed_when: false # for idempotency
Michal Ptacek200ae722019-03-21 12:32:20 +000040 failed_when:
41 - helm_repo_list.rc > 0
42 - "'Error: no repositories to show' not in helm_repo_list.stderr"
Tomas Levora5ea00a92018-12-19 14:36:36 +010043
44- name: Helm Add Repo
Samuli Silvius51d7d012019-03-19 08:45:54 +020045 command: "{{ helm_bin_dir }}/helm repo add {{ helm_repository_name | mandatory }} {{ helm_repository_url | mandatory }}"
Michal Ptacek200ae722019-03-21 12:32:20 +000046 when: "'local' not in helm_repo_list.stdout"
Samuli Silvius8fd23142019-04-17 19:42:59 +030047 changed_when: true # when executed its a changed type of action
Tomas Levora5ea00a92018-12-19 14:36:36 +010048
Michal Ptacek271cf3f2019-01-17 20:39:46 +000049- name: Build local helm repository
Tomas Levora5ea00a92018-12-19 14:36:36 +010050 make:
Michal Ptacek11e2af52018-12-19 19:42:03 +000051 chdir: "{{ app_helm_charts_infra_directory }}"
Michal Ptacek271cf3f2019-01-17 20:39:46 +000052 target: "{{ item }}"
Samuli Silvius51d7d012019-03-19 08:45:54 +020053 loop: "{{ app_helm_build_targets }}"
Michal Ptacek11e2af52018-12-19 19:42:03 +000054 environment:
55 PATH: "{{ helm_bin_dir }}:{{ ansible_env.PATH }}"
Tomas Levora5ea00a92018-12-19 14:36:36 +010056
Samuli Silvius51d7d012019-03-19 08:45:54 +020057- name: Generate Helm application override file with custom role
58 include_role:
59 name: "{{ app_helm_override_role }}"
60 when: not app_skip_helm_override
Michal Ptacek997057f2019-02-01 08:37:05 +000061
Michal Ptacekfabcad62019-02-04 06:38:08 +000062- name: Check for deploy plugin presence
63 stat:
Milan Verespej5f5aa012019-02-08 15:30:39 +010064 path: '{{ helm_home_dir.stdout }}/plugins/deploy/deploy.sh'
Michal Ptacekfabcad62019-02-04 06:38:08 +000065 register: deploy_plugin_presence
66
67- name: "Helm Install application {{ app_name }}"
68 command: >
69 {{ helm_bin_dir }}/helm
70 {{ 'deploy' if deploy_plugin_presence.stat.exists else 'install --name' }}
71 {{ app_helm_release_name }}
72 {{ helm_repository_name }}/{{ app_helm_chart_name }}
73 --namespace {{ app_kubernetes_namespace }}
Samuli Silvius51d7d012019-03-19 08:45:54 +020074 {{ '' if app_skip_helm_override else '-f ' + app_helm_override_file }}
Samuli Silvius8fd23142019-04-17 19:42:59 +030075 changed_when: true # when executed its a changed type of action
Milan Verespeja2e3a4c2019-03-29 12:50:40 +010076 register: helm_install
77 failed_when: helm_install.stderr