Mario Vázquez
2019-07-30 1e2ca71eab2d1c2704086dabfb3dcf94f5543885
commit | author | age
123ffb 1 ---
MV 2 # Implement your Workload deployment tasks here
3
4 - name: Setting up workload for user
5   debug:
6     msg: "Setting up workload for user ocp_username = {{ ocp_username }}"
7
8 - name: Setting up custom facts
9   set_fact:
10     pacman_cluster1_route_hostname: "pacman.{{ cluster1_wildcard_domain }}"
11     pacman_cluster2_route_hostname: "pacman.{{ cluster2_wildcard_domain }}"
12     pacman_cluster3_route_hostname: "pacman.{{ cluster3_wildcard_domain }}"
13
14 - name: Ensure OpenShift Objects for KubeFed are Created
15   k8s:
16     state: present
17     merge_type:
18     - strategic-merge
19     - merge
20     definition: "{{ lookup('template', item ) | from_yaml }}"
21   loop:
22     - ./templates/kubefed_project.j2
23     - ./templates/catalog_source_config.j2
24     - ./templates/operator_group.j2
25     - ./templates/subscription.j2
26
27 - name: Wait until InstallPlan is Created
28   shell: oc get installplan -o name -n "{{ _kubefed_project }}" | awk -F "/" '{print $2}'
29   register: install_plan
30   retries: 30
31   delay: 10
32   until: install_plan.stdout != ""
33
34 - name: Ensure InstallPlan is Approved
35   command: oc patch installplan "{{ install_plan.stdout }}" --type merge -p '{"spec":{"approved":true}}' -n "{{ _kubefed_project }}"
36
37 - name: Wait until CSV is Installed
38   command: oc get csv "{{ _kubefed_subscription_csv }}" -o jsonpath='{.status.phase}' -n "{{ _kubefed_project }}"
39   register: csv
40   retries: 30
41   delay: 10
42   until: csv.stdout == "Succeeded"
43
44 - name: Get KubeFed Operator Deployment Desired Replicas
45   command: oc get deployment "{{ _kubefed_operator_deployment }}" -o jsonpath='{.status.replicas}' -n "{{ _kubefed_project }}"
46   register: kubefed_operator_desired_replicas
47   retries: 30
48   delay: 10
49   until: kubefed_operator_desired_replicas.stdout != ""
50
51 - name: Wait until KubeFed Operator Deployment is Ready
52   command: oc get deployment "{{ _kubefed_operator_deployment }}" -o jsonpath='{.status.readyReplicas}' -n "{{ _kubefed_project }}" 
53   register: kubefed_operator_ready_replicas
54   retries: 30
55   delay: 10
56   until: kubefed_operator_ready_replicas.stdout == kubefed_operator_desired_replicas.stdout
57
58 - name: Ensure KubeFed Resource is Created
59   k8s:
60     state: present
61     merge_type:
62     - strategic-merge
63     - merge
64     definition: "{{ lookup('template', item ) | from_yaml }}"
65   loop:
66     - ./templates/kubefed.j2
67
68 - name: Get KubeFed Controller Deployment Desired Replicas
69   command: oc get deployment "{{ _kubefed_controller_deployment }}" -o jsonpath='{.status.replicas}' -n "{{ _kubefed_project }}"
70   register: kubefed_controller_desired_replicas
71   retries: 30
72   delay: 10
73   until: kubefed_controller_desired_replicas.stdout != ""
74
75 - name: Wait until KubeFed Controller Deployment is Ready
76   command: oc get deployment "{{ _kubefed_controller_deployment }}" -o jsonpath='{.status.readyReplicas}' -n "{{ _kubefed_project }}"
77   register: kubefed_controller_ready_replicas
78   retries: 30
79   delay: 10
80   until: kubefed_controller_ready_replicas.stdout == kubefed_controller_desired_replicas.stdout
81
82 - name: Ensure Pacman LB Route is Created
83   k8s:
84     state: present
85     merge_type:
86     - strategic-merge
87     - merge
88     definition: "{{ lookup('template', item ) | from_yaml }}"
89   loop:
90     - ./templates/haproxy_project.j2
91     - ./templates/haproxy_route.j2
92
93 - name: Get HAProxy Route
1e2ca7 94   command: oc get route haproxy-lb -o jsonpath='{.status.ingress[*].host}' -n "{{ _haproxy_project }}"
123ffb 95   register: haproxy_route_hostname
MV 96   retries: 30
97   delay: 10
98   until: haproxy_route_hostname.stdout != ""
99
100 - name: Set Pacman LB Fact
101   set_fact:
102     pacman_lb_hostname: "{{ haproxy_route_hostname.stdout }}"
103
104 - name: Ensure OpenShift Objects for HAProxy are Created
105   k8s:
106     state: present
107     merge_type:
108     - strategic-merge
109     - merge
110     definition: "{{ lookup('template', item ) | from_yaml }}"
111   loop:
112     - ./templates/haproxy_configmap.j2
113     - ./templates/haproxy_service.j2
114     - ./templates/haproxy_deployment.j2
115
116 - name: Ensure kubefedctl Tool is Downloaded
117   unarchive: 
118     src: "https://github.com/kubernetes-sigs/kubefed/releases/download/v{{ _kubefedctl_release }}/kubefedctl-{{ _kubefedctl_release }}-linux-amd64.tgz"
119     dest: /usr/local/bin
120     remote_src: yes
121     mode: 0755
122   become: true
123
124 - name: Ensure cfssl Tool is Downloaded
125   get_url:
126     url: "https://pkg.cfssl.org/{{ _cfssl_release }}/cfssl_linux-amd64"
127     dest: /usr/local/bin/cfssl
128     mode: 0755
129   become: true
130
131 - name: Ensure cfssljson Tool is Downloaded
132   get_url:
133     url: "https://pkg.cfssl.org/{{ _cfssl_release }}/cfssljson_linux-amd64"
134     dest: /usr/local/bin/cfssljson
135     mode: 0755
136   become: true
137
138 # The value of pacman_lb_hostname should be presented to the student somewhere as
139 # it will be the route they use for connecting to pacman application
140 - debug:
141     var: pacman_lb_hostname
142
143 # Leave this as the last task in the playbook.
144 - name: workload tasks complete
145   debug:
146     msg: "Workload Tasks completed successfully."
1e2ca7 147   when: not silent|bool