-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable extending environment variables of Controller and Invoker #3689
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
Conversation
| controller_env: "{{ controller_env | default({}) | combine(item) }}" | ||
| with_items: "{{ extraEnvSets.split(',') | map('trim') | map('extract', vars)| list }}" | ||
| loop_control: | ||
| label: redacted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ansible would by default emit the item value to stdout. As the values may contain secrets set the label to a constant
Codecov Report
@@ Coverage Diff @@
## master #3689 +/- ##
==========================================
+ Coverage 75% 75.02% +0.01%
==========================================
Files 127 127
Lines 6030 6030
Branches 388 388
==========================================
+ Hits 4523 4524 +1
+ Misses 1507 1506 -1
Continue to review full report at Codecov.
|
| # license agreements; and to You under the Apache License, Version 2.0. | ||
|
|
||
| whisk_version_name: local | ||
| extraEnvSets: "{{ lookup('env', 'OPENWHISK_EXTRA_ENV_SETS')|default(false, true) }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not assume that is one top level set and force on both controller and invoker
Maybe user wants to set certain config or secret that is intended for controller but not invoker.
Or you want to set the same variable ie apikey to the db and is different for both controller and invoker.
What about having namespace with option to override
invoker:
extraEnv: "{{ invoker_extra_env | lookup('env', 'OPENWHISK_EXTRA_ENV') | default(false, true) }}"
controller:
extraEnv: "{{ controller_extra_env | lookup('env', 'OPENWHISK_EXTRA_ENV') | default(false, true) }}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Update PR to support specific env for controller and invoker. By default they both rely on OPENWHISK_EXTRA_ENV. However one can change the setting in environment specific file.
Not sure on best practices for placing the vars in ansible ... for now I have added them to local/group_vars/all such that one can use a different setting in specific env
ansible/environments/custom/group_vars
controller:
extraEnv: "cosmos,splunk"
|
Hey @chetanmeh please review the commit I just pushed fd35871 Now you are able to edit your own environment like You can do it like this ^^ or in your environment load an environment variable into the environment file, or override using |
|
@csantanapr I needed this support for travis specially. There I want to have a way where just with a env variable switch I can make test run against Cosmos. So earlier plan was to define pre configured env set in local cosmos:
CONFIG_whisk_spi_ArtifactStoreProvider: whisk.core.database.cosmosdb.CosmosDBArtifactStoreProvider
CONFIG_whisk_cosmosdb_endpoint : {{ lookup('env','COSMOSDB_ENDPOINT') }}
CONFIG_whisk_cosmosdb_key : "{{ lookup('env','COSMOSDB_KEY') }}"
CONFIG_whisk_cosmosdb_db : "{{ lookup('env','COSMOSDB_KEY') }}"These env variables would then be configured via travis ui. And then in cosmos db stage of travis set This way with minimal changes specific to Cosmos I can run test against it. Any pointers on how to achieve that with approach you proposed? |
|
to bring back the discussion offline with @chetanmeh He has a seperate PR for the Cosmos DB that will leverage this but adding a way to overload the spi for db in ansible in global group vars: Then in travis the |
|
PG 3 2312 🏃 |
| - name: merge extra env variables | ||
| set_fact: | ||
| controller_env: "{{ controller_env | default({}) | combine(controller.extraEnv) }}" | ||
| when: controller.extraEnv | default(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the when needed in the first place? Shouldn't we be able to specify: extraEnv: "{{ controller_extraEnv | default({}) }}" and run the combine step no matter what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed we need it the extra safety, your proposing just dropping the when line?
since in group_vars we already default to default({}) and extra check is not need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see define the default {} and then drop the when I will give this a test and update
|
PG1 2974 ⌛️ |
|
PG 1 2976 🔵 |
Provides a way to extend the environment variable set for Controller and Invoker
Description
As mentioned in #3477 for some set of deployments like those using CosmosDB we need to add some extra environment variables like
CONFIG_whisk_spi_ArtifactStoreProvider. To support that ansible playbook now supports add a set of environment variables conditionally.Usage
To add extra environment variables user need to define them under
group_vars/allfor specific environmentHere
cosmosis the name of the environment variable set related to CosmosDB. To enable this set user needs to set an environment vairableHere
OPENWHISK_EXTRA_ENVrefers to a comma separated list of environment variable set which need to be added. If configured then all variables defined undercosmoskey would be added to env of controller and invokerRelated issue and scope
My changes affect the following components
Types of changes
Checklist: