-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendpoint-domains.yml
57 lines (51 loc) · 1.46 KB
/
endpoint-domains.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
---
- hosts: localhost
collections:
- netapp.storagegrid
vars_files:
vars/defaults.yml
gather_facts: no
tasks:
- name: Retrieve SG auth token
uri:
url: "{{ sgadmin_url }}/api/v3/authorize"
method: POST
body: {
"username": "{{ sgadmin_user }}",
"password": "{{ sgadmin_pwd }}",
"cookie": false,
"csrfToken": false
}
body_format: json
validate_certs: false
register: gridauth
tags: gridauth
- name: Gather facts from GRID
netapp.storagegrid.na_sg_grid_info:
api_url: "{{ sgadmin_url }}"
auth_token: "{{ gridauth.json.data }}"
validate_certs: false
gather_subset:
- grid/domain-names
register: grid_domain_info
- name: Save GRID facts to YAML file
delegate_to: localhost
copy:
content: "{{ grid_domain_info | to_nice_yaml }}"
dest: "./grid_sg_net_facts.yml"
- name: Merge list of domains
set_fact:
new_domain_list: "{{ (grid_domain_info['sg_info']['grid/domain-names'].data + [newdomain] ) |unique|list }}"
- name: Add a new domain via REST API call
uri:
url: "{{ sgadmin_url }}/api/v3/grid/domain-names"
method: PUT
body_format: json
headers:
Authorization: "{{ gridauth.json.data }}"
body: "{{ new_domain_list }}"
validate_certs: false
register: net_response
tags: netadd
when: newdomain not in grid_domain_info['sg_info']['grid/domain-names'].data
...