-
Notifications
You must be signed in to change notification settings - Fork 1
/
orderservice.yml
82 lines (80 loc) · 3.18 KB
/
orderservice.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
---
- name: Spinup RHPDS AWS Blank Enviornment
hosts: all
gather_facts: False
vars:
tower_un: "{{ lookup('env', 'TOWER_USERNAME') }}"
tasks:
- name: 'Preflight Varible check :: rhpdsurl'
fail: msg='Please include the rhpdsurl to the variable "rhpdsurl" or create Custom Credential for it'
run_once: true
when: 'rhpdsurl is not defined'
- name: 'Preflight Varible check :: rhpdsuser'
fail: msg='Please include the rhpdsuser to the variable "rhpdsuser" or create Custom Credential for it'
run_once: true
when: 'rhpdsuser is not defined'
- name: 'Preflight Varible check :: rhpdspass'
fail: msg='Please include the rhpdspass to the variable "rhpdspass" or create Custom Credential for it'
run_once: true
when: 'rhpdspass is not defined'
- name: 'Preflight Varible check :: catalogitem'
fail: msg='Please include the catalogitem to the variable "catalogitem"'
#Example: https://rhpds.redhat.com/api/v3.0.0/service_catalogs/'
run_once: true
when: 'catalogitem is not defined'
- name: 'Preflight Varible check :: rhpdsorder'
fail: msg='Please include the rhpdsorder to the variable "rhpdsorder"'
# Example '{ "action": "order", "resource": { "href":
# "https://rhpds.redhat.com/api/v3.0.0/service_templates/30000000000840",
# "check" : "t",
# "notes" : " {{notes}} "
# } }''
run_once: true
when: 'rhpdsorder is not defined'
- name: Check for Controller Username not blank
debug:
msg: "'{{ lookup('env', 'TOWER_USERNAME') }}'"
verbosity: 2
- name: 'Preflight Varible check :: for AWS Creds api'
block:
- name: 'Preflight Varible check :: Org'
fail: msg='Please include the Organization where the creds live to the variable "org"'
run_once: true
when: 'org is not defined'
- name: 'Preflight Varible check :: towercredname'
fail: msg='Please include the Creds to update or change to the variable "towercredname"'
run_once: true
when: 'towercredname is not defined'
run_once: true
when: 'tower_un != ""'
- name: Request AWS OPEN Enviornment from Red Hat Open Environments {{ catalogitem }} from RHPDS
uri:
url: "{{ rhpdsurl }}/api/v3.0.0/service_catalogs/{{ catalogitem }}/service_templates"
user: "{{ rhpdsuser }}"
password: "{{ rhpdspass }}"
method: POST
body: "{{ rhpdsorder }}"
body_format: json
register: requestinfo
#- name:
# debug:
# msg: "{{requestinfo.json.results[0].id}}"
- name: Set fact
set_fact:
serviceid: "{{ requestinfo.json.results[0].id }}"
- name: Show new fact
debug:
msg: "{{ serviceid }}"
verbosity: 2
- include: getservicecreds.yml
- name: Add RHPDS AWS Creds to Controller
ansible.controller.credential:
name: "{{ towercredname }}"
organization: "{{ org }}"
state: present
credential_type: Amazon Web Services
validate_certs: no
inputs:
username: "{{aws_access_key[:-1]}}"
password: "{{aws_access_secret[:-1]}}"
when: 'tower_un != ""'