---
|
# Implement your Workload deployment tasks here
|
|
- name: Setting up workload for user
|
debug:
|
msg: "Setting up workload for user ocp_username = {{ ocp_username }}"
|
|
- name: Setting up custom facts
|
set_fact:
|
pacman_cluster1_route_hostname: "pacman.{{ cluster1_wildcard_domain }}"
|
pacman_cluster2_route_hostname: "pacman.{{ cluster2_wildcard_domain }}"
|
pacman_cluster3_route_hostname: "pacman.{{ cluster3_wildcard_domain }}"
|
|
- name: Ensure OpenShift Objects for KubeFed are Created
|
k8s:
|
state: present
|
merge_type:
|
- strategic-merge
|
- merge
|
definition: "{{ lookup('template', item ) | from_yaml }}"
|
loop:
|
- ./templates/kubefed_project.j2
|
- ./templates/catalog_source_config.j2
|
- ./templates/operator_group.j2
|
- ./templates/subscription.j2
|
|
- name: Wait until InstallPlan is Created
|
shell: oc get installplan -o name -n "{{ _kubefed_project }}" | awk -F "/" '{print $2}'
|
register: install_plan
|
retries: 30
|
delay: 10
|
until: install_plan.stdout != ""
|
|
- name: Ensure InstallPlan is Approved
|
command: oc patch installplan "{{ install_plan.stdout }}" --type merge -p '{"spec":{"approved":true}}' -n "{{ _kubefed_project }}"
|
|
- name: Wait until CSV is Installed
|
command: oc get csv "{{ _kubefed_subscription_csv }}" -o jsonpath='{.status.phase}' -n "{{ _kubefed_project }}"
|
register: csv
|
retries: 30
|
delay: 10
|
until: csv.stdout == "Succeeded"
|
|
- name: Get KubeFed Operator Deployment Desired Replicas
|
command: oc get deployment "{{ _kubefed_operator_deployment }}" -o jsonpath='{.status.replicas}' -n "{{ _kubefed_project }}"
|
register: kubefed_operator_desired_replicas
|
retries: 30
|
delay: 10
|
until: kubefed_operator_desired_replicas.stdout != ""
|
|
- name: Wait until KubeFed Operator Deployment is Ready
|
command: oc get deployment "{{ _kubefed_operator_deployment }}" -o jsonpath='{.status.readyReplicas}' -n "{{ _kubefed_project }}"
|
register: kubefed_operator_ready_replicas
|
retries: 30
|
delay: 10
|
until: kubefed_operator_ready_replicas.stdout == kubefed_operator_desired_replicas.stdout
|
|
- name: Ensure KubeFed Resource is Created
|
k8s:
|
state: present
|
merge_type:
|
- strategic-merge
|
- merge
|
definition: "{{ lookup('template', item ) | from_yaml }}"
|
loop:
|
- ./templates/kubefed.j2
|
|
- name: Get KubeFed Controller Deployment Desired Replicas
|
command: oc get deployment "{{ _kubefed_controller_deployment }}" -o jsonpath='{.status.replicas}' -n "{{ _kubefed_project }}"
|
register: kubefed_controller_desired_replicas
|
retries: 30
|
delay: 10
|
until: kubefed_controller_desired_replicas.stdout != ""
|
|
- name: Wait until KubeFed Controller Deployment is Ready
|
command: oc get deployment "{{ _kubefed_controller_deployment }}" -o jsonpath='{.status.readyReplicas}' -n "{{ _kubefed_project }}"
|
register: kubefed_controller_ready_replicas
|
retries: 30
|
delay: 10
|
until: kubefed_controller_ready_replicas.stdout == kubefed_controller_desired_replicas.stdout
|
|
- name: Ensure Pacman LB Route is Created
|
k8s:
|
state: present
|
merge_type:
|
- strategic-merge
|
- merge
|
definition: "{{ lookup('template', item ) | from_yaml }}"
|
loop:
|
- ./templates/haproxy_project.j2
|
- ./templates/haproxy_route.j2
|
|
- name: Get HAProxy Route
|
command: oc get route haproxy-lb -o jsonpath='{.status.ingress[*].host}' -n "{{ _haproxy_project }}"
|
register: haproxy_route_hostname
|
retries: 30
|
delay: 10
|
until: haproxy_route_hostname.stdout != ""
|
|
- name: Set Pacman LB Fact
|
set_fact:
|
pacman_lb_hostname: "{{ haproxy_route_hostname.stdout }}"
|
|
- name: Ensure OpenShift Objects for HAProxy are Created
|
k8s:
|
state: present
|
merge_type:
|
- strategic-merge
|
- merge
|
definition: "{{ lookup('template', item ) | from_yaml }}"
|
loop:
|
- ./templates/haproxy_configmap.j2
|
- ./templates/haproxy_service.j2
|
- ./templates/haproxy_deployment.j2
|
|
- name: Ensure kubefedctl Tool is Downloaded
|
unarchive:
|
src: "https://github.com/kubernetes-sigs/kubefed/releases/download/v{{ _kubefedctl_release }}/kubefedctl-{{ _kubefedctl_release }}-linux-amd64.tgz"
|
dest: /usr/local/bin
|
remote_src: yes
|
mode: 0755
|
become: true
|
|
- name: Ensure cfssl Tool is Downloaded
|
get_url:
|
url: "https://pkg.cfssl.org/{{ _cfssl_release }}/cfssl_linux-amd64"
|
dest: /usr/local/bin/cfssl
|
mode: 0755
|
become: true
|
|
- name: Ensure cfssljson Tool is Downloaded
|
get_url:
|
url: "https://pkg.cfssl.org/{{ _cfssl_release }}/cfssljson_linux-amd64"
|
dest: /usr/local/bin/cfssljson
|
mode: 0755
|
become: true
|
|
# The value of pacman_lb_hostname should be presented to the student somewhere as
|
# it will be the route they use for connecting to pacman application
|
- debug:
|
var: pacman_lb_hostname
|
|
# Leave this as the last task in the playbook.
|
- name: workload tasks complete
|
debug:
|
msg: "Workload Tasks completed successfully."
|
when: not silent|bool
|