-
Notifications
You must be signed in to change notification settings - Fork 2
/
sources.yml
144 lines (136 loc) · 3.95 KB
/
sources.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
- name: Create source
uri:
url: https://cloud.redhat.com//api/sources/v1.0/sources
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
body_format: json
body:
name: "{{ source_name }}"
source_type_id: "3"
register: createSource
changed_when: "createSource.status == 201"
failed_when:
- "createSource.status == 401"
- "createSource.status == 403"
- "createSource.status == 500"
- name: Get source
uri:
url: https://cloud.redhat.com//api/sources/v1.0/source_types/3/sources?limit=5&filter[name]={{ source_name | urlencode }}
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: GET
headers:
accept: "application/json"
register: source
failed_when:
- "source.status == 404"
- name: Create application
uri:
url: https://cloud.redhat.com//api/sources/v1.0/applications
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
body_format: json
body:
availability_status_error: "string"
source_id: "{{ source.json.data[0].id }}"
application_type_id: "1"
register: createApplication
changed_when: "createApplication.status == 201"
failed_when:
- "createApplication.status == 401"
- "createApplication.status == 403"
- "createApplication.status == 500"
- name: Create endpoint
uri:
url: https://cloud.redhat.com//api/sources/v1.0/endpoints
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
body_format: json
body:
default: true
host: "{{ tower_url }}"
path: "/"
port: "443"
role: "ansible"
scheme: "https"
verify_ssl: false
source_id: "{{ source.json.data[0].id }}"
register: createEndpoint
changed_when: "createEndpoint.status == 201"
failed_when:
- "createEndpoint.status == 401"
- "createEndpoint.status == 403"
- "createEndpoint.status == 500"
- name: Get endpoint
uri:
url: https://cloud.redhat.com//api/sources/v1.0/endpoints?limit=5&filter[host]={{ tower_url }}
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: GET
headers:
accept: "application/json"
register: endpoint
- name: Create authentication
uri:
url: https://cloud.redhat.com//api/sources/v1.0/authentications
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
body_format: json
body:
authtype: "username_password"
name: "Tower Password"
username: "{{ tower_username }}"
password: "{{ tower_password }}"
resource_type: "Endpoint"
resource_id: "{{ endpoint.json.data[0].id }}"
register: createAuthentication
changed_when: "createAuthentication.status == 201"
failed_when:
- "createAuthentication.status == 401"
- "createAuthentication.status == 403"
- "createAuthentication.status == 500"
- name: Run availability check
uri:
url: https://cloud.redhat.com//api/sources/v1.0/sources/{{ source.json.data[0].id }}/check_availability
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: POST
headers:
accept: "application/json"
register: availability
failed_when: "availability.status != 202"
- name: Wait for source to populate (may take 10-60 mins)
uri:
url: https://cloud.redhat.com/api/topological-inventory/v1.0/sources/{{ source.json.data[0].id }}/service_offerings
user: "{{ username }}"
password: "{{ password }}"
force_basic_auth: true
method: GET
headers:
accept: "application/json"
register: services
until:
- "services.status == 200"
- "services.json.meta.count > 0"
retries: 120
delay: 30