Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Parameterise resource cache location (#39)
Browse files Browse the repository at this point in the history
* Replace hard-coded resource cache location with variable

* Update task names to reflect lack of hard-coding

* Formatting

* Add cache location var in all roles creating local resources
  • Loading branch information
agrski authored Nov 4, 2021
1 parent 50ec7c9 commit f0182ed
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 22 deletions.
2 changes: 2 additions & 0 deletions roles/efk_opendistro_stack/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
seldon_cache_directory: "{{ ansible_env.HOME }}/.cache/seldon"

seldon_system_namespace: seldon-system
elastic_opendistro_namespace: seldon-logs

Expand Down
2 changes: 1 addition & 1 deletion roles/efk_opendistro_stack/tasks/get_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
ansible.builtin.git:
version: "{{ elastic_opendistro_version }}"
repo: "{{ elastic_opendistro_repo }}"
dest: "{{ inventory_dir }}/.resources/opendistro-build"
dest: "{{ seldon_cache_directory }}/opendistro-build"
force: yes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
kubernetes.core.helm:
name: elasticsearch
release_namespace: "{{ elastic_opendistro_namespace }}"
chart_ref: "{{ inventory_dir }}/.resources/opendistro-build/helm/opendistro-es"
chart_ref: "{{ seldon_cache_directory }}/opendistro-build/helm/opendistro-es"
values: "{{ elastic_opendistro_values }}"

- name: Wait for Elasticsearch deployments
Expand Down
2 changes: 2 additions & 0 deletions roles/istio/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
seldon_cache_directory: "{{ ansible_env.HOME }}/.cache/seldon"

istio_version: 1.10.3
istio_verify_install: true
istio_create_seldon_gateway: true
Expand Down
12 changes: 6 additions & 6 deletions roles/istio/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
---
- name: Check if Istio {{ istio_version }} already downloaded.
stat:
path: "{{ inventory_dir }}/.resources/istio-{{ istio_version }}"
path: "{{ seldon_cache_directory }}/istio-{{ istio_version }}"
register: istio_directory


- name: "Create .resources directory if does not exist: {{ inventory_dir }}/.resources/"
- name: "Create resources directory if does not exist: {{ seldon_cache_directory }}/"
ansible.builtin.file:
path: "{{ inventory_dir }}/.resources/"
path: "{{ seldon_cache_directory }}/"
state: directory
mode: '0755'


- name: Download Istio {{ istio_version }}
shell: "curl -L https://istio.io/downloadIstio | ISTIO_VERSION={{ istio_version }} sh -"
args:
chdir: "{{ inventory_dir }}/.resources"
chdir: "{{ seldon_cache_directory }}"
warn: false
when: istio_directory.stat.exists == false


- name: Install Istio {{ istio_version }}
shell: "./bin/istioctl install --set profile=default -y"
args:
chdir: "{{ inventory_dir }}/.resources/istio-{{ istio_version }}"
chdir: "{{ seldon_cache_directory }}/istio-{{ istio_version }}"


- name: Verify Install Istio {{ istio_version }}
shell: "./bin/istioctl verify-install"
args:
chdir: "{{ inventory_dir }}/.resources/istio-{{ istio_version }}"
chdir: "{{ seldon_cache_directory }}/istio-{{ istio_version }}"
when: istio_verify_install | bool


Expand Down
2 changes: 2 additions & 0 deletions roles/iter8/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
seldon_cache_directory: "{{ ansible_env.HOME }}/.cache/seldon"

iter8_namespace: iter8-system
iter8_version: master

Expand Down
7 changes: 4 additions & 3 deletions roles/iter8/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
ansible.builtin.git:
version: "{{ iter8_version }}"
repo: "{{ iter8_repo }}"
dest: "{{ inventory_dir }}/.resources/iter8"
dest: "{{ seldon_cache_directory }}/iter8"
force: yes
when: iter8_source_dir is undefined

- name: Set Iter8 Directory
set_fact: iter8_source_dir="{{ inventory_dir }}/.resources/iter8"
set_fact:
iter8_source_dir: "{{ seldon_cache_directory }}/iter8"
when: iter8_source_dir is undefined

- name: Install Iter8
ansible.builtin.shell: "kustomize build {{ inventory_dir }}/.resources/iter8/install/core | kubectl apply -n {{ iter8_namespace }} -f -"
ansible.builtin.shell: "kustomize build {{ seldon_cache_directory }}/iter8/install/core | kubectl apply -n {{ iter8_namespace }} -f -"

- name: Wait for Iter8 deployments
kubernetes.core.k8s_info:
Expand Down
2 changes: 2 additions & 0 deletions roles/kind/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
seldon_cache_directory: "{{ ansible_env.HOME }}/.cache/seldon"

kind_cluster_name: ansible
kind_image_version: kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9

Expand Down
4 changes: 2 additions & 2 deletions roles/kind/tasks/create_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- name: "Start KinD Cluster: '{{ kind_cluster_name }}'"
command:
argv:
- "{{ inventory_dir }}/.resources/kind-{{ kind_version }}"
- "{{ seldon_cache_directory }}/kind-{{ kind_version }}"
- create
- cluster
- --name={{ kind_cluster_name }}
Expand All @@ -24,7 +24,7 @@
- name: "Export kubeconfig for KinD Cluster: '{{ kind_cluster_name }}'"
command:
argv:
- "{{ inventory_dir }}/.resources/kind-{{ kind_version }}"
- "{{ seldon_cache_directory }}/kind-{{ kind_version }}"
- export
- kubeconfig
- --name={{ kind_cluster_name }}
10 changes: 5 additions & 5 deletions roles/kind/tasks/download_kind.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
- name: Check if Kind {{ kind_version }} already downloaded
stat:
path: "{{ inventory_dir }}/.resources/kind-{{ kind_version }}"
path: "{{ seldon_cache_directory }}/kind-{{ kind_version }}"
register: kind_binary

- name: "Create .resources directory if does not exist: {{ inventory_dir }}/.resources/"
- name: "Create resources directory if does not exist: {{ seldon_cache_directory }}/"
ansible.builtin.file:
path: "{{ inventory_dir }}/.resources/"
path: "{{ seldon_cache_directory }}/"
state: directory
mode: '0755'

- name: Download Kind {{ kind_version }} binary
shell: "curl -Lo kind-{{ kind_version }} {{ kind_url }}"
args:
chdir: "{{ inventory_dir }}/.resources"
chdir: "{{ seldon_cache_directory }}"
warn: false
when: kind_binary.stat.exists == false

- name: Make Kind {{ kind_version }} binary executable
ansible.builtin.file:
path: "{{ inventory_dir }}/.resources/kind-{{ kind_version }}"
path: "{{ seldon_cache_directory }}/kind-{{ kind_version }}"
state: file
mode: '0755'
2 changes: 2 additions & 0 deletions roles/postgres_operator/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
seldon_cache_directory: "{{ ansible_env.HOME }}/.cache/seldon"

postgres_operator_namespace: postgres

postgres_operator_repo: https://github.com/zalando/postgres-operator.git
Expand Down
2 changes: 1 addition & 1 deletion roles/postgres_operator/tasks/get_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
ansible.builtin.git:
version: "{{ postgres_operator_version }}"
repo: "{{ postgres_operator_repo }}"
dest: "{{ inventory_dir }}/.resources/postgres-operator"
dest: "{{ seldon_cache_directory }}/postgres-operator"
force: yes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
kubernetes.core.helm:
name: postgres-operator
release_namespace: "{{ postgres_operator_namespace }}"
chart_ref: "{{ inventory_dir }}/.resources/postgres-operator/charts/postgres-operator"
chart_ref: "{{ seldon_cache_directory }}/postgres-operator/charts/postgres-operator"
values: "{{ postgres_operator_values }}"
values_files: "{{ postgres_operator_values_files }}"
2 changes: 2 additions & 0 deletions roles/seldon_core/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
seldon_cache_directory: "{{ ansible_env.HOME }}/.cache/seldon"

seldon_system_namespace: seldon-system
seldon_core_version: master

Expand Down
5 changes: 3 additions & 2 deletions roles/seldon_core/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
ansible.builtin.git:
version: "{{ seldon_core_version }}"
repo: "{{ seldon_core_repo }}"
dest: "{{ inventory_dir }}/.resources/seldon-core"
dest: "{{ seldon_cache_directory }}/seldon-core"
force: yes
when: seldon_core_source_dir is undefined

- name: Set Seldon Core Directory
set_fact: seldon_core_source_dir="{{ inventory_dir }}/.resources/seldon-core"
set_fact:
seldon_core_source_dir: "{{ seldon_cache_directory }}/seldon-core"
when: seldon_core_source_dir is undefined

- name: Deploy Seldon Core
Expand Down

0 comments on commit f0182ed

Please sign in to comment.