--- # Make utility is missing in Ubuntu by default and it's necessary for building local helm repository - name: Install build-essential package: name: build-essential state: present when: ansible_os_family == "Debian" - include_tasks: setup-helm2.yml when: helm_version | regex_search("^v2" ) - include_tasks: setup-helm3.yml when: helm_version | regex_search("^v3" ) - name: Build local helm repository make: chdir: "{{ app_helm_charts_infra_directory }}" params: SKIP_LINT: "TRUE" target: "{{ item }}" loop: "{{ app_helm_build_targets }}" environment: PATH: "{{ helm_bin_dir }}:{{ ansible_env.PATH }}" - name: Generate Helm application override file with custom role include_role: name: "{{ app_helm_override_role }}" when: not app_skip_helm_override # The generated override file is added to override list unless skipped. - name: Add application helm override file to list of overrides unless skipped set_fact: helm_override_files: "{{ (helm_override_files | default([])) + [app_helm_override_file] }}" when: not app_skip_helm_override - name: Print final list of override files debug: var: helm_override_files - name: "Ensure kubernetes namespace for {{ app_name }} exists" command: kubectl create namespace {{ app_kubernetes_namespace }} register: kubectl_out changed_when: kubectl_out.rc == 0 failed_when: kubectl_out.rc == 1 and "AlreadyExists" not in kubectl_out.stderr - name: "Helm Install application {{ app_name }}" command: > {{ helm_bin_dir }}/helm {{ 'deploy' if deploy_plugin_presence.stat.exists else 'install --name' }} {{ app_helm_release_name }} {{ helm_repository_name }}/{{ app_helm_chart_name }} --namespace {{ app_kubernetes_namespace }} {{ helm_override_files | map('regex_replace', '^', '-f ') | join(' ') }} {{ helm_extra_install_options | map(attribute='opt') | join(' ') }} changed_when: true # when executed its a changed type of action register: helm_install failed_when: "'FAILED' in (helm_install.stdout | upper()) or helm_install.rc != 0"