ansible-community / ara

ARA Records Ansible and makes it easier to understand and troubleshoot.
https://ara.recordsansible.org
GNU General Public License v3.0
1.87k stars 173 forks source link

How to use ARA_ALLOWED_HOSTS with Dynaconf. #108

Closed LaurentDumont closed 4 years ago

LaurentDumont commented 4 years ago

What component is this about ?

This is about ara-api

What is your ARA installation like ?

(venv) ldumont@smallpotato:~/projects/ara-ansible$ uname -a
Linux smallpotato 5.0.0-37-generic #40-Ubuntu SMP Thu Nov 14 00:14:01 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

(venv) ldumont@smallpotato:~/projects/ara-ansible$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.04
Release:    19.04
Codename:   disco

(venv) ldumont@smallpotato:~/projects/ara-ansible$ pip list | grep -i ara
ara                 1.3.2    

Launching the server with

ara-manage runserver 0.0.0.0:8000

What is happening ?

Working - Setup with the settings.yaml image

Rendered Django variable value image

NOT WORKING - using ARA_ALLOWED_HOSTS value

image

image

We can see that the Django variable is changed but the format is quite different from when the values are pulled from `settings.yaml.

I've tried a few other variations on the Env variable syntax but nothing seems to stick.

Let me know if anything else is required.

dmsimard commented 4 years ago

Hi @LaurentDumont and thanks for the report !

I think we can improve the docs for this. There's https://ara.readthedocs.io/en/latest/api-configuration.html#ara-allowed-hosts but no sample command like CORS_ORIGIN_WHITELIST.

So export ARA_ALLOWED_HOSTS="['foo', 'bar']" should work but I would recommend using the settings.yaml file if you can :)

The ara_api role templates out the settings.yaml without the special Box syntax and it works fine, for example: https://c1f15c8f942fddd39694-f73785700cacef583f29e4dcac8fae98.ssl.cf2.rackcdn.com/703223/2/check/ansible-role-ara-api-ubuntu-postgresql/db366bb/logs/server/settings.yaml

The role is used to deploy the live demo: https://github.com/ansible-community/ara-infra/blob/master/playbooks/live-demo.yaml

I did open an issue on the dynaconf repository about what to do with those and I have a fix I need to try: https://github.com/rochacbruno/dynaconf/issues/257

LaurentDumont commented 4 years ago

Hi!

Awesome, just tested and it works. I think I tried all other combination but that one!

We wanted to use ENV variables to make containers creation a bit more simple. I could just pass what is required and not worry about templating a file or generating something first. We are currently looking at ARA to alleviate some of our issues with RH-OSP verbosity during Overcloud/Undercloud deployments. I'm just not sure how ARA is going to cope as an Overcloud deployment is generating about 100MB worth of text files.

Thanks again for your help, I'll get a PR for the docs stuff.

LaurentDumont commented 4 years ago

Btw, I think that the API demo is down :(

image

dmsimard commented 4 years ago

Awesome, just tested and it works. I think I tried all other combination but that one!

:tada:

We wanted to use ENV variables to make containers creation a bit more simple. I could just pass what is required and not worry about templating a file or generating something first.

Sure. Some configurations (logging comes to mind) might not be realistic over environment variables though.

We are currently looking at ARA to alleviate some of our issues with RH-OSP verbosity during Overcloud/Undercloud deployments. I'm just not sure how ARA is going to cope as an Overcloud deployment is generating about 100MB worth of text files.

I don't know about your specific use case but I know TripleO already leverages ARA (although still on 0.x) for CI, for example:

Thanks again for your help, I'll get a PR for the docs stuff.

Very cool! I've added a comment in https://review.opendev.org/#/c/703245/ and we can merge it soon.

dmsimard commented 4 years ago

Btw, I think that the API demo is down :(

Might have been a temporary blip, I've tested from different locations and it's up for me. Thanks for looking out though !

LaurentDumont commented 4 years ago

Awesome, just tested and it works. I think I tried all other combination but that one!

🎉

We wanted to use ENV variables to make containers creation a bit more simple. I could just pass what is required and not worry about templating a file or generating something first.

Sure. Some configurations (logging comes to mind) might not be realistic over environment variables though.

We are currently looking at ARA to alleviate some of our issues with RH-OSP verbosity during Overcloud/Undercloud deployments. I'm just not sure how ARA is going to cope as an Overcloud deployment is generating about 100MB worth of text files.

I don't know about your specific use case but I know TripleO already leverages ARA (although still on 0.x) for CI, for example:

Thanks again for your help, I'll get a PR for the docs stuff.

Very cool! I've added a comment in https://review.opendev.org/#/c/703245/ and we can merge it soon.

It looks integrated into TripleO but not with the Red Hat Openstack Platform Product. At least, not when we checked before implementing ARA into our workflow.

We might end up templating the settings.yaml, baking it into the container, pushing that image and just running the image itself without injecting anything at run-time. I'll close this for now as my original question was covered (super quickly too! Merci!)

dmsimard commented 4 years ago

@LaurentDumont FYI I've merged a change in master to address the odd box syntax in the default settings file: https://github.com/ansible-community/ara/commit/df3bace703ea0c8bc3cbf6946444848c4cfaa61d