Skip to content

[patch] Require RSL secret name as API parameter #1742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: aib2op
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ibm/mas_devops/roles/aibroker_tenant/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ mas_aibroker_provision_tenant: "{{ lookup('env', 'MAS_AIBROKER_PROVISION_TENANT'
mas_aibroker_dro_token_secret: "{{ mas_aibroker_tenant_name }}----dro-secret"
mas_aibroker_dro_tenant_id: "{{ lookup('env', 'MAS_AIBROKER_DRO_TENANT_ID') | default('001', true) }}"

# RSL
mas_aibroker_rsl_token_secret: "{{ mas_aibroker_tenant_name }}----rsl-secret"

# SLS
mas_aibroker_sls_secret: "{{ mas_aibroker_tenant_name }}----sls-secret"
mas_aibroker_sls_subscription_id: "{{ lookup('env', 'MAS_AIBROKER_SLS_SUBSCRIPTION_ID') | default('001', true) }}"
36 changes: 36 additions & 0 deletions ibm/mas_devops/roles/aibroker_tenant/tasks/rsl/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- name: Read rsl config from environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency I would write "rsl" in capital letters here in the human-readable message.

ansible.builtin.set_fact:
rslcfg:
url: "{{ lookup('env', 'RSL_URL') }}"
rsl_token: "{{ lookup('env', 'RSL_TOKEN') }}"
org_id : "{{ lookup('env', 'RSL_ORG_ID') }}"


- name: "Debug: rsl information" #TODO: remove before PR
debug:
msg:
- "rsl url ................. {{ rslcfg.url }}"
- "rsl token ............. {{ rslcfg.rsl_token }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not print the secret token value.

- "rsl org id .............. {{ rslcfg.org_id }}"


- name: "Validate rsl configuration"
when: rslcfg.url | length == 0
fail:
msg: "rslcfg.url must not empty"

- name: "Validate rsl configuration"
when: rslcfg.rsl_token | length == 0
fail:
msg: "rslcfg.rsl_token must not empty"

- name: "Validate rsl configuration"
when: rslcfg.org_id | length == 0
fail:
msg: "rslcfg.org_id must not empty"

- name: Create rsl secret
kubernetes.core.k8s:
state: present
namespace: "{{ aibroker_namespace }}"
template: "templates/rsl/rsl-secret.yml.j2"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ spec:
url: "{{ drocfg.url }}"
secretName: "{{ mas_aibroker_dro_token_secret }}"
ca: "{{ drocfg.ca }}"

rsl:
url: "{{ rslcfg.url }}"
token : "{{ rslcfg.rsl_token }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The token should not be included here as it is a secret value. There should be a field called secretName whose value is {{ mas_aibroker_rsl_token_secret }}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field names also need to match those in https://github.ibm.com/maximoappsuite/ibm-mas-aibroker/pull/156

orgId: "{{ rslcfg.org_id }}"

sls:
url: "{{ slscfg.url }}"
secretName: "{{ mas_aibroker_sls_secret }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
kind: Secret
apiVersion: v1
type: Opaque
metadata:
name: {{ mas_aibroker_rsl_token_secret }}
namespace: {{ aibroker_namespace }}
labels:
mas.ibm.com/applicationId: aibroker
mas.ibm.com/instanceId: "{{ mas_instance_id }}"
{% if custom_labels is defined and custom_labels.items() %}
{% for key, value in custom_labels.items() %}
"{{ key }}": "{{ value }}"
{% endfor %}
{% endif %}
data:
RSL_TOKEN: "{{ rslcfg.registration_key | b64encode }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registration_key is not the correct name of the variable

Loading