-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook_create.yaml
133 lines (102 loc) · 5.06 KB
/
playbook_create.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
- name: Start CRC 1.8.0 and deploy Openshift Drools Hacep
hosts: localhost
gather_facts: true
vars:
strimzi_version: "0.16.2"
ram: "16384" #MB
libvirt_version: "4.3.8"
kube_password: "{{ lookup('file', '/home/{{ ansible_user_id }}/.crc/cache/crc_libvirt_{{ libvirt_version }}/kubeadmin-password') }}"
vars_prompt:
- name: "nameSpace"
prompt: "Insert your Project Name/ NameSpace"
default: "my-kafka-project"
private: "no"
- name: "PullSecret"
prompt: "Insert your Pull secret"
tasks:
- debug: msg="Project Name {{ nameSpace }}"
- name: CRC setup
shell: "crc setup"
register: crc_result
- debug: msg="{{ crc_result }}"
- name: Write pull secret
copy:
content: "{{ PullSecret }}"
dest: "~/.crc/crc-pull-secret"
- name: Copy service account RBAC
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-drools-hacep/master/springboot/kubernetes/service-account.yaml"
dest: "/tmp/service-account.yaml"
- name: Copy role RBAC
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-drools-hacep/master/springboot/kubernetes/role.yaml"
dest: "/tmp/role.yaml"
- name: Copy role-binding RBAC
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-drools-hacep/master/springboot/kubernetes/role-binding.yaml"
dest: "/tmp/role-binding.yaml"
- name: Copy Kafka-ephemeral
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-handbook/master/scripts/kafka/fedora/{{ strimzi_version }}/kafka-ephemeral.yaml"
dest: "/tmp/kafka-ephemeral.yaml"
- name: Copy Kafka control topic config
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-handbook/master/scripts/kafka/fedora/control.yaml"
dest: "/tmp/control.yaml"
- name: Copy Kafka events topic config
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-handbook/master/scripts/kafka/fedora/events.yaml"
dest: "/tmp/events.yaml"
- name: Copy Kafka events topic config
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-handbook/master/scripts/kafka/fedora/snapshot.yaml"
dest: "/tmp/snapshot.yaml"
- name: Copy Kafka kiesessioninfos topic config
get_url:
url: "https://raw.githubusercontent.com/desmax74/openshift-handbook/master/scripts/kafka/fedora/kiesessioninfos.yaml"
dest: "/tmp/kiesessioninfos.yaml"
- name: Start CRC with 16GB (~ 10 minutes)
shell: "crc start -m {{ ram }} -p ~/.crc/crc-pull-secret"
- name: Add .crc/bin to the path
shell: "export PATH=$PATH:/home/{{ansible_user_id}}/.crc/bin/"
- name: Check that oc exists in /home/{{ansible_user_id}}/.local/bin/
stat:
path: "/home/{{ ansible_user_id }}/.local/bin/oc"
register: stat_result
- name: Move oc from /tmp to /home/{{ansible_user_id}}/.local/bin
command: "cp /home/{{ansible_user_id}}/.crc/bin/oc /home/{{ansible_user_id}}/.local/bin/"
when: stat_result.stat.exists == False
- name: Login crc
shell: "oc login -u kubeadmin -p {{ kube_password }} https://api.crc.testing:6443"
- name: Create {{ nameSpace }}
shell: "oc new-project {{ nameSpace }}"
- name: Create service account RBAC
shell: "oc create -f /tmp/service-account.yaml"
- name: Create role for RBAC
shell: "oc create -f /tmp/role.yaml"
- name: Create role-binding for RBAC
shell: "oc create -f /tmp/role-binding.yaml"
- name: Install Strimzi operator {{ strimzi_version }}
shell: "curl -L https://github.com/strimzi/strimzi-kafka-operator/releases/download/{{ strimzi_version }}/strimzi-cluster-operator-{{ strimzi_version }}.yaml \
| sed 's/namespace: .*/namespace: {{ nameSpace }}/' \
| kubectl -n {{ nameSpace }} apply -f -"
- name: Create kafka ephemeral cluster
shell: "kubectl apply -f /tmp/kafka-ephemeral.yaml -n {{ nameSpace }}"
- name: Check AvailableReplica on Strimzi cluster first on {{ nameSpace }} wait for up to 240 sec, poll every 10 sec, 24 times
shell: "kubectl get pods --selector=strimzi.io/name=my-cluster-entity-operator -o jsonpath='{.items[*].status.phase}'"
register: result
until: result.stdout.find("Running") != -1
async: 240
poll: 10
retries: 24
- name: Create kafka events topic
shell: "oc create -f /tmp/events.yaml"
- name: Create kafka control topic
shell: "oc create -f /tmp/control.yaml"
- name: Create kafka snapshot topic
shell: "oc create -f /tmp/snapshot.yaml"
- name: Create kafka kiesessioninfos topic
shell: "oc create -f /tmp/kiesessioninfos.yaml"
- debug: msg="Your project Name is {{ nameSpace }}"
- debug: msg="Your Kube Password is {{ kube_password }}"