-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-src-site.yaml
More file actions
46 lines (40 loc) · 1.18 KB
/
create-src-site.yaml
File metadata and controls
46 lines (40 loc) · 1.18 KB
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
---
- name: Make HTTP POST request to create a site
hosts: localhost
gather_facts: no
vars_files:
- vars/env/extravars
tasks:
- name: Create source site
uri:
url: "https://snapcenter.cloudmanager.cloud.netapp.com/api/vmdr/sites"
method: post
return_content: yes
headers:
Content-Type: "application/json"
x-agent-id: "{{ agentid }}"
Authorization: "{{ authorization }}"
x-account-id: "{{ accountid }}"
body: >
{
"name": " {{ srcsitename }} ",
"region": "",
"type": "onprem"
}
body_format: json
status_code: [200, 202, 201]
register: result
- name: Setting src_site value.
ansible.builtin.set_fact:
src_site: "{{ result }}"
- name: Save the variable to a file
ansible.builtin.copy:
content: "{{ src_site | to_json }}"
dest: ./vars/src_site.json
- name: Use the variable file
ansible.builtin.include_vars:
file: ./vars/src_site.json
name: src_site
- name: Get the site ID
ansible.builtin.debug:
msg: "{{ src_site.json.id }}"