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

Commit

Permalink
Replace cluster extra var with platform (#446)
Browse files Browse the repository at this point in the history
OpenShift removed the endpoint that identified it was openshift.  The Broker
doesn't seem to accuratly identify which cluster it's running on so let's replace
the check for openshift.
  • Loading branch information
Ryan Hallisey authored Nov 9, 2018
1 parent 927e5c8 commit 25d9620
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 47 deletions.
13 changes: 6 additions & 7 deletions playbooks/kubevirt-web-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ One of following must be set:
- `version` example: 0.9.3

### Required Variables
- `cluster`
- To install Kubevirt Web UI, please set `cluster=openshift`
- `platform`
- To install Kubevirt Web UI, please set `platform=openshift`

### Optional Variables:
- `openshift_master_default_subdomain`
Expand All @@ -39,10 +39,9 @@ Please check `playbooks/kubevirt-web-ui/inventory_example.ini` for an example.

### Invocation examples
```
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=provision cluster=openshift registry_url=quay.io registry_namespace=kubevirt docker_tag=1.3" # to mimic kubevirt-apb flow
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=provision cluster=openshift registry_url=quay.io registry_namespace=kubevirt" # for :latest image tag
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=provision cluster=openshift registry_url=quay.io registry_namespace=kubevirt version=0.9.3" # for automatic tag association or :latest as default
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=provision platform=openshift registry_url=quay.io registry_namespace=kubevirt docker_tag=1.3" # to mimic kubevirt-apb flow
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=provision platform=openshift registry_url=quay.io registry_namespace=kubevirt" # for :latest image tag
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=provision platform=openshift registry_url=quay.io registry_namespace=kubevirt version=0.9.3" # for automatic tag association or :latest as default
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=deprovision cluster=openshift kubevirt_web_ui_image_name=whatever"
ansible-playbook -i your_inventory_file.ini playbooks/kubevirt-web-ui/config.yml -e "apb_action=deprovision platform=openshift kubevirt_web_ui_image_name=whatever"
```

8 changes: 4 additions & 4 deletions playbooks/kubevirt-web-ui/private/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
playbook: "playbooks/kubevirt-web-ui/config.yml"
status: "In Progress"
start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
when: cluster | default("openshift") == "openshift"
when: platform == "openshift"

- name: Kubevirt Web UI
- name: Kubevirt Web UI
# hosts: oo_first_master
hosts: masters[0]
vars:
first_master: "{{ masters[0] }}"
tasks:
- import_role:
name: kubevirt_web_ui
when: cluster | default("openshift") == "openshift"
when: platform == "openshift"

- name: Kubevirt Web UI Install Checkpoint End
hosts: all
Expand All @@ -35,4 +35,4 @@
installer_phase_console:
status: "Complete"
end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
when: cluster | default("openshift") == "openshift"
when: platform == "openshift"
16 changes: 14 additions & 2 deletions playbooks/kubevirt.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
---
- hosts: all
connection: local
gather_facts: False
environment:
http_proxy: ""
tasks:
- name: Identify cluster
command: "oc get projects"
register: result

- name: Set cluster variable
set_fact:
platform: "openshift"
when: "{{ result.rc }} == 0"

- name: Login As Super User
command: "oc login -u {{ admin_user }} -p {{ admin_password }}"
when: cluster | default('openshift')=="openshift"
when: platform == "openshift"
and admin_user is defined
and admin_password is defined

Expand All @@ -31,10 +43,10 @@

- hosts: masters[0]
connection: local
gather_facts: False
environment:
http_proxy: ""
roles:
- role: "cdi"

- import_playbook: kubevirt-web-ui/config.yml

2 changes: 1 addition & 1 deletion roles/cdi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This role deploys the CDI controller.
| cdi_kubevirt_storageclass | kubevirt | |Storageclass that CDI will use to create PersistentVolumes. |
| apb_action | provision |<ul><li>provision</li><li>deprovision</li></ul>|Action to perform.|
| cdi_repo_tag | kubevirt | |CDI docker hub repo tag.|
| cdi_release_tag | v1.2.0 | |CDI docker hub release tag.|
| cdi_release_tag | v1.3.0 | |CDI docker hub release tag.|
| cdi_uploadproxy_image | cdi-uploadproxy | Name of CDI uploadproxy docker image. |
| cdi_apiserver_image | cdi-apiserver | Name of CDI apiserver docker image. |
| cdi_uploadserver_image | cdi-uploadserver | Name of CDI uploadserver docker image. |
Expand Down
4 changes: 3 additions & 1 deletion roles/cdi/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ cdi_namespace: "{{ cdi_image_namespace | default('kube-system') }}"
cdi_storageclass: "{{ cdi_kubevirt_storageclass | default('kubevirt') }}"
apb_action: "provision"
docker_prefix: "{{ cdi_repo_tag | default('kubevirt') }}"
docker_tag: "{{ cdi_release_tag | default('v1.2.0') }}"
cdi_release_tag: "v1.3.0"
release_tag: "{{ cdi_release_tag }}"
docker_tag: "{{ cdi_release_tag }}"
uploadproxy_image: "{{ cdi_uploadproxy_image | default('cdi-uploadproxy') }}"
apiserver_image: "{{ cdi_apiserver_image | default('cdi-apiserver') }}"
uploadserver_image: "{{ cdi_uploadserver_image | default('cdi-uploadserver') }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/cdi/tasks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

- name: Download CDI Template
get_url:
url: "{{ cdi_release_manifest_url }}/{{ docker_tag }}/cdi-controller.yaml.j2"
url: "{{ cdi_release_manifest_url }}/{{ release_tag }}/cdi-controller.yaml.j2"
dest: "{{ cdi_template_dir }}/cdi-controller.yaml.j2"
when: byo_template.stat.exists == False and offline_templates.stat.exists == False

Expand Down
4 changes: 2 additions & 2 deletions roles/kubevirt/tasks/deprovision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
- name: Delete Privileged Policy
command: "oc adm policy remove-scc-from-user privileged -z {{ item }} -n {{ namespace }}"
with_items: "{{ kubevirt_privileged_policies | list }}"
when: cluster=="openshift"
when: platform=="openshift"

- name: Delete Hostmount-anyuid Policy
command: "oc adm policy remove-scc-from-user hostmount-anyuid -z kubevirt-infra -n {{ namespace }}"
when: cluster=="openshift"
when: platform=="openshift"
8 changes: 4 additions & 4 deletions roles/kubevirt/tasks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
- name: Add Privileged Policy
command: "oc adm policy add-scc-to-user privileged -z {{ item }} -n {{ namespace }}"
with_items: "{{ kubevirt_privileged_policies | list }}"
when: cluster=="openshift"
when: platform=="openshift"

- name: Add Hostmount-anyuid Policy
command: "oc adm policy add-scc-to-user hostmount-anyuid -z kubevirt-infra -n {{ namespace }}"
when: cluster=="openshift"
when: platform=="openshift"

- name: Enable kubevirt feature gates
shell: "oc apply -f {{ kubevirt_template_dir }}/kubevirt-config.yaml -n {{ namespace }}"
Expand Down Expand Up @@ -133,10 +133,10 @@
dest: "/tmp/{{ item }}.yaml"
with_items:
- "{{ default_vm_templates }}"
when: cluster == "openshift" and "{{ byo_vm_templates.results | selectattr('stat.exists') | map(attribute='item') | list | length == 0 }}" and "{{ offline_vm_templates.results | selectattr('stat.exists') | map(attribute='item') | list | length == 0 }}"
when: platform == "openshift" and "{{ byo_vm_templates.results | selectattr('stat.exists') | map(attribute='item') | list | length == 0 }}" and "{{ offline_vm_templates.results | selectattr('stat.exists') | map(attribute='item') | list | length == 0 }}"

- name: Create default VM templates in OpenShift Namespace
shell: "oc apply -f /tmp/{{ item }}.yaml -n openshift"
with_items:
- "{{ default_vm_templates }}"
when: cluster == "openshift"
when: platform == "openshift"
4 changes: 2 additions & 2 deletions roles/network-multus/tasks/deprovision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
- name: openshift cni config
set_fact:
cni_config: "{{ openshift_cni_config }}"
when: cluster=="openshift"
when: platform=="openshift"

- name: kubernetes cni config
set_fact:
cni_config: "{{ kubernetes_cni_config }}"
when: cluster=="kubernetes"
when: platform=="kubernetes"

- name: Render multus deployment yaml
template:
Expand Down
10 changes: 5 additions & 5 deletions roles/network-multus/tasks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
- name: oc Command
set_fact:
cluster_command: oc
when: cluster=="openshift"
when: platform=="openshift"

- name: kubectl Command
set_fact:
cluster_command: kubectl
when: cluster=="kubernetes"
when: platform=="kubernetes"

- name: Check if namespace "{{ namespace }}" exists
shell: "{{ cluster_command }} get ns | grep -w {{ namespace }} | awk \'{ print $1 }\'"
Expand All @@ -26,12 +26,12 @@
- name: openshift cni config
set_fact:
cni_config: "{{ openshift_cni_config }}"
when: cluster=="openshift"
when: platform=="openshift"

- name: kubernetes cni config
set_fact:
cni_config: "{{ kubernetes_cni_config }}"
when: cluster=="kubernetes"
when: platform=="kubernetes"

- name: Render multus deployment yaml
template:
Expand Down Expand Up @@ -71,7 +71,7 @@
dest: /tmp/ovs-vsctl.yml
- name: Create ovs-vsctl resources
shell: "{{ cluster_command }} apply -f /tmp/ovs-vsctl.yml"
when: cluster == "openshift"
when: platform == "openshift"
when: deploy_ovs_plugin

- name: Wait until multus is running
Expand Down
4 changes: 2 additions & 2 deletions roles/skydive/tasks/deprovision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
- name: Delete {{ skydive_namespace }} namespace on the kubernetes cluster
shell: kubectl delete namespaces {{ skydive_namespace }}
when: ns.stdout == skydive_namespace
and cluster=="kubernetes"
and platform=="kubernetes"

- name: Delete {{ skydive_namespace }} project on the openshift cluster
shell: oc delete project {{ skydive_namespace }}
when: ns.stdout == skydive_namespace
and cluster=="openshift"
and platform=="openshift"
20 changes: 10 additions & 10 deletions roles/skydive/tasks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,50 @@
- name: Create {{ skydive_namespace }} namespace on the kubernetes cluster
shell: kubectl create namespace {{ skydive_namespace }}
when: ns.stdout != skydive_namespace
and cluster=="kubernetes"
and platform=="kubernetes"

- name: Create {{ skydive_namespace }} project on the openshift cluster
shell: oc new-project {{ skydive_namespace }}
when: ns.stdout != skydive_namespace
and cluster=="openshift"
and platform=="openshift"

- name: Render skydive deployment yaml for kubernetes
template:
src: kubernetes-skydive.yaml
dest: /tmp/skydive.yaml
when: cluster=="kubernetes"
when: platform=="kubernetes"

- name: Render skydive deployment yaml for openshift
template:
src: openshift-skydive.yaml
dest: /tmp/skydive.yaml
when: cluster=="openshift"
when: platform=="openshift"

- name: Deploy skydive for openshift
shell: "oc -n {{ skydive_namespace }} apply -f /tmp/skydive.yaml"
when: cluster=="openshift"
when: platform=="openshift"

- name: Deploy skydive for kubernetes
shell: "oc -n {{ skydive_namespace }} apply -f /tmp/skydive.yaml"
when: cluster=="kubernetes"
when: platform=="kubernetes"

- name: Add privilage for openshift cluster
shell: "oc adm policy add-scc-to-user privileged system:serviceaccount:{{ skydive_namespace }}:default"
when: cluster=="openshift"
when: platform=="openshift"

- name: Create app from openshift teamplate
shell: "oc -n {{ skydive_namespace }} new-app --template=skydive"
when: cluster=="openshift"
when: platform=="openshift"

- name: Openshift resource
set_fact:
analyzer_resource: deploymentconfig
when: cluster=="openshift"
when: platform=="openshift"

- name: Kubernetes resource
set_fact:
analyzer_resource: deployment
when: cluster=="kubernetes"
when: platform=="kubernetes"

- name: Wait until skydive analyzer is running
shell: "kubectl -n {{ skydive_namespace }} get {{ analyzer_resource }} --no-headers skydive-analyzer | awk \'{ if ($3 == $4) print \"0\"; else print \"1\"}\'"
Expand Down
4 changes: 2 additions & 2 deletions roles/storage-demo/tasks/provision.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Login As Super User
command: "oc login -u {{ admin_user }} -p {{ admin_password }}"
when: cluster=="openshift"
when: platform=="openshift"
and admin_user is defined
and admin_password is defined

Expand All @@ -24,7 +24,7 @@

- name: Grant privileged access to storage-demo serviceaccount
command: oc adm policy add-scc-to-user privileged system:serviceaccount:{{ namespace }}:storage-demo
when: cluster=="openshift"
when: platform=="openshift"

- name: Select a target node
command: kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="Hostname")].address}'
Expand Down
4 changes: 2 additions & 2 deletions roles/storage-glusterfs/tasks/deprovision.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Login As Super User
command: "oc login -u {{ admin_user }} -p {{ admin_password }}"
when: cluster=="openshift"
when: platform=="openshift"
and admin_user is defined
and admin_password is defined

Expand All @@ -12,7 +12,7 @@
command: "oc get route -n {{ glusterfs_namespace }} -l heketi={{ glusterfs_name_label }}route -o jsonpath='{.items[0].spec.host}'"
register: route_cmd
when:
- cluster == 'openshift'
- platform == 'openshift'
- heketi_url is not defined

- set_fact:
Expand Down
4 changes: 2 additions & 2 deletions roles/storage-glusterfs/tasks/provision.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Login As Super User
command: "oc login -u {{ admin_user }} -p {{ admin_password }}"
when: cluster=="openshift"
when: platform=="openshift"
and admin_user is defined
and admin_password is defined

Expand All @@ -12,7 +12,7 @@
command: "oc get route -n {{ glusterfs_namespace }} -l heketi={{ glusterfs_name_label }}route -o jsonpath='{.items[0].spec.host}'"
register: route_cmd
when:
- cluster == 'openshift'
- platform == 'openshift'
- heketi_url is not defined

- set_fact:
Expand Down

0 comments on commit 25d9620

Please sign in to comment.