I am trying develop a cookbook to make a flask app work with gunicorn and nginx. I have been successful to the point that the app is running very well with a local sqlite database, see my cookbook at https://github.com/harrywang/flasky-cookbook. The flask app uses environment variables for sending emails such as: MAIL_USERNAME = os.environ.get('MAIL_USERNAME'), how I can pass those environment variables to the ubuntu virtual machines using test kitchen during kitchen converge?
There is no way to pass environment variables using .kitchen.yml configuration file (see test-kitchen/test-kitchen#662 issue).
I recommend you to set the environment variables in the gunicorn.conf.erb template using the --env
argument:
exec gunicorn --env SECRET_KEY=<%= @secret_key %> --env [...] --workers 3 --bind unix:<%= node['flasky-cookbook']['gunicorn_socket'] %> -m 007 --log-file <%= node['flasky-cookbook']['gunicorn_logfile']%> manage:app