{{ helm_bin_dir }}/helm init
--upgrade
--skip-refresh
+ changed_when: true # init is always changed type of action
#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)
until: result.rc == 0
delay: 10
retries: 12
+ changed_when: false # for idempotency
- name: Get all helm repos
command: "{{ helm_bin_dir }}/helm repo list"
register: repos
+ changed_when: false # for idempotency
- name: Remove stable repo
command: "{{ helm_bin_dir }}/helm repo remove stable"
+ changed_when: true # when executed its a changed type of action
when: "'stable' in repos.stdout"
- name: Helm Serve
shell: "{{ helm_bin_dir }}/helm serve &"
async: 45
- poll: 0
+ poll: 3 # wait 3sec to get a chance for some stderr
+ register: helm_serve
+ changed_when: "'address already in use' not in helm_serve.stderr"
+
+- name: List helm repos
+ command: "{{ helm_bin_dir }}/helm repo list"
+ register: helm_repo_list
+ changed_when: false # for idempotency
+ failed_when:
+ - helm_repo_list.rc > 0
+ - "'Error: no repositories to show' not in helm_repo_list.stderr"
- name: Helm Add Repo
command: "{{ helm_bin_dir }}/helm repo add {{ helm_repository_name }} {{ helm_repository_url }}"
+ when: "'local' not in helm_repo_list.stdout"
+ changed_when: true # when executed its a changed type of action
- name: Build local helm repository
make:
# WA: this is required because deploy plugin dont process params properly
- name: Create override file with global.cacert
copy:
- dest: "{{ app_data_path}}/override.yaml"
+ dest: "{{ app_data_path }}/override.yaml"
content: |
global:
cacert: |
{{ helm_repository_name }}/{{ app_helm_chart_name }}
--namespace {{ app_kubernetes_namespace }}
-f {{ app_data_path }}/override.yaml
+ changed_when: true # when executed its a changed type of action
- name: "Unarchive resource {{ resource_source_filename }} from host {{ resources_source_host }}, transport is {{ transport }}"
include_tasks: "unarchive-{{ transport }}-resource.yml"
- - file:
+
+ - name: "Generate flag file after resources are deployed on infra"
+ file:
path: "{{ resource_destination_directory }}/{{ resource_source_filename }}-uploaded"
state: touch
rescue:
with_items: "{{ files_after_fail.files | difference(original_files.files) }}"
when: files_after_fail is defined
- - fail:
+ - name: "Report failure of upload operation"
+ fail:
msg: "Upload of {{ resource_source_filename }} failed"
set_fact:
tar_extract_options: "{{ '-xzf' if compressed.rc == 0 else '-xf' }}"
- - name: "Unarchive resource {{ resources_dir }}/{{ resource_source_filename }} to {{ resource_destination_directory }} dir on infrastructure servers over ssh"
+ - name: "Unarchive resource {{ resources_dir }}/{{ resource_source_filename }} \
+ to {{ resource_destination_directory }} dir on infrastructure servers over ssh"
shell: >
ssh -o StrictHostKeyChecking=no -o BatchMode=yes
-i /root/.ssh/infra_to_resource.privkey