diff --git a/roles/bind-crc-apb/tasks/main.yml b/roles/bind-crc-apb/tasks/main.yml index 2851f8b..5ee3afe 100644 --- a/roles/bind-crc-apb/tasks/main.yml +++ b/roles/bind-crc-apb/tasks/main.yml @@ -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 }} @@ -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: @@ -31,7 +23,7 @@ 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 }}' @@ -39,15 +31,28 @@ 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: diff --git a/roles/deprovision-crc-apb/tasks/update_status.yml b/roles/bind-crc-apb/tasks/update_status.yml similarity index 100% rename from roles/deprovision-crc-apb/tasks/update_status.yml rename to roles/bind-crc-apb/tasks/update_status.yml diff --git a/roles/bind-crc-apb/vars/main.yml b/roles/bind-crc-apb/vars/main.yml new file mode 100644 index 0000000..68433e0 --- /dev/null +++ b/roles/bind-crc-apb/vars/main.yml @@ -0,0 +1,3 @@ +--- +SERVICE_NAME: '{{ _apb_provision_creds.SERVICE_NAME }}' +SERVICE_URI: '{{ _apb_provision_creds.SERVICE_URI }}' \ No newline at end of file diff --git a/roles/deprovision-crc-apb/tasks/main.yml b/roles/deprovision-crc-apb/tasks/main.yml index 6420776..6c485b1 100644 --- a/roles/deprovision-crc-apb/tasks/main.yml +++ b/roles/deprovision-crc-apb/tasks/main.yml @@ -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 }}' \ No newline at end of file + register: crc_configmap_deleted \ No newline at end of file diff --git a/roles/provision-crc-apb/tasks/main.yml b/roles/provision-crc-apb/tasks/main.yml index 5040a2d..2b2044d 100644 --- a/roles/provision-crc-apb/tasks/main.yml +++ b/roles/provision-crc-apb/tasks/main.yml @@ -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 }}' @@ -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 @@ -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 diff --git a/roles/unbind-crc-apb/tasks/main.yml b/roles/unbind-crc-apb/tasks/main.yml index ba7a024..98a0437 100644 --- a/roles/unbind-crc-apb/tasks/main.yml +++ b/roles/unbind-crc-apb/tasks/main.yml @@ -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 }}' diff --git a/roles/unbind-crc-apb/vars/main.yml b/roles/unbind-crc-apb/vars/main.yml new file mode 100644 index 0000000..0b53e57 --- /dev/null +++ b/roles/unbind-crc-apb/vars/main.yml @@ -0,0 +1,3 @@ +--- +SERVICE_NAME: '{{ _apb_provision_creds.SERVICE_NAME }}' +CLIENT_ID: '{{ _apb_bind_creds.CLIENT_ID }}' \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml index 7f9488d..c962a90 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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 \ No newline at end of file