-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaybook.yml
55 lines (49 loc) · 1.74 KB
/
playbook.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
---
- name: Create Storidge Cluster
hosts: masters
become: true
gather_facts: False
tasks:
- name: get join token from active cluster
shell: >
cioctl join-token | awk '/cioctl node add/ {print $5}'
register: jointoken
- name: create cluster
shell: >
cioctl create --ip {{ private_ip }} | awk '/cioctl join/ {print $4}'
register: clustertoken
when: "jointoken.stdout == ''"
- name: Join Storidge Nodes
hosts: workers
become: true
gather_facts: False
vars:
clustertoken: "{{ hostvars[groups['masters'][0]]['clustertoken'] }}"
jointoken: "{{ hostvars[groups['masters'][0]]['jointoken'] }}"
master: "{{ hostvars[groups['masters'][0]]['private_ip'] }}"
tasks:
- name: check if already a cluster member
stat:
path: /etc/storidge/nodeid
register: nodeid
- name: join nodes to cio cluster
command: "cioctl join {{ master }} {{ clustertoken.stdout|default(jointoken.stdout) }} --ip {{ private_ip }}"
register: result
until: result.stdout.find("Adding this node") != -1
retries: 5
delay: 1
- name: Initialize Storidge Cluster
hosts: masters
become: true
gather_facts: False
vars:
clustertoken: "{{ hostvars[groups['masters'][0]]['clustertoken'] }}"
tasks:
- name: cioctl init
command: "cioctl init {{ clustertoken.stdout.split('-')[1] }}"
register: clusterinit
when: "clustertoken is not skipped"
- name: show cluster init output
debug: var=clusterinit.stdout
- name: show cluster init error
debug: var=clusterinit.stderr #can put copies of this debug under blocks like "tasks" to debug things