-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetservicecreds.yml
65 lines (63 loc) · 2.46 KB
/
getservicecreds.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
---
- name: Query Service Request Template for RHPDS Tasks
uri:
url: "{{ rhpdsurl }}/api/v3.0.0/service_requests/{{serviceid}}?expand=request_tasks"
user: "{{ rhpdsuser }}"
password: "{{ rhpdspass }}"
method: GET
register: serviceexpanded
until: serviceexpanded.json.request_state == "finished"
retries: 60
delay: 30
#- name: Show all output
# debug:
# msg: "{{serviceexpanded}}"
- name: Debug Task ID
debug:
msg: "{{serviceexpanded.json.request_tasks[0].id}}"
verbosity: 2
- name: Debug Task URI request
debug:
msg: "{{serviceexpanded.json.request_tasks[0].href}}"
- name: Query Service Template for (ServiceID)
uri:
url: "{{ serviceexpanded.json.request_tasks[0].href }}"
user: "{{ rhpdsuser }}"
password: "{{ rhpdspass }}"
method: GET
register: taskinformation
#- name: Task options
# debug:
# msg: "{{taskinformation.json.options.dialog}}"
- name: Debug Service ID
debug:
msg: "{{taskinformation.json.options.dialog['Service::Service']}}"
verbosity: 2
- name: Query Service {{taskinformation.json.options.dialog['Service::Service']}} for Custom Attributes)
uri:
url: "{{ rhpdsurl }}/api/v3.0.0/services/{{taskinformation.json.options.dialog['Service::Service']}}?attributes=custom_attributes"
user: "{{ rhpdsuser }}"
password: "{{ rhpdspass }}"
method: GET
register: moreattributes
- name: Searching project for AWS ACCESS KEY
vars:
_query: "[?name ==`Environment Info 004`].value"
set_fact:
aws_access_key_temp: "{{ moreattributes.json.custom_attributes|json_query(_query) }}"
- name: Searching project for AWS SECRET KEY
vars:
_query: "[?name ==`Environment Info 005`].value"
set_fact:
aws_access_secret_temp: "{{ moreattributes.json.custom_attributes|json_query(_query) }}"
- name: Clean up Variables
set_fact:
#aws_access_key: "{{ aws_access_key_temp[19:39] }}"
#aws_access_secret: "{{ aws_access_secret_temp[24:64] }}"
aws_access_key: "{{ aws_access_key_temp[0] | split(' ') | last }}"
aws_access_secret: "{{ aws_access_secret_temp[0] | split(' ') | last }}"
- name: Display AWS Key and Secret
debug:
msg:
- "AWS ACCESS KEY: '{{ aws_access_key[:-1] }}'"
- "AWS SECRET KEY: '{{ aws_access_secret[:-1] }}'"