cookbook 'application_python', '~> 4.0.0'
application_python (14) Versions 4.0.0 Follow53
A Chef cookbook for deploying Python application code.
cookbook 'application_python', '~> 4.0.0', :supermarket
knife supermarket install application_python
knife supermarket download application_python
Application_Python Cookbook
A Chef cookbook to deploy Python applications.
Quick Start
To deploy a Django application from git:
application '/srv/myapp' do git 'https://github.com/example/myapp.git' virtualenv pip_requirements django do database 'sqlite:///test_django.db' secret_key 'd78fe08df56c9' migrate true end gunicorn do port 8000 end end
Requirements
Chef 12 or newer is required.
Resources
application_celery_beat
The application_celery_beat
resource creates a service for the celery beat
process.
application '/srv/myapp' do celery_beat do app_module 'myapp.tasks' end end
Actions
-
:enable
– Create, enable and start the service. (default) -
:disable
– Stop, disable, and destroy the service. -
:start
– Start the service. -
:stop
– Stop the service. -
:restart
– Stop and then start the service. -
:reload
– Send the configured reload signal to the service.
Properties
-
path
– Base path for the application. (name attribute) -
app_module
– Celery application module. (default: auto-detect) -
service_name
– Name of the service to create. (default: auto-detect) #user
– User to run the service as. (default: application owner)
application_celery_config
The application_celery_config
creates a celeryconfig.py
configuration file.
application '/srv/myapp' do celery_config do options do broker_url 'amqp://' end end end
Actions
-
:deploy
– Create the configuration file. (default)
Properties
-
path
– Path to write the configuration file to. If given as a directory, createpath/celeryconfig.py
. (name attribute) -
options
– Hash or block of options to set in the configuration file.
application_celery_worker
The application_celery_worker
resource creates a service for the
celery worker
process.
application '/srv/myapp' do celery_worker do app_module 'myapp.tasks' end end
Actions
-
:enable
– Create, enable and start the service. (default) -
:disable
– Stop, disable, and destroy the service. -
:start
– Start the service. -
:stop
– Stop the service. -
:restart
– Stop and then start the service. -
:reload
– Send the configured reload signal to the service.
Properties
-
path
– Base path for the application. (name attribute) -
app_module
– Celery application module. (default: auto-detect) -
service_name
– Name of the service to create. (default: auto-detect) #user
– User to run the service as. (default: application owner)
application_django
The application_django
resource creates configuration files and runs commands
for a Django application deployment.
application '/srv/myapp' do django do database 'sqlite:///test_django.db' migrate true end end
Actions
-
:deploy
– Create config files and run required deployments steps. (default)
Properties
-
path
– Base path for the application. (name attribute) -
allowed_hosts
– Value forALLOWED_HOSTS
in the Django settings. (default: []) -
collectstatic
– Runmanage.py collectstatic
during deployment. (default: true) -
database
– Database settings for the default connection. See the database section below for more information. (option collector) -
debug
– Enable debug mode for Django. (default: false) -
local_settings
– A Poise template property for the content of the local settings configuration file. -
local_settings_path
– Path to write local settings to. If given as a relative path, will be expanded against path. Set to false to disable writing local settings. (default: local_settings.py next to settings_module) -
migrate
– Runmanage.py migrate
during deployment. (default: false) -
manage_path
– Path tomanage.py
. (default: auto-detect) -
secret_key
– Value forSECRET_KEY
in the Django settings. If unset, no key is added to the local settings. -
settings_module
– Django settings module in dotted notation. (default: auto-detect) -
syncdb
– Runmanage.py syncdb
during deployment. (default: false) -
wsgi_module
– WSGI application module in dotted notation. (default: auto-detect)
Database Parameters
The database parameters can be set in three ways: URL, hash, and block.
If you have a single URL for the parameters, you can pass it directly to
database
:
django do database 'postgres://myuser@dbhost/myapp' end
Passing a single URL will also set the $DATABASE_URL
environment variable
automatically for compatibility with Heroku-based applications.
As with other option collector resources, you can pass individual settings as
either a hash or block:
django do database do engine 'postgres' user 'myuser' host 'dbhost' name 'myapp' end end django do database({ engine: 'postgres', user: 'myuser', host: 'dbhost', name: 'myapp', }) end
application_gunicorn
The application_gunicorn
resource creates a service for the
Gunicorn application server.
application '/srv/myapp' do gunicorn do port 8000 preload_app true end end
Actions
-
:enable
– Create, enable and start the service. (default) -
:disable
– Stop, disable, and destroy the service. -
:start
– Start the service. -
:stop
– Stop the service. -
:restart
– Stop and then start the service. -
:reload
– Send the configured reload signal to the service.
Properties
-
path
– Base path for the application. (name attribute) -
app_module
– WSGI module to run as an application. (default: auto-detect) -
bind
– One or more addresses/ports to bind to. -
config
– Path to a Guncorn configuration file. -
preload_app
– Enable code preloading. (default: false) -
port
– Port to listen on. Alias forbind("0.0.0.0:#{port}")
. -
service_name
– Name of the service to create. (default: auto-detect) #user
– User to run the service as. (default: application owner) -
version
– Version of Gunicorn to install. If set to true, use the latest version. If set to false, do not install Gunicorn. (default: true)
application_pip_requirements
The application_pip_requirements
resource installs Python packages based on a
requirements.txt
file.
application '/srv/myapp' do pip_requirements end
All actions and properties are the same as the pip_requirements
resource.
application_python
The application_python
resource installs a Python runtime for the deployment.
application '/srv/myapp' do python '2.7' end
All actions and properties are the same as the python_runtime
resource.
application_python_execute
The application_python_execute
resource runs Python commands for the deployment.
application '/srv/myapp' do python_execute 'setup.py install' end
All actions and properties are the same as the python_execute
resource,
except that the cwd
, environment
, group
, and user
properties default to
the application-level data if not specified.
application_python_package
The application_python_package
resource installs Python packages for the deployment.
application '/srv/myapp' do python_package 'requests' end
All actions and properties are the same as the python_package
resource,
except that the group
and user
properties default to the application-level
data if not specified.
application_virtualenv
The application_virtualenv
resource creates a Python virtualenv for the
deployment.
application '/srv/myapp' do virtualenv end
If no path property is given, the default is to create a .env/
inside the
application deployment path.
All actions and properties are the same as the python_virtualenv
resource.
Examples
Some test recipes are available as examples for common application frameworks:
Sponsors
Development sponsored by Chef Software, Symonds & Son, and Orion.
The Poise test server infrastructure is sponsored by Rackspace.
License
Copyright 2015, Noah Kantrowitz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Dependent cookbooks
poise ~> 2.0 |
application ~> 5.0 |
poise-python ~> 1.0 |
poise-service ~> 1.0 |
Contingent cookbooks
Application_Python Changelog
v4.0.0
- Massive rewrite on top of newer Chef patterns. See the 4.0 README for details.
v3.0.0
- Drop support for Chef 10.
- COOK-2212 - autostart when server reboots.
-
COOK-3432 - Use
Chef::DSL::IncludeRecipe
becauseChef::Mixin::LanguageIncludeRecipe
is deprecated.
v2.0.4
- Revert changes that broke backwards compatibility.
v2.0.2
- This release did not follow semver and was reverted in 2.0.4!
-
COOK-3432 - Use
Chef::DSL::IncludeRecipe
becauseChef::Mixin::LanguageIncludeRecipe
is deprecated.
v2.0.0
- [COOK-3306]: Multiple Memory Leaks in Application Cookbook.
v1.2.4
- [COOK-2747]: celerycam configuration is not suitable for multiple node celery installation.
- [COOK-2766]: pip does not use
deploy_key
in django ressource ofapplication_python
.
v1.2.2
- [COOK-2796]: celery provider tries to case switch on 'queue' parameter instead of 'queues' parameter.
v1.2.0
- [COOK-2611]: Celery LWRP should configure which queues a celeryd worker binds to.
- [COOK-2599]: gunicorn provider fails if no
node['cpu']['total']
.
v1.1.0
- [COOK-2330] - celeryconfig.py.erb tries to use non-existant String#upper method
- [COOK-2337] - It should be possible to pass environment variables through to gunicorn and celery supervisor configs
- [COOK-2403] - cookbook attribute expects argument to be a string.
- [COOK-2453] - application_python should allow the working directory of gunicorn processes to be set via an attribute.
- [COOK-2475] - celerybeat supervisor process is unnecessarily configured.
- [COOK-2484] - virtualenv and requirements are installed as root instead of uid/gid specified by application properties.
v1.0.8
- [COOK-2175] - Template cookbook attribute expecting a stringg getting symbol instead.
v1.0.6
- [COOK-2122] - pip was incorrectly using -E syntax.
- [COOK-2147] - django sub-resource searched wrong directory for requirements.txt.
v1.0.4
- [COOK-2042] - gunicorn LWRP support for virtualenv, deps.
v1.0.2
- [COOK-1420] - template resource source cookbook is wrong.
- [COOK-1421] - pip using old -E syntax.
- [COOK-1422] - syncdb using --migrate option.
- [COOK-1477] - pip requirements.txt and editable package support.
v1.0.0
- [COOK-1246] - Initial release - relates to COOK-634.
Collaborator Number Metric
4.0.0 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
4.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
4.0.0 passed this metric
No Binaries Metric
4.0.0 passed this metric
Testing File Metric
4.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
4.0.0 passed this metric
4.0.0 failed this metric
4.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
4.0.0 passed this metric
No Binaries Metric
4.0.0 passed this metric
Testing File Metric
4.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
4.0.0 passed this metric
4.0.0 passed this metric
4.0.0 passed this metric
Testing File Metric
4.0.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
4.0.0 passed this metric
4.0.0 failed this metric
4.0.0 passed this metric