2 - name: Helm init and upgrade
4 {{ helm_bin_dir }}/helm init
7 changed_when: true # init is always changed type of action
9 # 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)
11 - name: "Wait for helm upgrade to finish"
12 command: "{{ helm_bin_dir }}/helm version --tiller-connection-timeout 10"
17 changed_when: false # for idempotency
19 - name: Get all helm repos
20 command: "{{ helm_bin_dir }}/helm repo list"
22 changed_when: false # for idempotency
24 - name: Remove stable repo
25 command: "{{ helm_bin_dir }}/helm repo remove stable"
26 changed_when: true # when executed its a changed type of action
27 when: "'stable' in repos.stdout"
30 shell: "{{ helm_bin_dir }}/helm serve &"
32 poll: 3 # wait 3sec to get a chance for some stderr
34 changed_when: "'address already in use' not in helm_serve.stderr"
36 - name: List helm repos
37 command: "{{ helm_bin_dir }}/helm repo list"
38 register: helm_repo_list
39 changed_when: false # for idempotency
41 - helm_repo_list.rc > 0
42 - "'Error: no repositories to show' not in helm_repo_list.stderr"
45 command: "{{ helm_bin_dir }}/helm repo add {{ helm_repository_name | mandatory }} {{ helm_repository_url | mandatory }}"
46 when: "'local' not in helm_repo_list.stdout"
47 changed_when: true # when executed its a changed type of action
49 - name: Build local helm repository
51 chdir: "{{ app_helm_charts_infra_directory }}"
55 loop: "{{ app_helm_build_targets }}"
57 PATH: "{{ helm_bin_dir }}:{{ ansible_env.PATH }}"
59 - name: Generate Helm application override file with custom role
61 name: "{{ app_helm_override_role }}"
62 when: not app_skip_helm_override
64 # The generated override file is added to override list unless skipped.
65 - name: Add application helm override file to list of overrides unless skipped
67 helm_override_files: "{{ (helm_override_files | default([])) + [app_helm_override_file] }}"
68 when: not app_skip_helm_override
70 - name: Print final list of override files
72 var: helm_override_files
74 - name: Check for deploy plugin presence
76 path: '{{ helm_home_dir.stdout }}/plugins/deploy/deploy.sh'
77 register: deploy_plugin_presence
79 - name: "Helm Install application {{ app_name }}"
81 {{ helm_bin_dir }}/helm
82 {{ 'deploy' if deploy_plugin_presence.stat.exists else 'install --name' }}
83 {{ app_helm_release_name }}
84 {{ helm_repository_name }}/{{ app_helm_chart_name }}
85 --namespace {{ app_kubernetes_namespace }}
86 {{ helm_override_files | map('regex_replace', '^', '-f ') | join(' ') }}
87 {{ helm_extra_install_options | map(attribute='opt') | join(' ') }}
88 changed_when: true # when executed its a changed type of action
89 register: helm_install
90 failed_when: helm_install.stderr