-
Notifications
You must be signed in to change notification settings - Fork 9
/
testCAS.yml
53 lines (44 loc) · 1.19 KB
/
testCAS.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
---
- hosts: localhost
tasks:
- name: Create Token
uri:
url: https://api.mgmt.cloud.vmware.com/iaas/login
method: POST
return_content: yes
body:
refreshToken: 78b07539-89a5-4c4a-885d-a444bb08e4cb
body_format: json
register: create_token
- set_fact:
token: "{{ 'Bearer ' + create_token.json.token }}"
- name: Log token
debug: var=token
- name: Get Projects
uri:
url: https://api.mgmt.cloud.vmware.com/iaas/projects
method: GET
return_content: yes
headers:
Authorization: "{{ token }}"
register: projects
- name: Log projects
debug: var=projects.json.content
- set_fact:
project_exists: "{{ lookup('template', './testCAS.yml.j2') }}"
- name: Log result
debug: var=project_exists
- name: Create Project
uri:
url: https://api.mgmt.cloud.vmware.com/iaas/projects
method: POST
return_content: yes
headers:
Authorization: "{{ token }}"
body: "{{ lookup('file','project.json') }}"
body_format: json
register: create_project
when: not project_exists
- name: Log New Project
debug: var=create_project
when: not project_exists