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?
Environment variable substitution is supported in both the great_expectations. yml and config variables config_variables.
kitchen. yml file is the main configuration file for kitchen. This file contains mainly 4 blocks driver, provisioner, platforms and suites. Driver: This is the name of driver that is used to create new node for testing. Provisioner: This is the chef provisioner to simulate test, chef-zero and chef-solo are the options.
Test Kitchen is Chef's integrated testing framework. It enables writing test recipes, which will run on the VMs once they are instantiated and converged using the cookbook. The test recipes run on that VM and can verify if everything works as expected. ChefSpec is something which only simulates a Chef run.
A converge will leave the machine running and kitchen automatically uploads changes each converge so that one can iterate rapidly on configuration code. A lot of time and effort has gone into ensuring that the exit code of kitchen is always appropriate.
You can use Erb formatting in your .kitchen.yml
:
provisioner:
name: chef-solo
attributes:
mycookbook:
mail_username: <%= ENV['MAIL_USERNAME'] %>
And then use node['mycookbook']['mail_username']
in your recipe to pass the value to the application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With