-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathportfolios.yml
66 lines (63 loc) · 1.95 KB
/
portfolios.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
58
59
60
61
62
63
64
65
66
---
- name: Create portfolio
uri:
url: https://cloud.redhat.com//api/catalog/v1.1/portfolios
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
body_format: json
body:
name: "{{ portfolio_name }}"
description: "{{ portfolio_desc }}"
register: createPortfolio
changed_when: "createPortfolio.status == 201"
failed_when:
- "createPortfolio.status == 401"
- "createPortfolio.status == 403"
- "createPortfolio.status == 500"
- name: Get portfolio
uri:
url: https://cloud.redhat.com//api/catalog/v1.1/portfolios?limit=5&filter[name]={{ portfolio_name | urlencode }}
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: GET
headers:
accept: "application/json"
register: portfolio
- name: Get service offerings
uri:
url: https://cloud.redhat.com/api/topological-inventory/v1.0/sources/{{ source.json.data[0].id }}/service_offerings?limit=5&filter[name]={{ job_template_name | urlencode }}
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: GET
headers:
accept: "application/json"
register: service
until: "service.json.meta.count > 0"
retries: 120
delay: 5
- name: Create portfolio item
uri:
url: https://cloud.redhat.com//api/catalog/v1.1/portfolio_items
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
body_format: json
body:
portfolio_id: "{{ portfolio.json.data[0].id }}"
service_offering_ref: "{{ service.json.data[0].id }}"
register: createPortfolioItem
changed_when: "createPortfolioItem.status == 201"
failed_when:
- "createPortfolioItem.status == 400"
- "createPortfolioItem.status == 401"
- "createPortfolioItem.status == 403"
- "createPortfolioItem.status == 404"