Skip to content

Commit

Permalink
Merge pull request #29 from aerogearcatalog/t_binding_log_and_fix
Browse files Browse the repository at this point in the history
Fix variables and log binding results
  • Loading branch information
psturc authored Jul 10, 2018
2 parents adad96c + 551b4c6 commit 445b7ee
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 33 deletions.
37 changes: 21 additions & 16 deletions roles/bind-crc-apb/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Retrieve {{ _apb_provision_creds.SERVICE_NAME }} configuration
- name: Retrieve {{ SERVICE_NAME }} configuration
shell: >
oc get configmaps/{{ crc_svc_config_alias }}
-n {{ namespace }}
Expand All @@ -11,18 +11,10 @@
register: crc_json_config_valid
ignore_errors: True

- block:
- asb_last_operation:
description: "config was not valid json. Could not bind"

- lineinfile:
line: 'config was not valid json. Could not bind'
path: '{{ crc_term_msg_filepath }}'
unsafe_writes: true

- fail:
msg: "config was not valid json. Could not bind"
when: crc_json_config_valid.failed
- import_tasks: update_status.yml
vars:
message: config was not valid json. Could not provision
result: '{{ crc_json_config_valid }}'

- name: Creating CRC {{ CLIENT_ID }} secret
k8s_v1_secret:
Expand All @@ -31,23 +23,36 @@
annotations:
configType: '{{ crc_svc_config_type }}'
labels:
name: '{{ _apb_provision_creds.SERVICE_NAME }}'
name: '{{ SERVICE_NAME }}'
mobile: '{{ crc_svc_label_mobile }}'
serviceName: '{{ crc_svc_name }}'
serviceInstanceID: '{{ _apb_service_instance_id }}'
clientId: '{{ CLIENT_ID }}'
mobile-client: '{{ crc_svc_label_mobile }}'
string_data:
type: '{{ crc_svc_type }}'
name: '{{ _apb_provision_creds.SERVICE_NAME }}'
uri: '{{ _apb_provision_creds.SERVICE_URI }}'
name: '{{ SERVICE_NAME }}'
uri: '{{ SERVICE_URI }}'
config: '{{ svc_json_config | to_nice_json }}'
register: crc_secrets_created

- import_tasks: update_status.yml
vars:
message: CRC {{ crc_client_secret_alias }} secret created. Continue...
result: '{{ crc_secrets_created }}'

- name: Encode {{ CLIENT_ID }} APB bind credentials
asb_encode_binding:
fields:
CLIENT_ID: "{{ CLIENT_ID }}"
when: encode_asb_binding
register: crc_encode_bindings

- import_tasks: update_status.yml
vars:
message: Successfully bound CRC
result: "{{ crc_encode_bindings }}"
when: encode_asb_binding

- name: Populate {{ CLIENT_ID }} APB bind credentials
set_fact:
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions roles/bind-crc-apb/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
SERVICE_NAME: '{{ _apb_provision_creds.SERVICE_NAME }}'
SERVICE_URI: '{{ _apb_provision_creds.SERVICE_URI }}'
12 changes: 1 addition & 11 deletions roles/deprovision-crc-apb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,9 @@
state: absent
register: crc_secret_deleted

- import_tasks: update_status.yml
vars:
message: 'CRC secret {{ crc_svc_config_alias }} deleted. Continue...'
result: '{{ crc_secret_deleted }}'

- name: Delete CRC configmap
k8s_v1_config_map:
name: '{{ crc_svc_config_alias }}'
namespace: '{{ namespace }}'
state: absent
register: crc_configmap_deleted

- import_tasks: update_status.yml
vars:
message: 'CRC configmap {{ crc_svc_config_alias }} deleted. Continue...'
result: '{{ crc_configmap_deleted }}'
register: crc_configmap_deleted
6 changes: 3 additions & 3 deletions roles/provision-crc-apb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

- name: Creating CRC {{ crc_svc_config_name }} secrets
k8s_v1_secret:
name: '{{ crc_svc_config_alias }}'
name: '{{ crc_svc_sercret_alias }}'
namespace: '{{ namespace }}'
labels:
name: '{{ SERVICE_NAME }}'
Expand All @@ -26,7 +26,7 @@

- import_tasks: update_status.yml
vars:
message: CRC {{ crc_svc_config_name }} secrets created. Continue...
message: CRC {{ crc_svc_sercret_alias }} secret created. Continue...
result: '{{ crc_secrets_created }}'

- name: Creating CRC {{ crc_svc_config_name }} configmap
Expand All @@ -49,7 +49,7 @@

- import_tasks: update_status.yml
vars:
message: CRC {{ crc_svc_config_name }} configmap created. Continue...
message: CRC {{ crc_svc_config_alias }} configmap created. Continue...
result: '{{crc_configmap_created }}'

- name: Encode {{ SERVICE_NAME }} APB provision credentials
Expand Down
2 changes: 1 addition & 1 deletion roles/unbind-crc-apb/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Delete CRC {{ _apb_bind_creds.CLIENT_ID }} configmap
- name: Delete CRC {{ CLIENT_ID }} configmap
k8s_v1_secret:
name: '{{ crc_client_config_alias }}'
namespace: '{{ namespace }}'
Expand Down
3 changes: 3 additions & 0 deletions roles/unbind-crc-apb/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
SERVICE_NAME: '{{ _apb_provision_creds.SERVICE_NAME }}'
CLIENT_ID: '{{ _apb_bind_creds.CLIENT_ID }}'
6 changes: 4 additions & 2 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ crc_svc_config_name: 'master'
crc_svc_config_type: 'json'
crc_svc_label_mobile: 'enabled'
crc_term_msg_filepath: '/dev/termination-log'
crc_svc_config_alias: '{{ SERVICE_NAME | lower }}-{{ crc_svc_config_name }}'
crc_client_config_alias: '{{ SERVICE_NAME | lower }}-{{ CLIENT_ID | lower }}'
crc_svc_sercret_alias: '{{ SERVICE_NAME | lower }}-{{ crc_svc_config_name }}'
crc_svc_config_alias: '{{ crc_svc_sercret_alias }}'
crc_client_secret_alias: '{{ SERVICE_NAME | lower }}-{{ CLIENT_ID | lower }}'
crc_client_config_alias: '{{ crc_client_secret_alias }}'
encode_asb_binding: yes

0 comments on commit 445b7ee

Please sign in to comment.