Configure ACA-py via Environment Variables
Hi there,
The documentation states that ACA-py can be configured via Environment Variables and that all command line arguments have an ENV equivalent.
I have converted all my CLI arguments into ConfigMaps and Secrets in Kubernetes and am loading them appropriately, however when starting the instance it has the following error:
aca-py start: error: argument --admin: expected 2 arguments
The environment variable is this ACAPY_ADMIN : 0.0.0.0 11000.
I got all the environment variable names from The Arg Parser
I start ACA-py in the following manner:
containers:
- name: acapy
image: bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc1
command: ["/bin/bash"]
args: ["-c", "aca-py start"]
I have omitted the rest of the Deployment manifest for brevity.
Am I doing something wrong?
@ianco or @amanji — can one of you take a quick look at this one? Seems like it should be easy enough to see if you know where to look.
I'm not sure off the top of my head but there's a yaml example in the demo folder:
https://github.com/hyperledger/aries-cloudagent-python/blob/main/demo/demo-args.yaml
I did a quick google and found this (we use the configargparse library):
https://stackoverflow.com/questions/63213005/argparse-multiple-values-with-options
Do the arguments need to be comma-separated or in an array format?
ACA-Py uses ConfigArgParse to consume the env var startup params. It can be a little tricky understanding the syntax that's expected sometimes, but in general it's expecting python serialized lists and arrays when more than one value is expected.
Example loading plugins with the env vars:
ACAPY_PLUGIN=[redis_events.v1_0.redis_queue.events, firebase_push_notifications]
Cool — thanks @WadeBarnes . There is your answer @Executioner1939. If you can think of where it would have helped to have that documented, a documentation PR would be appreciated.
@WadeBarnes @swcurran @ianco thank you very much, I didn't know that at all, I appreciate the help :-)
I will try and make a documentation PR tomorrow!
I am sorry to have to bug you again, but I am once again stuck. The fixes suggested above work, when I specify --admin as ACAPY_ADMIN : [0.0.0.0, 11000]; the initial error disappears.
But now it seems the issue is the with -it / --inbound-transports and I suspect it could be because of the action="append" which is the only difference I can see between the two argument parsers, as this can also contain multiple transports like http and ws.
I have tried multiple combinations but I still get aca-py start: error: argument -it/--inbound-transport: expected 3 arguments
Again, sorry about the follow up, I am just trying to get this deployed before work starts tomorrow :-)
cc @swcurran @WadeBarnes
The ACAPY_PLUGIN argument has the same action="append" pattern, which basically means you can specify the flag/argument many times. So, that indicates the outer structure would be an array/list. Each instance of inbound-transport is expecting three arguments metavar=("<module>", "<host>", "<port>"), so I would think this would need to be a list too.
I've struggled with this myself and have not looked at it closely in a while. I don't think I've got it working and instead specify the settings via the command line argument --inbound-transport.
Can you provide some examples of what you've tried?
I'm thinking it needs to be something like (but I have not tested this example):
ACAPY_INBOUND_TRANSPORT=[[http_module, http_host, http_port],[ws_module, ws_host, ws_port]]
Hi @WadeBarnes thank you for replying again, I tried the format you suggested as well as simply:
[module, host, port][(module, host, port)]"module, host, port"- just a sanity check
I may need to pass it as a command line argument, which I would prefer not to do so I can keep all configuration in ConfigMaps.
~I think more investigation will be need to determine the exact format needed for setting things like ACAPY_INBOUND_TRANSPORT.~ I do recall running across a bug in one version of ConfigArgParse that was causing issues for me at one point. Oh, and look at that, the answer we seek seems to be there; Upgrade ConfigArgParse to version 1.5.3
Example using the environment variable for --inbound-transport:
ACAPY_INBOUND_TRANSPORT=[[\"http\",\"0.0.0.0\",\"8021\"],[\"ws\",\"0.0.0.0\",\"8023\"]]
Awesome! That worked! Thank you @WadeBarnes , I would like to add some documentation for this, where would you recommend I add a small note about using Environment Variables?
This looks like a good spot; https://github.com/hyperledger/aries-cloudagent-python/blob/main/docs/features/DevReadMe.md#configuring-aca-py-command-line-parameters
Thanks @WadeBarnes I'll work on a PR tomorrow, and I'll mark this as closed for now :-).
Thank you for all the assistance everyone 👍🏻