-
Notifications
You must be signed in to change notification settings - Fork 55
/
main.yml
113 lines (92 loc) · 2.93 KB
/
main.yml
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
---
- name: Install git
become: true
become_user: root
yum:
name: git
state: present
- name: Template endpoints json
template:
src: glusterfs-endpoints.json.j2
dest: /home/centos/glusterfs-endpoints.json
- name: Template service json
template:
src: glusterfs-service.json.j2
dest: /home/centos/glusterfs-service.json
- name: Template volume yaml (IT'S STATIC RIGHT NOW, FIX THAT.)
template:
src: glusterfs-volumes.yaml.j2
dest: /home/centos/glusterfs-volumes.yaml
- name: Template namespace yaml
template:
src: glusterfs-namespace.yaml.j2
dest: /home/centos/glusterfs-namespace.yaml
- name: Get list of namespaces
shell: >
kubectl get namespaces
register: namespaces_list
- name: Create gluster namespace if necessary
shell: >
kubectl create -f /home/centos/glusterfs-namespace.yaml
when: "'gluster' not in namespaces_list.stdout"
- name: Clone gluster-kubernetes
git:
repo: https://github.com/gluster/gluster-kubernetes.git
dest: /home/centos/gluster-kubernetes
version: master
- name: Template GlusterFS gk-deploy topology json
template:
src: glusterfs-topology.json.j2
dest: /home/centos/gluster-kubernetes/deploy/topology.json
- name: Download heketi cli tarball
get_url:
url: https://github.com/heketi/heketi/releases/download/v4.0.0/heketi-v4.0.0.linux.amd64.tar.gz
dest: /home/centos/heketi.tar.gz
- name: Create directory for extraction of tarball
file:
path: /home/centos/heketi
state: directory
- name: Extract heketi cli tarball
unarchive:
src: /home/centos/heketi.tar.gz
dest: /home/centos/heketi
remote_src: yes
- name: Copy heketi-cli bin into place
become: true
become_user: root
shell: >
cp /home/centos/heketi/heketi/heketi-cli /usr/local/bin/heketi-cli
args:
creates: /usr/local/bin/heketi-cli
- name: Deploy GlusterFS on Kubernetes with gk-deploy (note -- this is coffee break worthy, it takes a while)
shell: >
./gk-deploy -n gluster -g -y
args:
chdir: /home/centos/gluster-kubernetes/deploy
creates: /home/centos/.gk-deployed
- name: Mark that gk-deploy is complete
file:
path: /home/centos/.gk-deployed
state: directory
- name: Get the heketi IP address
shell: >
kubectl get svc --namespace=gluster | grep 8080 | awk '{print $2}'
register: heketi_ipaddress_raw
- name: Set the heketi IP
set_fact:
heketi_ip: "{{ heketi_ipaddress_raw.stdout }}"
- name: Template the storage class yaml
template:
src: glusterfs-storageclass.yaml.j2
dest: /home/centos/glusterfs-storageclass.yaml
- name: List the storage classes
shell: >
kubectl get storageclass
register: storageclass_list
- name: Create the storage class
shell: >
kubectl create -f /home/centos/glusterfs-storageclass.yaml
when: "'gluster' not in storageclass_list.stdout"
# Get heketi URL.
# [centos@kube-master ~]$ kubectl get svc --namespace=gluster | grep 8080 | awk '{print $2}'
# 10.105.179.111