poise-application-python 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.kitchen.travis.yml +9 -0
- data/.kitchen.yml +10 -0
- data/.travis.yml +20 -0
- data/.yardopts +3 -0
- data/Berksfile +35 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +37 -0
- data/LICENSE +201 -0
- data/README.md +334 -0
- data/Rakefile +17 -0
- data/SUPPORTERS.md +81 -0
- data/chef/templates/celeryconfig.py.erb +5 -0
- data/chef/templates/settings.py.erb +13 -0
- data/lib/poise_application_python.rb +23 -0
- data/lib/poise_application_python/app_mixin.rb +67 -0
- data/lib/poise_application_python/cheftie.rb +17 -0
- data/lib/poise_application_python/error.rb +25 -0
- data/lib/poise_application_python/resources.rb +26 -0
- data/lib/poise_application_python/resources/celery_beat.rb +43 -0
- data/lib/poise_application_python/resources/celery_config.rb +109 -0
- data/lib/poise_application_python/resources/celery_worker.rb +77 -0
- data/lib/poise_application_python/resources/django.rb +355 -0
- data/lib/poise_application_python/resources/gunicorn.rb +127 -0
- data/lib/poise_application_python/resources/pip_requirements.rb +47 -0
- data/lib/poise_application_python/resources/python.rb +57 -0
- data/lib/poise_application_python/resources/python_execute.rb +89 -0
- data/lib/poise_application_python/resources/python_package.rb +62 -0
- data/lib/poise_application_python/resources/virtualenv.rb +75 -0
- data/lib/poise_application_python/service_mixin.rb +57 -0
- data/lib/poise_application_python/version.rb +19 -0
- data/poise-application-python.gemspec +45 -0
- data/test/cookbooks/application_python_test/attributes/default.rb +17 -0
- data/test/cookbooks/application_python_test/metadata.rb +20 -0
- data/test/cookbooks/application_python_test/recipes/default.rb +83 -0
- data/test/cookbooks/application_python_test/recipes/django.rb +32 -0
- data/test/cookbooks/application_python_test/recipes/flask.rb +25 -0
- data/test/gemfiles/chef-12.gemfile +19 -0
- data/test/gemfiles/master.gemfile +27 -0
- data/test/integration/default/serverspec/default_spec.rb +81 -0
- data/test/integration/default/serverspec/django_spec.rb +56 -0
- data/test/integration/default/serverspec/flask_spec.rb +39 -0
- data/test/spec/app_mixin_spec.rb +69 -0
- data/test/spec/resources/celery_config_spec.rb +58 -0
- data/test/spec/resources/django_spec.rb +303 -0
- data/test/spec/resources/gunicorn_spec.rb +96 -0
- data/test/spec/resources/python_execute_spec.rb +46 -0
- data/test/spec/resources/python_spec.rb +44 -0
- data/test/spec/resources/virtualenv_spec.rb +44 -0
- data/test/spec/spec_helper.rb +19 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae45f83ad0604ee5c2b2f6e2776b2743d4263170
|
4
|
+
data.tar.gz: 3c0dba7480d9c0d4ba6c990a2f0c80bb9db47cf7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f64c9d4a23bcbff4608ba94d1d2a12132883099ddf7cc770b841b18bd23e5ad4a82063fe912e4f9895f242a06fd560ff3e7b73a31c17ada001c8d36eb5e40ded
|
7
|
+
data.tar.gz: 152e96cb0e17d32bbfb9ebf73b6db2c9b3178b554d0d3403f0feb768254cd869d459f92573d21fabe70a752573ba60ee39707e7d9c49e7268323996b274e11ed
|
data/.gitignore
ADDED
data/.kitchen.travis.yml
ADDED
data/.kitchen.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
sudo: false
|
2
|
+
cache: bundler
|
3
|
+
language: ruby
|
4
|
+
rvm:
|
5
|
+
- '2.2'
|
6
|
+
addons:
|
7
|
+
apt:
|
8
|
+
packages:
|
9
|
+
- libgecode-dev
|
10
|
+
env:
|
11
|
+
global:
|
12
|
+
- USE_SYSTEM_GECODE=true
|
13
|
+
- KITCHEN_LOCAL_YAML=.kitchen.travis.yml
|
14
|
+
- secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U=
|
15
|
+
bundler_args: "--binstubs=$PWD/bin --jobs 3 --retry 3"
|
16
|
+
script:
|
17
|
+
- "./bin/rake travis"
|
18
|
+
gemfile:
|
19
|
+
- test/gemfiles/chef-12.gemfile
|
20
|
+
- test/gemfiles/master.gemfile
|
data/.yardopts
ADDED
data/Berksfile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Noah Kantrowitz <noah@coderanger.net>
|
3
|
+
#
|
4
|
+
# Copyright 2013, Balanced, Inc.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
source 'https://supermarket.chef.io/'
|
20
|
+
extension 'halite'
|
21
|
+
|
22
|
+
# Force the rebuild every time for development.
|
23
|
+
cookbook 'poise', gem: 'poise'
|
24
|
+
cookbook 'application', gem: 'poise-application'
|
25
|
+
cookbook 'application_python', gem: 'poise-application-python'
|
26
|
+
cookbook 'poise-languages', gem: 'poise-languages'
|
27
|
+
cookbook 'poise-python', gem: 'poise-python'
|
28
|
+
cookbook 'poise-service', gem: 'poise-service'
|
29
|
+
|
30
|
+
group :test do
|
31
|
+
cookbook 'application_git', gem: 'poise-application-git'
|
32
|
+
cookbook 'application_python_test', path: 'test/cookbooks/application_python_test'
|
33
|
+
cookbook 'apt'
|
34
|
+
cookbook 'git'
|
35
|
+
end
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Application_Python Changelog
|
2
|
+
|
3
|
+
## v4.0.0
|
4
|
+
|
5
|
+
* Massive rewrite on top of newer Chef patterns. See the 4.0 README for details.
|
6
|
+
|
7
|
+
## v3.0.0
|
8
|
+
|
9
|
+
* Drop support for Chef 10.
|
10
|
+
* [COOK-2212](https://tickets.opscode.com/browse/COOK-2212) - autostart when server reboots.
|
11
|
+
* [COOK-3432](https://tickets.opscode.com/browse/COOK-3432) - Use `Chef::DSL::IncludeRecipe` because `Chef::Mixin::LanguageIncludeRecipe` is deprecated.
|
12
|
+
|
13
|
+
## v2.0.4
|
14
|
+
|
15
|
+
* Revert changes that broke backwards compatibility.
|
16
|
+
|
17
|
+
## v2.0.2
|
18
|
+
|
19
|
+
* **This release did not follow semver and was reverted in 2.0.4!**
|
20
|
+
* [COOK-3432](https://tickets.opscode.com/browse/COOK-3432) - Use `Chef::DSL::IncludeRecipe` because `Chef::Mixin::LanguageIncludeRecipe` is deprecated.
|
21
|
+
|
22
|
+
## v2.0.0
|
23
|
+
|
24
|
+
* [COOK-3306]: Multiple Memory Leaks in Application Cookbook.
|
25
|
+
|
26
|
+
## v1.2.4
|
27
|
+
|
28
|
+
* [COOK-2747]: celerycam configuration is not suitable for multiple node celery installation.
|
29
|
+
* [COOK-2766]: pip does not use `deploy_key` in django ressource of `application_python`.
|
30
|
+
|
31
|
+
## v1.2.2
|
32
|
+
|
33
|
+
* [COOK-2796]: celery provider tries to case switch on 'queue' parameter instead of 'queues' parameter.
|
34
|
+
|
35
|
+
## v1.2.0
|
36
|
+
|
37
|
+
* [COOK-2611]: Celery LWRP should configure which queues a celeryd worker binds to.
|
38
|
+
* [COOK-2599]: gunicorn provider fails if no `node['cpu']['total']`.
|
39
|
+
|
40
|
+
## v1.1.0
|
41
|
+
|
42
|
+
* [COOK-2330] - celeryconfig.py.erb tries to use non-existant String#upper method
|
43
|
+
* [COOK-2337] - It should be possible to pass environment variables through to gunicorn and celery supervisor configs
|
44
|
+
* [COOK-2403] - cookbook attribute expects argument to be a string.
|
45
|
+
* [COOK-2453] - application_python should allow the working directory of gunicorn processes to be set via an attribute.
|
46
|
+
* [COOK-2475] - celerybeat supervisor process is unnecessarily configured.
|
47
|
+
* [COOK-2484] - virtualenv and requirements are installed as root instead of uid/gid specified by application properties.
|
48
|
+
|
49
|
+
## v1.0.8
|
50
|
+
|
51
|
+
* [COOK-2175] - Template cookbook attribute expecting a stringg getting symbol instead.
|
52
|
+
|
53
|
+
## v1.0.6
|
54
|
+
|
55
|
+
* [COOK-2122] - pip was incorrectly using -E syntax.
|
56
|
+
* [COOK-2147] - django sub-resource searched wrong directory for requirements.txt.
|
57
|
+
|
58
|
+
## v1.0.4
|
59
|
+
|
60
|
+
* [COOK-2042] - gunicorn LWRP support for virtualenv, deps.
|
61
|
+
|
62
|
+
## v1.0.2
|
63
|
+
|
64
|
+
* [COOK-1420] - template resource source cookbook is wrong.
|
65
|
+
* [COOK-1421] - pip using old -E syntax.
|
66
|
+
* [COOK-1422] - syncdb using --migrate option.
|
67
|
+
* [COOK-1477] - pip requirements.txt and editable package support.
|
68
|
+
|
69
|
+
## v1.0.0
|
70
|
+
|
71
|
+
* [COOK-1246] - Initial release - relates to COOK-634.
|
data/Gemfile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2015, Noah Kantrowitz
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
source 'https://rubygems.org/'
|
18
|
+
|
19
|
+
gemspec path: File.expand_path('..', __FILE__)
|
20
|
+
|
21
|
+
def dev_gem(name, path: File.join('..', name), github: nil)
|
22
|
+
path = File.expand_path(File.join('..', path), __FILE__)
|
23
|
+
if File.exist?(path)
|
24
|
+
gem name, path: path
|
25
|
+
elsif github
|
26
|
+
gem name, github: github
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
dev_gem 'halite'
|
31
|
+
dev_gem 'poise'
|
32
|
+
dev_gem 'poise-application', path: '../application', github: 'poise/application'
|
33
|
+
dev_gem 'poise-application-git', path: '../application_git'
|
34
|
+
dev_gem 'poise-boiler'
|
35
|
+
dev_gem 'poise-languages'
|
36
|
+
dev_gem 'poise-python'
|
37
|
+
dev_gem 'poise-service'
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,334 @@
|
|
1
|
+
# Application_Python Cookbook
|
2
|
+
|
3
|
+
[![Build Status](https://img.shields.io/travis/poise/application_python.svg)](https://travis-ci.org/poise/application_python)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/poise-application-python.svg)](https://rubygems.org/gems/poise-application-python)
|
5
|
+
[![Cookbook Version](https://img.shields.io/cookbook/v/application_python.svg)](https://supermarket.chef.io/cookbooks/application_python)
|
6
|
+
[![Coverage](https://img.shields.io/codecov/c/github/poise/application_python.svg)](https://codecov.io/github/poise/application_python)
|
7
|
+
[![Gemnasium](https://img.shields.io/gemnasium/poise/application_python.svg)](https://gemnasium.com/poise/application_python)
|
8
|
+
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
|
9
|
+
|
10
|
+
A [Chef](https://www.chef.io/) cookbook to deploy Python applications.
|
11
|
+
|
12
|
+
## Quick Start
|
13
|
+
|
14
|
+
To deploy a Django application from git:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
application '/srv/myapp' do
|
18
|
+
git 'https://github.com/example/myapp.git'
|
19
|
+
virtualenv
|
20
|
+
pip_requirements
|
21
|
+
django do
|
22
|
+
database 'sqlite:///test_django.db'
|
23
|
+
secret_key 'd78fe08df56c9'
|
24
|
+
migrate true
|
25
|
+
end
|
26
|
+
gunicorn do
|
27
|
+
port 8000
|
28
|
+
end
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
## Requirements
|
33
|
+
|
34
|
+
Chef 12 or newer is required.
|
35
|
+
|
36
|
+
## Resources
|
37
|
+
|
38
|
+
### `application_celery_beat`
|
39
|
+
|
40
|
+
The `application_celery_beat` resource creates a service for the `celery beat`
|
41
|
+
process.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
application '/srv/myapp' do
|
45
|
+
celery_beat do
|
46
|
+
app_module 'myapp.tasks'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
#### Actions
|
52
|
+
|
53
|
+
* `:enable` – Create, enable and start the service. *(default)*
|
54
|
+
* `:disable` – Stop, disable, and destroy the service.
|
55
|
+
* `:start` – Start the service.
|
56
|
+
* `:stop` – Stop the service.
|
57
|
+
* `:restart` – Stop and then start the service.
|
58
|
+
* `:reload` – Send the configured reload signal to the service.
|
59
|
+
|
60
|
+
#### Properties
|
61
|
+
|
62
|
+
* `path` – Base path for the application. *(name attribute)*
|
63
|
+
* `app_module` – Celery application module. *(default: auto-detect)*
|
64
|
+
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
65
|
+
# `user` – User to run the service as. *(default: application owner)*
|
66
|
+
|
67
|
+
### `application_celery_config`
|
68
|
+
|
69
|
+
The `application_celery_config` creates a `celeryconfig.py` configuration file.
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
application '/srv/myapp' do
|
73
|
+
celery_config do
|
74
|
+
options do
|
75
|
+
broker_url 'amqp://'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
#### Actions
|
82
|
+
|
83
|
+
* `:deploy` – Create the configuration file. *(default)*
|
84
|
+
|
85
|
+
#### Properties
|
86
|
+
|
87
|
+
* `path` – Path to write the configuration file to. If given as a directory,
|
88
|
+
create `path/celeryconfig.py`. *(name attribute)*
|
89
|
+
* `options` – Hash or block of options to set in the configuration file.
|
90
|
+
|
91
|
+
### `application_celery_worker`
|
92
|
+
|
93
|
+
The `application_celery_worker` resource creates a service for the
|
94
|
+
`celery worker` process.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
application '/srv/myapp' do
|
98
|
+
celery_worker do
|
99
|
+
app_module 'myapp.tasks'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
#### Actions
|
105
|
+
|
106
|
+
* `:enable` – Create, enable and start the service. *(default)*
|
107
|
+
* `:disable` – Stop, disable, and destroy the service.
|
108
|
+
* `:start` – Start the service.
|
109
|
+
* `:stop` – Stop the service.
|
110
|
+
* `:restart` – Stop and then start the service.
|
111
|
+
* `:reload` – Send the configured reload signal to the service.
|
112
|
+
|
113
|
+
#### Properties
|
114
|
+
|
115
|
+
* `path` – Base path for the application. *(name attribute)*
|
116
|
+
* `app_module` – Celery application module. *(default: auto-detect)*
|
117
|
+
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
118
|
+
# `user` – User to run the service as. *(default: application owner)*
|
119
|
+
|
120
|
+
### `application_django`
|
121
|
+
|
122
|
+
The `application_django` resource creates configuration files and runs commands
|
123
|
+
for a Django application deployment.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
application '/srv/myapp' do
|
127
|
+
django do
|
128
|
+
database 'sqlite:///test_django.db'
|
129
|
+
migrate true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
134
|
+
#### Actions
|
135
|
+
|
136
|
+
* `:deploy` – Create config files and run required deployments steps. *(default)*
|
137
|
+
|
138
|
+
#### Properties
|
139
|
+
|
140
|
+
* `path` – Base path for the application. *(name attribute)*
|
141
|
+
* `allowed_hosts` – Value for `ALLOWED_HOSTS` in the Django settings.
|
142
|
+
*(default: [])*
|
143
|
+
* `collectstatic` – Run `manage.py collectstatic` during deployment.
|
144
|
+
*(default: true)*
|
145
|
+
* `database` – Database settings for the default connection. See [the database
|
146
|
+
section below](#database-parameters) for more information. *(option collector)*
|
147
|
+
* `debug` – Enable debug mode for Django. *(default: false)*
|
148
|
+
* `local_settings` – A [Poise template property](https://github.com/poise/poise#template-content)
|
149
|
+
for the content of the local settings configuration file.
|
150
|
+
* `local_settings_path` – Path to write local settings to. If given as a
|
151
|
+
relative path, will be expanded against path. Set to false to disable writing
|
152
|
+
local settings. *(default: local_settings.py next to settings_module)*
|
153
|
+
* `migrate` – Run `manage.py migrate` during deployment. *(default: false)*
|
154
|
+
* `manage_path` – Path to `manage.py`. *(default: auto-detect)*
|
155
|
+
* `secret_key` – Value for `SECRET_KEY` in the Django settings. If unset, no
|
156
|
+
key is added to the local settings.
|
157
|
+
* `settings_module` – Django settings module in dotted notation.
|
158
|
+
*(default: auto-detect)*
|
159
|
+
* `syncdb` – Run `manage.py syncdb` during deployment. *(default: false)*
|
160
|
+
* `wsgi_module` – WSGI application module in dotted notation.
|
161
|
+
*(default: auto-detect)*
|
162
|
+
|
163
|
+
#### Database Parameters
|
164
|
+
|
165
|
+
The database parameters can be set in three ways: URL, hash, and block.
|
166
|
+
|
167
|
+
If you have a single URL for the parameters, you can pass it directly to
|
168
|
+
`database`:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
django do
|
172
|
+
database 'postgres://myuser@dbhost/myapp'
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
Passing a single URL will also set the `$DATABASE_URL` environment variable
|
177
|
+
automatically for compatibility with Heroku-based applications.
|
178
|
+
|
179
|
+
As with other option collector resources, you can pass individual settings as
|
180
|
+
either a hash or block:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
django do
|
184
|
+
database do
|
185
|
+
engine 'postgres'
|
186
|
+
user 'myuser'
|
187
|
+
host 'dbhost'
|
188
|
+
name 'myapp'
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
django do
|
193
|
+
database({
|
194
|
+
engine: 'postgres',
|
195
|
+
user: 'myuser',
|
196
|
+
host: 'dbhost',
|
197
|
+
name: 'myapp',
|
198
|
+
})
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
202
|
+
### `application_gunicorn`
|
203
|
+
|
204
|
+
The `application_gunicorn` resource creates a service for the
|
205
|
+
[Gunicorn](http://gunicorn.org/) application server.
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
application '/srv/myapp' do
|
209
|
+
gunicorn do
|
210
|
+
port 8000
|
211
|
+
preload_app true
|
212
|
+
end
|
213
|
+
end
|
214
|
+
```
|
215
|
+
|
216
|
+
#### Actions
|
217
|
+
|
218
|
+
* `:enable` – Create, enable and start the service. *(default)*
|
219
|
+
* `:disable` – Stop, disable, and destroy the service.
|
220
|
+
* `:start` – Start the service.
|
221
|
+
* `:stop` – Stop the service.
|
222
|
+
* `:restart` – Stop and then start the service.
|
223
|
+
* `:reload` – Send the configured reload signal to the service.
|
224
|
+
|
225
|
+
#### Properties
|
226
|
+
|
227
|
+
* `path` – Base path for the application. *(name attribute)*
|
228
|
+
* `app_module` – WSGI module to run as an application. *(default: auto-detect)*
|
229
|
+
* `bind` – One or more addresses/ports to bind to.
|
230
|
+
* `config` – Path to a Guncorn configuration file.
|
231
|
+
* `preload_app` – Enable code preloading. *(default: false)*
|
232
|
+
* `port` – Port to listen on. Alias for `bind("0.0.0.0:#{port}")`.
|
233
|
+
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
234
|
+
# `user` – User to run the service as. *(default: application owner)*
|
235
|
+
* `version` – Version of Gunicorn to install. If set to true, use the latest
|
236
|
+
version. If set to false, do not install Gunicorn. *(default: true)*
|
237
|
+
|
238
|
+
### `application_pip_requirements`
|
239
|
+
|
240
|
+
The `application_pip_requirements` resource installs Python packages based on a
|
241
|
+
`requirements.txt` file.
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
application '/srv/myapp' do
|
245
|
+
pip_requirements
|
246
|
+
end
|
247
|
+
```
|
248
|
+
|
249
|
+
All actions and properties are the same as the [`pip_requirements` resource](https://github.com/poise/poise-python#pip_requirements).
|
250
|
+
|
251
|
+
### `application_python`
|
252
|
+
|
253
|
+
The `application_python` resource installs a Python runtime for the deployment.
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
application '/srv/myapp' do
|
257
|
+
python '2.7'
|
258
|
+
end
|
259
|
+
```
|
260
|
+
|
261
|
+
All actions and properties are the same as the [`python_runtime` resource](https://github.com/poise/poise-python#python_runtime).
|
262
|
+
|
263
|
+
### `application_python_execute`
|
264
|
+
|
265
|
+
The `application_python_execute` resource runs Python commands for the deployment.
|
266
|
+
|
267
|
+
```ruby
|
268
|
+
application '/srv/myapp' do
|
269
|
+
python_execute 'setup.py install'
|
270
|
+
end
|
271
|
+
```
|
272
|
+
|
273
|
+
All actions and properties are the same as the [`python_execute` resource](https://github.com/poise/poise-python#python_execute),
|
274
|
+
except that the `cwd`, `environment`, `group`, and `user` properties default to
|
275
|
+
the application-level data if not specified.
|
276
|
+
|
277
|
+
### `application_python_package`
|
278
|
+
|
279
|
+
The `application_python_package` resource installs Python packages for the deployment.
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
application '/srv/myapp' do
|
283
|
+
python_package 'requests'
|
284
|
+
end
|
285
|
+
```
|
286
|
+
|
287
|
+
All actions and properties are the same as the [`python_package` resource](https://github.com/poise/poise-python#python_package),
|
288
|
+
except that the `group` and `user` properties default to the application-level
|
289
|
+
data if not specified.
|
290
|
+
|
291
|
+
### `application_virtualenv`
|
292
|
+
|
293
|
+
The `application_virtualenv` resource creates a Python virtualenv for the
|
294
|
+
deployment.
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
application '/srv/myapp' do
|
298
|
+
virtualenv
|
299
|
+
end
|
300
|
+
```
|
301
|
+
|
302
|
+
If no path property is given, the default is to create a `.env/` inside the
|
303
|
+
application deployment path.
|
304
|
+
|
305
|
+
All actions and properties are the same as the [`python_virtualenv` resource](https://github.com/poise/poise-python#python_virtualenv).
|
306
|
+
|
307
|
+
## Examples
|
308
|
+
|
309
|
+
Some test recipes are available as examples for common application frameworks:
|
310
|
+
|
311
|
+
* [Flask](https://github.com/poise/application_python/blob/master/test/cookbooks/application_python_test/recipes/flask.rb)
|
312
|
+
* [Django](https://github.com/poise/application_python/blob/master/test/cookbooks/application_python_test/recipes/django.rb)
|
313
|
+
|
314
|
+
## Sponsors
|
315
|
+
|
316
|
+
Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/).
|
317
|
+
|
318
|
+
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
|
319
|
+
|
320
|
+
## License
|
321
|
+
|
322
|
+
Copyright 2015, Noah Kantrowitz
|
323
|
+
|
324
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
325
|
+
you may not use this file except in compliance with the License.
|
326
|
+
You may obtain a copy of the License at
|
327
|
+
|
328
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
329
|
+
|
330
|
+
Unless required by applicable law or agreed to in writing, software
|
331
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
332
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
333
|
+
See the License for the specific language governing permissions and
|
334
|
+
limitations under the License.
|