-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1687 from ar3ndt/feature/separate-repository-machine
separate repository machine [#1640]
- Loading branch information
Showing
14 changed files
with
192 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
--- | ||
- hosts: helm | ||
become: true | ||
become_method: sudo | ||
become_flags: --login | ||
- hosts: 127.0.0.1 | ||
gather_facts: false | ||
connection: local | ||
become: false | ||
roles: | ||
- helm | ||
- role: helm | ||
when: | ||
- groups.helm is defined | ||
- groups.helm | length > 0 | ||
- groups.repository is defined | ||
- groups.repository | length > 0 | ||
environment: | ||
# The "inventory_dir" fact cannot be used here. | ||
# Documentation (https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html) states: | ||
# - The inventory_file and inventory_dir magic variables are not available for the implicit localhost as they are dependent on each inventory host. | ||
# TODO: https://github.com/epiphany-platform/epiphany/issues/1650 | ||
KUBECONFIG: "{{ vault_location }}/../kubeconfig" |
8 changes: 0 additions & 8 deletions
8
core/src/epicli/data/common/ansible/playbooks/roles/helm/tasks/gather-facts.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 29 additions & 35 deletions
64
core/src/epicli/data/common/ansible/playbooks/roles/helm/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,42 @@ | ||
--- | ||
- import_tasks: gather-facts.yml | ||
|
||
- name: Check system index file existence | ||
uri: | ||
url: http://localhost/epirepo/helm-charts/system/index.yaml | ||
method: HEAD | ||
register: uri_index_test | ||
# fail with error if status is unexpected | ||
failed_when: uri_index_test.status not in [200, 404] | ||
|
||
- name: Deploy the "system" Helm charts | ||
when: inventory_hostname == target_repository_hostnames[0] # execute on the main repository host only | ||
block: | ||
- name: Check if Helm chart repo already exists | ||
shell: | | ||
helm repo list | grep {{ helm_chart_repo_name }} | ||
shell: helm repo list | grep -w "{{ helm_chart_repo_name }}" | ||
register: helm_repo_list | ||
failed_when: (helm_repo_list.rc != 0 and not 'no repositories' in helm_repo_list.stderr) | ||
or helm_repo_list.rc > 1 | ||
|
||
- name: "Check if files exist in {{ specification.apache_epirepo_path }}/helm-charts/system" | ||
find: | ||
paths: "{{ specification.apache_epirepo_path }}/helm-charts/system" | ||
register: helm_charts_files_number | ||
|
||
- name: Add Helm chart repo and install charts | ||
when: helm_charts_files_number.matched > 1 | ||
block: | ||
- name: Get Helm charts list from repo before update | ||
shell: | | ||
helm search repo {{ helm_chart_repo_name }} --output json | jq -r '.[].name' | ||
register: helm_charts_list_before_update | ||
- name: Get Helm charts list from repo before update | ||
shell: helm search repo {{ helm_chart_repo_name }} --output json | jq -r '.[].name' | ||
register: helm_charts_list_before_update | ||
failed_when: (helm_charts_list_before_update.rc != 0 and not 'no repositories' in helm_charts_list_before_update.stderr) | ||
or helm_charts_list_before_update.rc > 1 | ||
|
||
- name: "Add {{ helm_chart_repo_name }} Helm repository from url {{ repository_url }}" | ||
shell: | | ||
helm repo add {{ helm_chart_repo_name }} {{ repository_url }}/helm-charts/system | ||
when: | ||
- helm_chart_repo_name not in helm_repo_list.stdout | ||
- name: "Add {{ helm_chart_repo_name }} Helm repository from url http://localhost/epirepo" | ||
shell: helm repo add {{ helm_chart_repo_name }} http://localhost/epirepo/helm-charts/system | ||
when: helm_chart_repo_name not in helm_repo_list.stdout | ||
|
||
- name: Update Helm repo | ||
shell: | | ||
helm repo update | ||
- name: Update Helm repo | ||
shell: helm repo update | ||
|
||
- name: Get Helm charts list from repo after update | ||
shell: | | ||
helm search repo {{ helm_chart_repo_name }} --output json | jq -r '.[].name' | ||
register: helm_charts_list_after_update | ||
- name: Get Helm charts list from repo after update | ||
shell: helm search repo {{ helm_chart_repo_name }} --output json | jq -r '.[].name' | ||
register: helm_charts_list_after_update | ||
|
||
- name: Delete Helm charts not present in repository | ||
shell: | | ||
helm delete {{ chart_subname }} --purge | ||
vars: | ||
chart_subname: "{{ item.split('/')[1] }}" | ||
loop: "{{ helm_charts_list_before_update.stdout_lines }}" | ||
when: item not in helm_charts_list_after_update.stdout_lines | ||
- name: Delete Helm charts not present in repository | ||
shell: helm delete {{ chart_subname }} --purge | ||
vars: | ||
chart_subname: "{{ item.split('/')[1] }}" | ||
loop: "{{ helm_charts_list_before_update.stdout_lines }}" | ||
when: item not in helm_charts_list_after_update.stdout_lines | ||
when: uri_index_test.status == 200 # whole block of code is supposed to be executed only if system charts exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters