-
Notifications
You must be signed in to change notification settings - Fork 2
/
gluster.yaml
63 lines (63 loc) · 1.83 KB
/
gluster.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
- hosts: k8s:glusters
become: yes
tasks:
- name: Add GlusterFS Repository
apt_repository:
repo: 'ppa:gluster/glusterfs-3.13'
codename: xenial
- name: Install GlusterFS on all servers
apt:
name: glusterfs-server
state: present
update_cache: yes
- name: Make storage directory on GlusterFS Server
file:
path: /opt/shared-storage
state: directory
mode: 0755
run_once: true
- name: Make storage directory to mount on nodes
file:
path: /mnt/shared-directory
state: directory
mode: 0755
run_once: true
- name: Add IP address of hosts to /etc/hosts
lineinfile:
dest: /etc/hosts
line: "{{ hostvars[item].ansible_host }} {{ hostvars[item].inventory_hostname }}"
state: present
with_items: "{{ groups.glusters }}"
- hosts: glusters
become: yes
tasks:
- name: Connect peers
shell: gluster peer probe "{{ hostvars[item].inventory_hostname }}"
with_items:
- "{{ groups.glusters }}"
- name: Create GlusterFS Volume
gluster_volume:
state: present
name: cluster-storage
force: yes
bricks: /opt/shared-storage
# rebalance: yes //UNCOMMENT IF YOU HAVE MORE THAN 1 BRICK IN YOUR POOL//
start_on_create: yes
cluster:
"{{ groups.glusters }}"
run_once: true
- name: Setting network timeout
shell: gluster volume set cluster-storage network.ping-timeout "3"
- hosts: k8s
become: yes
tasks:
- name: Create mount-point on nodes and add it to fstab
become: true
become_user: root
become_method: sudo
mount:
name: /mnt/shared-directory
src: gluster1:/cluster-storage
fstype: glusterfs
opts: "defaults,_netdev"
state: mounted