forked from kshlm/gd2-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-devices.yml
38 lines (32 loc) · 1 KB
/
add-devices.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
---
- name: Add devices to GD2
hosts: kube-master[0]
gather_facts: false
vars:
kubectl: /usr/local/bin/kubectl
devices_list:
- /dev/vdb
- /dev/vdc
- /dev/vdd
tasks:
- name: Get glusterd2-client service
command: "{{ kubectl }} -ngcs -ojson get service glusterd2-client "
register: gd2_client_service
- name: Set gd2_client_endpoint
set_fact:
gd2_client_endpoint: "http://{{ (gd2_client_service.stdout|from_json).spec.clusterIP}}:24007"
cacheable: true
- name: Get peers in cluster
uri:
url: "{{ gd2_client_endpoint }}/v1/peers"
register: peers_resp
- name: Set gd2_peers fact
set_fact:
gd2_peers: "{{ peers_resp.json | json_query('[].id') }}"
- name: Register devices
uri:
method: POST
url: "{{ gd2_client_endpoint }}/v1/devices/{{ item.0 }}"
body: "{ \"device\": \"{{ item.1 }}\"}"
body_format: json
loop: "{{ query('nested', gd2_peers, devices_list)}}"