diff --git a/collections/requirements.yml b/collections/requirements.yml index 549c67c..32e141b 100644 --- a/collections/requirements.yml +++ b/collections/requirements.yml @@ -1,5 +1,5 @@ --- collections: -- name: ansible.tower -- name: ansible.controller -- name: community.general + - name: ansible.tower + - name: ansible.controller + - name: community.general diff --git a/getservicecreds.yml b/getservicecreds.yml index f1bef4a..e932719 100644 --- a/getservicecreds.yml +++ b/getservicecreds.yml @@ -1,65 +1,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: 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: 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] }}'" +- name: Display AWS Key and Secret + debug: + msg: + - "AWS ACCESS KEY: '{{ aws_access_key[:-1] }}'" + - "AWS SECRET KEY: '{{ aws_access_secret[:-1] }}'" diff --git a/getserviceinfo.yml b/getserviceinfo.yml index e905107..fdeae23 100644 --- a/getserviceinfo.yml +++ b/getserviceinfo.yml @@ -3,7 +3,7 @@ --- - name: Get Service info hosts: localhost - gather_facts: False + gather_facts: false tasks: - name: Query Service Request Template for RHPDS Tasks uri: @@ -57,7 +57,6 @@ set_fact: aws_access_secret_temp: "{{ moreattributes.json.custom_attributes|json_query(_query) }}" - - name: Debug Query debug: msg="{{moreattributes.json.custom_attributes|json_query(jquery)}}" vars: @@ -71,6 +70,6 @@ - name: Display AWS Key and Secret debug: - msg: - - "AWS ACCESS KEY: {{aws_access_key[:-1]}}" - - "AWS SECRET KEY: {{aws_access_secret[:-1]}}" + msg: + - "AWS ACCESS KEY: {{aws_access_key[:-1]}}" + - "AWS SECRET KEY: {{aws_access_secret[:-1]}}" diff --git a/orderservice.yml b/orderservice.yml index 432bea5..aaebe4d 100644 --- a/orderservice.yml +++ b/orderservice.yml @@ -1,52 +1,52 @@ --- - name: Spinup RHPDS AWS Blank Enviornment hosts: all - gather_facts: False + gather_facts: false vars: tower_un: "{{ lookup('env', 'TOWER_USERNAME') }}" tasks: - - name: 'Preflight Varible check :: rhpdsurl' + - name: "Preflight Varible check :: rhpdsurl" fail: msg='Please include the rhpdsurl to the variable "rhpdsurl" or create Custom Crediental for it' run_once: true - when: 'rhpdsurl is not defined' - - name: 'Preflight Varible check :: rhpdsuser' + when: rhpdsurl is not defined + - name: "Preflight Varible check :: rhpdsuser" fail: msg='Please include the rhpdsuser to the variable "rhpdsuser" or create Custom Crediental for it' run_once: true - when: 'rhpdsuser is not defined' - - name: 'Preflight Varible check :: rhpdspass' + when: rhpdsuser is not defined + - name: "Preflight Varible check :: rhpdspass" fail: msg='Please include the rhpdspass to the variable "rhpdspass" or create Custom Crediental for it' run_once: true - when: 'rhpdspass is not defined' - - name: 'Preflight Varible check :: catalogitem' + 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' + 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}} " - # } }'' + # 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' + 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' + - 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' + - 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 != ""' + when: tower_un != "" - name: Request AWS OPEN Enviornment from Red Hat Open Environments {{ catalogitem }} from RHPDS uri: @@ -75,8 +75,8 @@ organization: "{{ org }}" state: present credential_type: Amazon Web Services - validate_certs: no + validate_certs: false inputs: username: "{{aws_access_key[:-1]}}" password: "{{aws_access_secret[:-1]}}" - when: 'tower_un != ""' + when: tower_un != ""