From bfd93de6943ef3e38ea903d330850ab31f2c3380 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 19 Jul 2015 13:12:22 -0700 Subject: [PATCH 001/113] First pass on Poise standard boilerplate. --- .gitignore | 11 + .kitchen.travis.yml | 9 + .kitchen.yml | 8 + .travis.yml | 19 ++ .yardopts | 3 + Berksfile | 35 +++ CONTRIBUTING.md | 257 ------------------ Gemfile | 39 +++ README.md | 174 +----------- Rakefile | 17 ++ SUPPORTERS.md | 81 ++++++ chef/templates/.gitkeep | 0 lib/poise_application_python.rb | 21 ++ lib/poise_application_python/cheftie.rb | 17 ++ lib/poise_application_python/error.rb | 25 ++ lib/poise_application_python/resources.rb | 15 + .../resources/.gitkeep | 0 lib/poise_application_python/version.rb | 19 ++ metadata.rb | 13 - poise-application-python.gemspec | 44 +++ .../attributes/default.rb | 17 ++ .../application_python_test/metadata.rb | 20 ++ .../recipes/default.rb | 18 ++ test/gemfiles/chef-12.gemfile | 19 ++ test/gemfiles/master.gemfile | 26 ++ .../default/serverspec/default_spec.rb | 20 ++ test/spec/spec_helper.rb | 18 ++ 27 files changed, 515 insertions(+), 430 deletions(-) create mode 100644 .gitignore create mode 100644 .kitchen.travis.yml create mode 100644 .kitchen.yml create mode 100644 .travis.yml create mode 100644 .yardopts create mode 100644 Berksfile delete mode 100644 CONTRIBUTING.md create mode 100644 Gemfile create mode 100644 Rakefile create mode 100644 SUPPORTERS.md create mode 100644 chef/templates/.gitkeep create mode 100644 lib/poise_application_python.rb create mode 100644 lib/poise_application_python/cheftie.rb create mode 100644 lib/poise_application_python/error.rb create mode 100644 lib/poise_application_python/resources.rb create mode 100644 lib/poise_application_python/resources/.gitkeep create mode 100644 lib/poise_application_python/version.rb delete mode 100644 metadata.rb create mode 100644 poise-application-python.gemspec create mode 100644 test/cookbooks/application_python_test/attributes/default.rb create mode 100644 test/cookbooks/application_python_test/metadata.rb create mode 100644 test/cookbooks/application_python_test/recipes/default.rb create mode 100644 test/gemfiles/chef-12.gemfile create mode 100644 test/gemfiles/master.gemfile create mode 100644 test/integration/default/serverspec/default_spec.rb create mode 100644 test/spec/spec_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38f93b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +Gemfile.lock +test/gemfiles/*.lock +Berksfile.lock +.kitchen/ +.kitchen.local.yml +test/docker/ +coverage/ +pkg/ +.yardoc/ +doc/ + diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml new file mode 100644 index 0000000..53d18c2 --- /dev/null +++ b/.kitchen.travis.yml @@ -0,0 +1,9 @@ +--- +driver: + name: docker + binary: "./docker" + socket: tcp://docker.poise.io:443 + tls_verify: true + tls_cacert: test/docker/docker.ca + tls_cert: test/docker/docker.pem + tls_key: test/docker/docker.key diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..bb6c069 --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,8 @@ +--- +#<% require 'poise_boiler' %> +<%= PoiseBoiler.kitchen(platforms: 'linux') %> + +suites: +- name: default + run_list: + - recipe[application_python_test] diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d76f0e0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +sudo: false +cache: bundler +language: ruby +rvm: +- '2.2' +addons: + apt: + packages: + - libgecode-dev +env: + global: + - USE_SYSTEM_GECODE=true + - KITCHEN_LOCAL_YAML=.kitchen.travis.yml +bundler_args: "--binstubs=$PWD/bin --jobs 3 --retry 3" +script: +- "./bin/rake travis" +gemfile: +- test/gemfiles/chef-12.gemfile +- test/gemfiles/master.gemfile diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..1c11d2a --- /dev/null +++ b/.yardopts @@ -0,0 +1,3 @@ +--plugin classmethods +--markup markdown +--hide-void-return diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..c9c4042 --- /dev/null +++ b/Berksfile @@ -0,0 +1,35 @@ +# +# Author:: Noah Kantrowitz +# +# Copyright 2013, Balanced, Inc. +# +# 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. +# + +source 'https://supermarket.chef.io/' +extension 'halite' + +# Force the rebuild every time for development. +cookbook 'poise', gem: 'poise' +cookbook 'application', gem: 'poise-application' +cookbook 'application_python', gem: 'poise-application-python' +cookbook 'poise-languages', gem: 'poise-languages' +cookbook 'poise-python', gem: 'poise-python' +cookbook 'poise-service', gem: 'poise-service' + +group :test do + cookbook 'application_git', gem: 'poise-application-git' + cookbook 'application_python_test', path: 'test/cookbooks/application_python_test' + cookbook 'apt' + cookbook 'git' +end diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 3a99897..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,257 +0,0 @@ -# Contributing to Opscode Cookbooks - -We are glad you want to contribute to Opscode Cookbooks! The first -step is the desire to improve the project. - -You can find the answers to additional frequently asked questions -[on the wiki](http://wiki.opscode.com/display/chef/How+to+Contribute). - -You can find additional information about -[contributing to cookbooks](http://wiki.opscode.com/display/chef/How+to+Contribute+to+Opscode+Cookbooks) -on the wiki as well. - -## Quick-contribute - -* Create an account on our [bug tracker](http://tickets.opscode.com) -* Sign our contributor agreement (CLA) -[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L) -(keep reading if you're contributing on behalf of your employer) -* Create a ticket for your change on the - [bug tracker](http://tickets.opscode.com) -* Link to your patch as a rebased git branch or pull request from the - ticket -* Resolve the ticket as fixed - -We regularly review contributions and will get back to you if we have -any suggestions or concerns. - -## The Apache License and the CLA/CCLA - -Licensing is very important to open source projects, it helps ensure -the software continues to be available under the terms that the author -desired. Chef uses the Apache 2.0 license to strike a balance between -open contribution and allowing you to use the software however you -would like to. - -The license tells you what rights you have that are provided by the -copyright holder. It is important that the contributor fully -understands what rights they are licensing and agrees to them. -Sometimes the copyright holder isn't the contributor, most often when -the contributor is doing work for a company. - -To make a good faith effort to ensure these criteria are met, Opscode -requires a Contributor License Agreement (CLA) or a Corporate -Contributor License Agreement (CCLA) for all contributions. This is -without exception due to some matters not being related to copyright -and to avoid having to continually check with our lawyers about small -patches. - -It only takes a few minutes to complete a CLA, and you retain the -copyright to your contribution. - -You can complete our contributor agreement (CLA) -[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L). -If you're contributing on behalf of your employer, have your employer -fill out our -[Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) -instead. - -## Ticket Tracker (JIRA) - -The [ticket tracker](http://tickets.opscode.com) is the most important -documentation for the code base. It provides significant historical -information, such as: - -* Which release a bug fix is included in -* Discussion regarding the design and merits of features -* Error output to aid in finding similar bugs - -Each ticket should aim to fix one bug or add one feature. - -## Using git - -You can get a quick copy of the repository for this cookbook by -running `git clone -git://github.com/opscode-coobkooks/COOKBOOKNAME.git`. - -For collaboration purposes, it is best if you create a Github account -and fork the repository to your own account. Once you do this you will -be able to push your changes to your Github repository for others to -see and use. - -If you have another repository in your GitHub account named the same -as the cookbook, we suggest you suffix the repository with -cookbook. - -### Branches and Commits - -You should submit your patch as a git branch named after the ticket, -such as COOK-1337. This is called a _topic branch_ and allows users to -associate a branch of code with the ticket. - -It is a best practice to have your commit message have a _summary -line_ that includes the ticket number, followed by an empty line and -then a brief description of the commit. This also helps other -contributors understand the purpose of changes to the code. - - [COOK-1757] - platform_family and style - - * use platform_family for platform checking - * update notifies syntax to "resource_type[resource_name]" instead of - resources() lookup - * COOK-692 - delete config files dropped off by packages in conf.d - * dropped debian 4 support because all other platforms have the same - values, and it is older than "old stable" debian release - -Remember that not all users use Chef in the same way or on the same -operating systems as you, so it is helpful to be clear about your use -case and change so they can understand it even when it doesn't apply -to them. - -### Github and Pull Requests - -All of Opscode's open source cookbook projects are available on -[Github](http://www.github.com/opscode-cookbooks). - -We don't require you to use Github, and we will even take patch diffs -attached to tickets on the tracker. However Github has a lot of -convenient features, such as being able to see a diff of changes -between a pull request and the main repository quickly without -downloading the branch. - -If you do choose to use a pull request, please provide a link to the -pull request from the ticket __and__ a link to the ticket from the -pull request. Because pull requests only have two states, open and -closed, we can't easily filter pull requests that are waiting for a -reply from the author for various reasons. - -### More information - -Additional help with git is available on the -[Working with Git](http://wiki.opscode.com/display/chef/Working+with+Git) -wiki page. - -## Functional and Unit Tests - -This cookbook is set up to run tests under -[Opscode's test-kitchen](https://github.com/opscode/test-kitchen). It -uses minitest-chef to run integration tests after the node has been -converged to verify that the state of the node. - -Test kitchen should run completely without exception using the default -[baseboxes provided by Opscode](https://github.com/opscode/bento). -Because Test Kitchen creates VirtualBox machines and runs through -every configuration in the Kitchenfile, it may take some time for -these tests to complete. - -If your changes are only for a specific recipe, run only its -configuration with Test Kitchen. If you are adding a new recipe, or -other functionality such as a LWRP or definition, please add -appropriate tests and ensure they run with Test Kitchen. - -If any don't pass, investigate them before submitting your patch. - -Any new feature should have unit tests included with the patch with -good code coverage to help protect it from future changes. Similarly, -patches that fix a bug or regression should have a _regression test_. -Simply put, this is a test that would fail without your patch but -passes with it. The goal is to ensure this bug doesn't regress in the -future. Consider a regular expression that doesn't match a certain -pattern that it should, so you provide a patch and a test to ensure -that the part of the code that uses this regular expression works as -expected. Later another contributor may modify this regular expression -in a way that breaks your use cases. The test you wrote will fail, -signalling to them to research your ticket and use case and accounting -for it. - -If you need help writing tests, please ask on the Chef Developer's -mailing list, or the #chef-hacking IRC channel. - -## Code Review - -Opscode regularly reviews code contributions and provides suggestions -for improvement in the code itself or the implementation. - -We find contributions by searching the ticket tracker for _resolved_ -tickets with a status of _fixed_. If we have feedback we will reopen -the ticket and you should resolve it again when you've made the -changes or have a response to our feedback. When we believe the patch -is ready to be merged, we will tag the _Code Reviewed_ field with -_Reviewed_. - -Depending on the project, these tickets are then merged within a week -or two, depending on the current release cycle. - -## Release Cycle - -The versioning for Opscode Cookbook projects is X.Y.Z. - -* X is a major release, which may not be fully compatible with prior - major releases -* Y is a minor release, which adds both new features and bug fixes -* Z is a patch release, which adds just bug fixes - -A released version of a cookbook will end in an even number, e.g. -"1.2.4" or "0.8.0". When development for the next version of the -cookbook begins, the "Z" patch number is incremented to the next odd -number, however the next release of the cookbook may be a major or -minor incrementing version. - -Releases of Opscode's cookbooks are usually announced on the Chef user -mailing list. Releases of several cookbooks may be batched together -and announced on the [Opscode Blog](http://www.opscode.com/blog). - -## Working with the community - -These resources will help you learn more about Chef and connect to -other members of the Chef community: - -* [chef](http://lists.opscode.com/sympa/info/chef) and - [chef-dev](http://lists.opscode.com/sympa/info/chef-dev) mailing - lists -* #chef and #chef-hacking IRC channels on irc.freenode.net -* [Community Cookbook site](http://community.opscode.com) -* [Chef wiki](http://wiki.opscode.com/display/chef) -* Opscode Chef [product page](http://www.opscode.com/chef) - - -## Cookbook Contribution Do's and Don't's - -Please do include tests for your contribution. If you need help, ask -on the -[chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev) -or the -[#chef-hacking IRC channel](http://community.opscode.com/chat/chef-hacking). -Not all platforms that a cookbook supports may be supported by Test -Kitchen. Please provide evidence of testing your contribution if it -isn't trivial so we don't have to duplicate effort in testing. Chef -10.14+ "doc" formatted output is sufficient. - -Please do indicate new platform (families) or platform versions in the -commit message, and update the relevant ticket. - -If a contribution adds new platforms or platform versions, indicate -such in the body of the commit message(s), and update the relevant -COOK ticket. When writing commit messages, it is helpful for others if -you indicate the COOK ticket. For example: - - git commit -m '[COOK-1041] - Updated pool resource to correctly - delete.' - -Please do use [foodcritic](http://acrmp.github.com/foodcritic) to -lint-check the cookbook. Except FC007, it should pass all correctness -rules. FC007 is okay as long as the dependent cookbooks are *required* -for the default behavior of the cookbook, such as to support an -uncommon platform, secondary recipe, etc. - -Please do ensure that your changes do not break or modify behavior for -other platforms supported by the cookbook. For example if your changes -are for Debian, make sure that they do not break on CentOS. - -Please do not modify the version number in the metadata.rb, Opscode -will select the appropriate version based on the release cycle -information above. - -Please do not update the CHANGELOG.md for a new version. Not all -changes to a cookbook may be merged and released in the same versions. -Opscode will update the CHANGELOG.md when releasing a new version of -the cookbook. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b593dff --- /dev/null +++ b/Gemfile @@ -0,0 +1,39 @@ +# +# 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. +# + +source 'https://rubygems.org/' + +gemspec path: File.expand_path('..', __FILE__) + +def dev_gem(name, path: File.join('..', name), github: nil) + path = File.expand_path(File.join('..', path), __FILE__) + if File.exist?(path) + gem name, path: path + elsif github + gem name, github: github + end +end + +dev_gem 'halite' +dev_gem 'poise' +dev_gem 'poise-application', path: '../application', github: 'poise/application' +dev_gem 'poise-application-git', path: '../application_git', github: 'poise/application_git' +dev_gem 'poise-boiler' +dev_gem 'poise-languages', github: 'poise/poise-languages' +dev_gem 'poise-python', github: 'poise/poise-python' +dev_gem 'poise-service', github: 'poise/poise-service' + +gem 'kitchen-docker', github: 'portertech/kitchen-docker' diff --git a/README.md b/README.md index c9cb523..08b35e2 100644 --- a/README.md +++ b/README.md @@ -1,178 +1,32 @@ -application_python Cookbook -=========================== -This cookbook is designed to be able to describe and deploy Python web applications. Currently supported: +# Application_Python Cookbook -- plain python web applications -- Django -- Green Unicorn -- Celery +[![Build Status](https://img.shields.io/travis/poise/application_python.svg)](https://travis-ci.org/poise/application_python) +[![Gem Version](https://img.shields.io/gem/v/poise-application-python.svg)](https://rubygems.org/gems/poise-application-python) +[![Cookbook Version](https://img.shields.io/cookbook/v/application_python.svg)](https://supermarket.chef.io/cookbooks/application_python) +[![Coverage](https://img.shields.io/codecov/c/github/poise/application_python.svg)](https://codecov.io/github/poise/application_python) +[![Gemnasium](https://img.shields.io/gemnasium/poise/application_python.svg)](https://gemnasium.com/poise/application_python) +[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -Note that this cookbook provides the Python-specific bindings for the `application` cookbook; you will find general documentation in that cookbook. +More info coming soon! -Other application stacks may be supported at a later date. +## Sponsors +Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/). -Requirements ------------- -Chef 0.10.0 or higher required (for Chef environment use). +The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/). -The following Opscode cookbooks are dependencies: +## License -- application -- python -- gunicorn -- supervisor - - -Resources/Providers -------------------- -The LWRPs provided by this cookbook are not meant to be used by themselves; make sure you are familiar with the `application` cookbook before proceeding. - - -### django -The `django` sub-resource LWRP deals with deploying Django webapps from an SCM repository. It uses the `deploy_revision` LWRP to perform the bulk of its tasks, and many concepts and parameters map directly to it. Check the documentation for `deploy_revision` for more information. - -A new virtualenv will be created for the application in "#{path}/shared/env"; pip package will be installed in that virtualenv. - -#### Attribute Parameters -- packages: an Array of pip packages to install -- requirements: the relative path to a requirements file. If not specified the provider will look for one in the project root, named either "requirements/#{chef_environment}.txt" or "requirements.txt" -- database_master_role: if a role name is provided, a Chef search will be run to find a node with than role in the same environment as the current role. If a node is found, its IP address will be used when rendering the context file, but see the "Database block parameters" section below -- local_settings_file: the name of the local settings file to be generated by template. Defaults to "local_settings.py" -- settings_template: the name of template that will be rendered to create the local settings file; if specified it will be looked up in the application cookbook. Defaults to "settings.py.erb" from this cookbook -- settings: a Hash of additional settings that will be made available to the template -- database: a block containing additional parameters for configuring the database connection -- legacy_database_settings: if true, the default settings template will generate legacy database config variables. Defaults to false -- debug: used by the default settings template to control debugging. Defaults to false -- collectstatic: controls the behavior of the `staticfiles` app. If true, if will invoke manage.py with `collectstatic --noinput`; you can also pass a String with an explicit command (see Usage below). Defaults to false - -#### Database block parameters - -The database block can accept any method, which will result in an entry being created in the `@database` Hash which is passed to the context template. See Usage below for more information. - -### gunicorn -The `gunicorn` sub-resource LWRP configures Green Unicorn to run the application. - -If used with a Django application, it will install gunicorn into the same virtualenv and run it with `manage.py run_gunicorn`. For other applications, gunicorn will be run with `gunicorn #{app_module}`. - -#### Attribute Parameters - -- app_module: mandatory. If set to :django, gunicorn will be configured to run a Django application; if set to another String or Symbol, it will be used to build the gunicorn base command. -- settings_template: the template to render to create the `gunicorn_config.py` file; if specified it will be looked up in the application cookbook. Defaults to "se.py.erb" from the `gunicorn` cookbook -- host: passed to the `gunicorn_config` LWRP -- port: passed to the `gunicorn_config` LWRP -- backlog: passed to the `gunicorn_config` LWRP -- workers: passed to the `gunicorn_config` LWRP -- worker_class: passed to the `gunicorn_config` LWRP -- worker_connections: passed to the `gunicorn_config` LWRP -- max_requests: passed to the `gunicorn_config` LWRP -- timeout: passed to the `gunicorn_config` LWRP -- keepalive: passed to the `gunicorn_config` LWRP -- debug: passed to the `gunicorn_config` LWRP -- trace: passed to the `gunicorn_config` LWRP -- preload_app: passed to the `gunicorn_config` LWRP -- daemon: passed to the `gunicorn_config` LWRP -- pidfile: passed to the `gunicorn_config` LWRP -- umask: passed to the `gunicorn_config` LWRP -- logfile: passed to the `gunicorn_config` LWRP -- loglevel: passed to the `gunicorn_config` LWRP -- proc_name: passed to the `gunicorn_config` LWRP -- environment: hash of environment variables passed to `supervisor_service` -- autostart: passed to `supervisor_service`. - - -### celery -The `celery` sub resource LWRP configures the application to use Celery. - -#### Attribute Parameters -- config: passed to `supervisor_service` for `CELERY_CONFIG_MODULE`. -- template: name of the template to use, default `celeryconfig.py.erb`. -- django: use this if celery is for a django application, see `celerycam` below. -- celeryd: adds celeryd to processes managed for the application by `supervisor`. -- celerybeat: adds celerybeat to processes managed for the application by `supervisor`. -- celerycam: adds celerycam to the processes managed for the application by `supervisor` if `django` is true for celery sub-resource, or celeryev with the class specified with `camera_class`. -- camera_class: class passed into celeryev for the processes managed for the application by supervisor. -- environment: hash of environment variables passed to the `supervisor_service`. - - -Usage ------ -A sample application that needs a database connection: - -```ruby -application 'packaginator' do - path '/srv/packaginator' - owner 'nobody' - group 'nogroup' - repository 'https://github.com/coderanger/packaginator.git' - revision 'master' - migrate true - packages ['libpq-dev', 'git-core', 'mercurial'] - - django do - packages ['redis'] - requirements 'requirements/mkii.txt' - settings_template 'settings.py.erb' - debug true - collectstatic 'build_static --noinput' - database do - database 'packaginator' - adapter 'postgresql_psycopg2' - username 'packaginator' - password 'awesome_password' - end - database_master_role 'packaginator_database_master' - end -end -``` - -You can invoke any method on the database block: - -```ruby -application 'my-app' do - path '/srv/packaginator' - repository '...' - revision '...' - - django do - database_master_role 'packaginator_database_master' - database do - database 'name' - quorum 2 - replicas ['Huey', 'Dewey', 'Louie'] - end - end -end -``` - -The corresponding entries will be passed to the context template: - -```erb -<%= @database['quorum'] %> -<%= @database['replicas'].join(',') %> -``` - - -License & Authors ------------------ -- Author:: Adam Jacob () -- Author:: Andrea Campi () -- Author:: Joshua Timberman () -- Author:: Noah Kantrowitz () -- Author:: Seth Chisamore () - -```text -Copyright 2009-2013, Opscode, Inc. +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 +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. -``` diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..bc878ed --- /dev/null +++ b/Rakefile @@ -0,0 +1,17 @@ +# +# 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. +# + +require 'poise_boiler/rakefile' diff --git a/SUPPORTERS.md b/SUPPORTERS.md new file mode 100644 index 0000000..fa5a652 --- /dev/null +++ b/SUPPORTERS.md @@ -0,0 +1,81 @@ +# Supporters + +This cookbook wouldn't have been possible without the generous support of my +Kickstarter backers. Thanks so much to every one of you! + +* @kcunning +* Alberto Lorenzo Pulido +* Alex Gaynor +* Alexander Myasnikov +* Brooke Schreier Ganz +* Bryan McLellan +* Charles Johnson +* Chef Software, Inc. +* Chris Adams +* Christopher Petrilli +* David Thornton +* Derek Murawsky +* Fast Robot, LLC +* Fatty McAwesome Pants (Kate Heddleston) +* Greg Albrecht +* JD Harrington +* Jake Plimack +* Jason Cook +* Jeff Byrnes +* Jeff Forcier +* Jeff Lindsay +* Jennifer Davis +* John Fitch +* Jon Stacks +* Joshua SS Miller +* Julian Dunn +* Julien Phalip +* Kennon Kwok +* Kevin Duane +* Krzysztof Wilczynski +* Linda Goldstein +* Manny Toledo +* Marco A Morales +* Marcus Morris +* Mark Luntzel +* Martin B. Smith +* Mathieu Sauve-Frankel +* Matt Good +* Matt Juszczak +* Matt Ray +* Matt Stratton +* Michael Burns +* Miguel Landaeta +* Mike Schueler +* Nathan L Smith +* Nathen Harvey +* Paul Welch +* Peter Kropf +* Phil Mocek +* Practice Fusion Inc +* Ranjib +* Richard Jones +* Robert J. Berger +* Robin Levin +* Roland Moriz +* Ruben Orduz +* Russell Keith-Magee +* Ryan Hass +* Sam Clements +* Sean OMeara +* Seva Feldman +* Soo Choi +* Steven Danna +* Symonds & Son +* Todd Michael Bushnell +* Tracy Osborn +* Troy Ready +* Tyler Ball +* Vicky Tuite +* Ying Li +* Yvo van Doorn +* Zac Stevens +* lvh +* oolongtea +* smeuser +* tmonk42 diff --git a/chef/templates/.gitkeep b/chef/templates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/poise_application_python.rb b/lib/poise_application_python.rb new file mode 100644 index 0000000..2f3d1d5 --- /dev/null +++ b/lib/poise_application_python.rb @@ -0,0 +1,21 @@ +# +# 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. +# + + +module PoiseApplicationPython + autoload :Resources, 'poise_application_python/resources' + autoload :VERSION, 'poise_application_python/version' +end diff --git a/lib/poise_application_python/cheftie.rb b/lib/poise_application_python/cheftie.rb new file mode 100644 index 0000000..8d47201 --- /dev/null +++ b/lib/poise_application_python/cheftie.rb @@ -0,0 +1,17 @@ +# +# 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. +# + +require 'poise_application_python/resources' diff --git a/lib/poise_application_python/error.rb b/lib/poise_application_python/error.rb new file mode 100644 index 0000000..10fdc61 --- /dev/null +++ b/lib/poise_application_python/error.rb @@ -0,0 +1,25 @@ +# +# 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. +# + +require 'poise_application/error' + +module PoiseApplicationPython + # Base exception class for poise-application-python errors. + # + # @since 4.0.0 + class Error < PoiseApplication::Error + end +end diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb new file mode 100644 index 0000000..e2840da --- /dev/null +++ b/lib/poise_application_python/resources.rb @@ -0,0 +1,15 @@ +# +# 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. +# diff --git a/lib/poise_application_python/resources/.gitkeep b/lib/poise_application_python/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/poise_application_python/version.rb b/lib/poise_application_python/version.rb new file mode 100644 index 0000000..30313a8 --- /dev/null +++ b/lib/poise_application_python/version.rb @@ -0,0 +1,19 @@ +# +# 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. +# + +module PoiseApplicationPython + VERSION = '4.0.0.pre' +end diff --git a/metadata.rb b/metadata.rb deleted file mode 100644 index a06b064..0000000 --- a/metadata.rb +++ /dev/null @@ -1,13 +0,0 @@ -name "application_python" -maintainer "Opscode, Inc." -maintainer_email "cookbooks@opscode.com" -license "Apache 2.0" -description "Deploys and configures Python-based applications" -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "3.0.1" - -%w{ python gunicorn supervisor }.each do |cb| - depends cb -end - -depends "application", "~> 3.0" diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec new file mode 100644 index 0000000..9913100 --- /dev/null +++ b/poise-application-python.gemspec @@ -0,0 +1,44 @@ +# +# 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. +# + +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'poise_application_python/version' + +Gem::Specification.new do |spec| + spec.name = 'poise-application-python' + spec.version = PoiseApplicationPython::VERSION + spec.authors = ['Noah Kantrowitz'] + spec.email = %w{noah@coderanger.net} + spec.description = "A Chef cookbook for deploying Python application code." + spec.summary = spec.description + spec.homepage = 'https://github.com/poise/application_python' + spec.license = 'Apache 2.0' + spec.metadata['halite_name'] = 'application_python' + + spec.files = `git ls-files`.split($/) + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = %w{lib} + + spec.add_dependency 'halite', '~> 1.0' + spec.add_dependency 'poise', '~> 2.0' + spec.add_dependency 'poise-application', '~> 5.0.pre' + spec.add_dependency 'poise-python', '~> 1.0.pre' + spec.add_dependency 'poise-service', '~> 1.0' + + spec.add_development_dependency 'poise-boiler', '~> 1.0' +end diff --git a/test/cookbooks/application_python_test/attributes/default.rb b/test/cookbooks/application_python_test/attributes/default.rb new file mode 100644 index 0000000..39ae375 --- /dev/null +++ b/test/cookbooks/application_python_test/attributes/default.rb @@ -0,0 +1,17 @@ +# +# 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. +# + +override['poise-service']['provider'] = 'dummy' diff --git a/test/cookbooks/application_python_test/metadata.rb b/test/cookbooks/application_python_test/metadata.rb new file mode 100644 index 0000000..2b26afc --- /dev/null +++ b/test/cookbooks/application_python_test/metadata.rb @@ -0,0 +1,20 @@ +# +# 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. +# + +name 'application_python_test' +depends 'application_git' +depends 'application_python' +depends 'build-essential' diff --git a/test/cookbooks/application_python_test/recipes/default.rb b/test/cookbooks/application_python_test/recipes/default.rb new file mode 100644 index 0000000..2adbfa6 --- /dev/null +++ b/test/cookbooks/application_python_test/recipes/default.rb @@ -0,0 +1,18 @@ +# +# 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. +# + +# For netstat in serverspec. +package 'net-tools' diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile new file mode 100644 index 0000000..65b686b --- /dev/null +++ b/test/gemfiles/chef-12.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.0' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile new file mode 100644 index 0000000..191be7e --- /dev/null +++ b/test/gemfiles/master.gemfile @@ -0,0 +1,26 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', github: 'chef/chef' +gem 'halite', github: 'poise/halite' +gem 'poise', github: 'poise/poise' +# gem 'poise-application', github: 'poise/application' +# gem 'poise-application-git', github: 'poise/application_git' +gem 'poise-boiler', github: 'poise/poise-boiler' +# gem 'poise-python', github: 'poise/poise-python' +gem 'poise-service', github: 'poise/poise-service' diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb new file mode 100644 index 0000000..e284a0f --- /dev/null +++ b/test/integration/default/serverspec/default_spec.rb @@ -0,0 +1,20 @@ +# +# 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. +# + +require 'net/http' + +require 'serverspec' +set :backend, :exec diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb new file mode 100644 index 0000000..d8ca917 --- /dev/null +++ b/test/spec/spec_helper.rb @@ -0,0 +1,18 @@ +# +# 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. +# + +require 'poise_boiler/spec_helper' +require 'poise_application_python' From d4f43d525f87e08e74162c8787e33a8192a91df5 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 18:49:26 -0700 Subject: [PATCH 002/113] Add docker config. --- .travis.yml | 1 + test/docker/docker.ca | 29 +++++++++++++++ test/docker/docker.pem | 83 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 test/docker/docker.ca create mode 100644 test/docker/docker.pem diff --git a/.travis.yml b/.travis.yml index d76f0e0..8b64321 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: global: - USE_SYSTEM_GECODE=true - KITCHEN_LOCAL_YAML=.kitchen.travis.yml + - secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U= bundler_args: "--binstubs=$PWD/bin --jobs 3 --retry 3" script: - "./bin/rake travis" diff --git a/test/docker/docker.ca b/test/docker/docker.ca new file mode 100644 index 0000000..f381108 --- /dev/null +++ b/test/docker/docker.ca @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIFCzCCAvOgAwIBAgIJAJTJgn9tSdKmMA0GCSqGSIb3DQEBBQUAMA0xCzAJBgNV +BAMTAkNBMB4XDTE1MDExMjIwMjk0M1oXDTI1MDEwOTIwMjk0M1owDTELMAkGA1UE +AxMCQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDDPFn79sz1kQLk +rAS5z/zfCMXuE+V9IEmGXJeSprsXrv+AdjFpVDr52lpvZ36i2gixk8grcWtFqQMC +jB1c2HUe69ebC89rHSPmGCx5eRcWQPQG29fdH/nC+I34EbYadJB7PdzkvTj0KuN8 +YfQj6lhwqltYiELZhuGoXcuhwZ5SC4VcJ2cdvx7oQPECLlMft8dhWyk15WGhp0jL +2H5noGajz9IFzHieoKJyh+oYA3BYCugpNBLTweNw+NuRxMwHixftvkXvlqKeZ402 +4iwmIO8MG9oUxXs6D85gv6tJOau+dD1EDYH9VzYwSvLto3QBzJX0NiHKlmeq4BG2 +1V3n+N1kZmMDgEtX2TDFsGHlUo77Gw0ob/w7qJU+7GAXRwWw7TPhMBLSkOlGM726 +Lq9p5+7mK1YThk0PmlsSAU6/fT79PSdrYpTKr3WkBTnwd76df+Koh8fpN4BHf9L4 +9bWSYc9Nb9/wp0md9xhzjjVHargpVxZmNH7bcIa8YA9tYaW+oifo2hfb7o0qhGQ1 +8pES3LPUi/qtZkBYUQdh8/mkqTvRjeS446iUmYWcrHyiIzQk/cMbrAVYOi3Xnq0J +ui/r48iv7uLhpcDEQl2mENr0syygrPthVKa4gYHAZ0tK3pfe0yUGMiwS2D23xMR4 +WYLWLwYSK0j1JYpEbsBNS3wZX91FIwIDAQABo24wbDAdBgNVHQ4EFgQU1j2CHhNt +sWAvDmu49yRFfHRBp9kwPQYDVR0jBDYwNIAU1j2CHhNtsWAvDmu49yRFfHRBp9mh +EaQPMA0xCzAJBgNVBAMTAkNBggkAlMmCf21J0qYwDAYDVR0TBAUwAwEB/zANBgkq +hkiG9w0BAQUFAAOCAgEAD7apefon65k3Xey7vsTb/A18m7JwBNLB48ILNcSKVgO1 +iuSMCGNQ+4bNU4o9cTpRoijB3w4RY7IIaDlRcUg8FIO6kgEhjhiAjSSqJAaajOFc +urxOmi9E7xYmTDqLxEGF5/5vaG4olAi3tRgZNd2+Ue0ANZ1KMh3ZkE0nA5v1zb/g +Ax/Zs6tATdoG6umMQg8TjiKucwi9J9he+xJ5y0E77/RrdNL9aKcU47wTAwUkokpb +u1JFo1da3yZLDwQuBN5DCc4pgPgxXlfa6DnzQM1veKIhP5sa9T4sCC8S4IjGFenw +yl4xm+9AOZQeLFpczqgVJhun5P41syepnZ433hWoLXKLHd1n0ILgw9JyVF686LIt +bSar3+krmFuzdRCfet0kJR762p8jmxJOwL+KQGELGlkleJK48a+ruWIeeulZhpJ5 +tF4QJxytq4aXpjeFma0Yi/0rQuNi3H1QIW5YPnFL0XlJ8Rvr8gSVc1zhkM9rsnxX +l9Pun0flP/mf/ulOa020hQUPqEYjSfdJOkLy2gZDvHRL2LRXNjGHoteGNJCq34Q1 +wQerxofHn+Hpp61+Ebj+RLK0KJE+QeP3T8rL30aSSzQZQZJVI0ict5C71kiTbQnw +Z0vE6LquvFfMSqfPLt6uuCRVywBjLx19B7TuMf/DgAD+lR+1FFGKy1hO2Q1jfCY= +-----END CERTIFICATE----- diff --git a/test/docker/docker.pem b/test/docker/docker.pem new file mode 100644 index 0000000..d449b2c --- /dev/null +++ b/test/docker/docker.pem @@ -0,0 +1,83 @@ +-----BEGIN CERTIFICATE----- +MIIFCzCCAvOgAwIBAgIBGzANBgkqhkiG9w0BAQUFADANMQswCQYDVQQDEwJDQTAe +Fw0xNTA3MjIwMDUyNTBaFw0yNTA3MTkwMDUyNTBaMGwxLTArBgNVBAMUJERvY2tl +ciBjbGllbnQgZm9yIGFwcGxpY2F0aW9uX3B5dGhvbjEXMBUGA1UECxMOa2l0Y2hl +bi1kb2NrZXIxIjAgBgNVBAoTGUNvZGVyYW5nZXIgQ29uc3VsdGluZyBMTEMwggIi +MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCsshKxwkNqBbhxyUKn+1z/ZWkW +Zee7IW3uYkxBnsbyXrLKMdW3ClSSvyR6YV4mL+TmfeWYR8bZBQuzABpoNa4wLaFa +JsKUAlnAVNIOP2fd1JfBk2AmqqOx9ZL3JrQv+zYZGx5HeBC1i1vZllWio0qvToMS +OEHkacOB+YvvjCEWAm3dI8vTtGN9S1J8Ql7OtpgqgZfRVIKsPK1fqnJSis9BYzMz +B5kcLI77rs5SYuLIpA7A/t6ZhciK+tOhjlHS2ctLQJ7/5R1GgppWzvxcgmfLV3Vm +a+vFYN0xwb0MQAzXgV149yk+Ap6D4aB1riUw+YJ+zhUXIzo7xteqeMw8pkgdJ9PS +IC3liPDPKGtkyzzdoS3Wmg1MZ1pdnpvFzDct+LYO5czNIbsQGO2OasoAtVjM8ZaF +ZVh0jt4LMYJZvyCkS1FF/C8DM02R26j2hHYwUhQPn5FwzPBmTzoQwihmQIcLCPil +R9YC3SQzbZ759NXSX2HQC83msP/cPVxyilXYNgY9g8sbSBR79NgZs1oYL6xvjbw3 +sTSYFoqpXlDi4b2Atna4gP1jGmCKMlkrA8Wad+QGe/Hfsds9u+fdl/f4f4WYNHQ2 +C6goJn2L76rUya0E7VDvWqfMVyV3RE7oiMPvglsCqFx1Dp8rtSEXt6Y3yQ5uMKZN +27El6ybLXZeMlTnVQQIDAQABoxcwFTATBgNVHSUEDDAKBggrBgEFBQcDAjANBgkq +hkiG9w0BAQUFAAOCAgEASHsNNYaBZ/+D2nHj7wliHU8SQfaXdFrJ1Ei5pGU0Laqb +z2rmtTeFjzq4bBNr6K6fjMEiT5SftTEOMpteCfWEzgHLEvkR9klEMD9es4BKoKkC +aCLLkKGv9135X+rZYWDaWMoksXNC61zVFziRExVa7HZSCiTXM9Hi6A0B9U+iCC4k +Y6era2G2yHSs1JCIWQlOHHLIfk79mtEwd84mfizYjx3Bj93ZTZXESFiRx/2/YbaI +Rr+g24n4zytWXaQb2ocb3HYmvTUkv1keJnaIGJZZFW9rePaRI3f6oVA15qsvwttz +F3UQ4ACpYUd0t2nUha+trFh3Srr2e3KQz8L/10gy6riLW/n2P6AmI6Ukmz/ChIoJ +ZydvbTdwJ0LCg89EFjUQThRszce66Cbd15awZjurfpQymgn1Sa2OXAzwUTuSc2Jr +x5+leiixvudRvfk83TQnabbbdlYY5EoJpjR7iqhgH7ONIl7xUn9WC2DXK99CeWQB +WX10OLXocksL+13IAYdAeLDDIaMvDInm8GZLhdlm+HRga2E30sVq9BwRywsLOP3C +3B2JOPLo4pZdAKOL7aaLI5kDOVuQ8NW/jCuc1JSrca1OSHHEtQ18YyYfsvcfzOdu +MlB8/TF5SzuMiXKo2k1wxDTwh7+ju2tZOc3jTgZCzLYNMn/ebYVivr/MIFwv4cw= +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-256-CBC,50BDE04B335259A3D960185E8205D667 + +eeue1i1tlmzZy3QY21NNLy+m9Bh8BJY9+Bwx+pAC8L7mwSXZdMgESBw6ta41RVoR +DAzT746Bf9tvI7tRSW1XAdY+TV2cRBueIMwm3tkumAqfxVZhWxS2XHyG5lvX1Jik +UBWDNlSnqn8w/uE7jsxnAA4LphreseQoqvOp+WTL1sempOvVW+QyyltxfmTD1pAJ +U6omrTm9BO5LNv7Uri1sRRHTTE1ejXb8xJYt8YQQKjxn2JHap6I0X+nHQ8XGdTY4 +0O9TYGCnar0LHOvvWWAr/Z4DMf0YzjS8yptrJ+C2BIIZF+4ifrW8LrBmK5/X9LFI ++oAW9Tv8sdFYtpZpXheGgFP3dt9HhD7XgnQZ7d8+3hzHELAN+U0YyvWgnmktdBDp +6l0ifgexM121mGbG6JfyAhglKuqGwal+KttmAS4NL8m4ushzlsquUO6fHsYzXrHi +4+NcbJZ2udIn1MZymicztNBRCvGTjKYRgWwl8HG/pHdJ8i8w95xI+yYKwv46OG26 +unk3KrwSm/pc+Ztu+7WqPSjmOB8wsBGbXqaI4CyeM6Tj/5HPE6Mk69Fwk8moas4f +19eA9vzwnMKmyawLFTZ1TRZ3my4GIF1qWglIgtbux8B4Daq1DN9rTDXIroE8XJXL +5h9aHmI3vweslNYRTtLvkN1JCkY71FMv1QoK3FYoAknW0BFosDPG5fJXaiEMVd2c +avD5+CgTBg9T8n3InKR2D3Xae+4PxHlsxMa65GTq303hikcrjlYoEM6zUsb77SOt +W6wuzKPyJtDJzVFt6dIf6nkynxy9ouzRS3tx4XS6dCK+R9Xe0IPcYJiP/8/dmGUx +20qrf8RHCbbSJw8+ou9qT4QnJhExKIifSKmkpdzRxAnFz5p35Fl/wMUSL9QSQjW/ +jpOUEAtGVZsmR2wqmjQdrfLydwHAG1DnOuljHwpFuJ5QgQfXH+pvq7PmyVH0r4cM ++NdUUIOeKQXX0z3nVWIXhPyqUa6nPGRxF+KySspCae6ehkrXA3sV//955WL0YBF3 +v6JNBLN9FQnO86EfJsMvVN3X23tKb9j2DvmWITFqgJT4HJvBNLVfRUyxYW/9sAO6 +RUjoDq9nnwk7U2WVrCVuOEwx2D51AQebY2pB9uvxynC7sIF9AMQ4a+wIR5T7gM/V +m5hIC54ARWE3ReJRsRKxqygU1GE0OQLB6Zq2HNRUM6CyHFULoKp0EJfJE23u2B0S +6n2u+AFRHb37Db8Kv5pInbyPsij/eX6Pis3iOE+qa4Az3wZuYd3Y8Ouiu2SeSKbv +9ThjvkU2cvWcIEKYtSuH6JXTbFtyrnxT3djdYu8puPl6LjHsSCMZyPLN2JOLVpuk +rtVm9qhZwv3e6QoDRWrtJd4h3GOYolh+f6MIa3em/uLZCz816mAgRksuI53PI4Dv +OQG2MwZdFh2b9d+iegKwsTxq6SbULUD/aagEapM5Yn05JPaCUSdzjPnTSS0YDcps +Bf4RFW8MTPLxkYrc77EZwK8ncMs9xyY7YOfbA3+tYHeBy/NfQxGv70Dz8+gcLACY +6/1xAvD2pkhvCKal3KtJ8vjIhZURdLgc+dNaPStjTY2PwzGQcimucE1ksOh+WGX+ +L/4cYWYzSVD4NzOly+73Bf0cghs9lKUYHS3PA+GCwN4QgNFTRqNHDdJdd2IQjLPn +36ZKmv1Nby1ywxsWQ4vmxOwpN8tPEVoK6T1PsVh07fxnDpuy2dUsWTh+BxauLrfq +iCpLAyHsb9es+gjqWPUNnCPWDnVjUvwHcMIyfyR/Kq2KXI46uDNvKblVhV2MiZb+ +WukdXU91ZWbngd8YJTWQbedPvKDg/ifuAr7I5xpnhlr0GkdnV460l4+5am+N3wiS +UWl26tiivV8yFHIQtX0tmMUlGPDkTvYG71aa++MVZDg5kqQvSgBmxAs4Z8yUEU7N +d+hwKOIyEQVXALWLoKG+NZ4fga3yN6rY95qpsVrIJQbleSig034okc53rfVat1D6 +X9neZ1Ey8DBIheeqvwih6Xz/xxl2XruF+N6AViknagqfm9K9T2tilQt7IE253BYZ +OKwkMOfR4zEuRa8+hejImALEOHxKcCPoYzY1uXHNGGAE8jRHGyqsGXdIcifXQErw +NVY+UYOlVyGj3QPyUSmAYN51QUanJzd7PO3b8rdNOzX43RfyiKmECyMawUa3k505 +6Epa5TYNBx4rL7DHpoE4eqMogiVpgw6YHMNXjUvJFTqX+zI0AAADNI7U+M0YLoAs +b7Vlqji7cAIo8/HFyAY4Hmj2lq0D73sDd/LYB6dMY0br5qkhqVnINMBidN1U0oZc +YbdBPAMBqZkCtEUyfHeQ76HHyXqFYfiRZLzRD0r/2OtrH6VGYu4Iu41QjQbO8k3m +vAnTMh8xCEa+t+zQWu36iZkNoUnI+KtQTMHovYQ6sH6mHFNRSfx0ElLenqXpZ4xT +HdPIsgAdIZdFApQe+IAsdmcg0GvPYjs9AqjDuT91lXrnpRcPxTFjfH7nz/3aKaOO +7s0JPE9D5SSvl6zH7rN8yK6sXPSKojJFs0jHhn710yyoortkIej8usgkimDaYgrv +bOF1RNO0gi03aiqGvKI0pEOWpKrSAXONcqUniv1K+ttlGurgTyJZmHhwwLIFVdus +juD6PXkxjkX6L9R55+PLhaGOpBP9JSxb4gXGjX9Qbn6cuNEw7IBDssR0ifvxjXCu +wl1jbW0TaO3ol+C1f2/cKLXSzfnAF7WXf1mR6yUTn8cT8mS7yWaHJFoUDwUPA99l +9b18paZR+EwZtsR31pjijnDHwycsH75nsLTddVUc7yYptgmXtHuHyZY3FT7HixD7 +Zlwz30watxcBEopb7eq0ExSY4Ri+L9rV5gBYRzazlBM7J3xN1K8sAdkReclx5ms4 +1Ez/hv7m2xkNysPpRO8SCGoMjr/UxYL+kFI/1Y/DvvSx1EpX9SkoaAF5YB7Z89+N +uTD7PFVmqS0ZFUcXvrxGi1TGEvCWHsA6NY1wDNfzI7FiZCx1E0YjTWGjkdw5d/b3 +eCfhBCAQHJHC2/PX4s8MdgyAB/jatTjglCjAYPXO7PZqyOe1RyP7pxhd2eqEbJH3 +6/keQNj+O/TdUG47LUI2D/uZ92hNRenvuu5cMhRrUivBYhiw0X3w0bidGFSw5O/h +-----END RSA PRIVATE KEY----- From 5bc1bc4216b99477cc32017076f4cd1769f61f21 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 18:50:03 -0700 Subject: [PATCH 003/113] First pass on a gunicorn resource and a flask app using it. --- .kitchen.yml | 1 + lib/poise_application_python.rb | 1 + lib/poise_application_python/resources.rb | 2 + .../resources/.gitkeep | 0 .../resources/gunicorn.rb | 91 +++++++++++++++++++ .../application_python_test/recipes/flask.rb | 25 +++++ .../default/serverspec/flask_spec.rb | 40 ++++++++ test/spec/resources/gunicorn_spec.rb | 57 ++++++++++++ 8 files changed, 217 insertions(+) delete mode 100644 lib/poise_application_python/resources/.gitkeep create mode 100644 lib/poise_application_python/resources/gunicorn.rb create mode 100644 test/cookbooks/application_python_test/recipes/flask.rb create mode 100644 test/integration/default/serverspec/flask_spec.rb create mode 100644 test/spec/resources/gunicorn_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index bb6c069..d530aac 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -6,3 +6,4 @@ suites: - name: default run_list: - recipe[application_python_test] + - recipe[application_python_test::flask] diff --git a/lib/poise_application_python.rb b/lib/poise_application_python.rb index 2f3d1d5..279c1e4 100644 --- a/lib/poise_application_python.rb +++ b/lib/poise_application_python.rb @@ -16,6 +16,7 @@ module PoiseApplicationPython + autoload :Error, 'poise_application_python/error' autoload :Resources, 'poise_application_python/resources' autoload :VERSION, 'poise_application_python/version' end diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index e2840da..8498c32 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -13,3 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # + +require 'poise_application_python/resources/gunicorn' diff --git a/lib/poise_application_python/resources/.gitkeep b/lib/poise_application_python/resources/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb new file mode 100644 index 0000000..51a4c3a --- /dev/null +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -0,0 +1,91 @@ +# +# 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. +# + +require 'chef/provider' +require 'chef/resource' +require 'poise' +require 'poise_application/service_mixin' +require 'poise_python/python_command_mixin' + + +module PoiseApplicationPython + module Resources + # (see Gunicorn::Resource) + # @since 4.0.0 + module Gunicorn + class Resource < Chef::Resource + include PoiseApplication::ServiceMixin + include PoisePython::PythonCommandMixin + provides(:application_gunicorn) + + attribute(:path, kind_of: String, name_attribute: true) + attribute(:app_module, kind_of: String, default: lazy { default_app_module }) + attribute(:port, kind_of: [String, Integer], default: 80) + attribute(:version, kind_of: [String, TrueClass, FalseClass], default: true) + + def default_app_module + # If set in app_state, use that. + return app_state[:python_app_module] if app_state[:python_app_module] + files = Dir.entries(path) + # Try to find a known filename. + candidate_file = %w{wsgi.py main.py app.py application.py}.find {|file| files.include?(file) } + # Try the first Python file. Do I really want this? + candidate_file ||= files.find {|file| file.end_with?('.py') } + if candidate_file + ::File.basename(candidate_file, '.py') + else + raise PoiseApplicationPython::Error.new("Unable to determine app module for #{self}") + end + end + + end + + class Provider < Chef::Provider + include PoiseApplication::ServiceMixin + provides(:application_gunicorn) + + def action_enable + notifying_block do + install_gunicorn + end + super + end + + private + + def install_gunicorn + return unless new_resource.version + python_package 'gunicorn' do + # Set the parent, could be either a resource or path string. + if new_resource.parent_python + parent_python new_resource.parent_python + elsif new_resource.python + python new_resource.python + end + version new_resource.version if new_resource.version.is_a?(String) + end + end + + # (see PoiseApplication::ServiceMixin#service_options) + def service_options(resource) + super + resource.command("#{new_resource.python} -m gunicorn.app.wsgiapp --bind 0.0.0.0:#{new_resource.port} #{new_resource.app_module}") + end + + end + end + end +end diff --git a/test/cookbooks/application_python_test/recipes/flask.rb b/test/cookbooks/application_python_test/recipes/flask.rb new file mode 100644 index 0000000..2098b1a --- /dev/null +++ b/test/cookbooks/application_python_test/recipes/flask.rb @@ -0,0 +1,25 @@ +# +# 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. +# + +include_recipe 'poise-python' + +application '/opt/test_flask' do + git 'https://github.com/poise/test_flask.git' + python_requirements + gunicorn do + port 9000 + end +end diff --git a/test/integration/default/serverspec/flask_spec.rb b/test/integration/default/serverspec/flask_spec.rb new file mode 100644 index 0000000..3a2f730 --- /dev/null +++ b/test/integration/default/serverspec/flask_spec.rb @@ -0,0 +1,40 @@ +# +# 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. +# + +require 'net/http' + +require 'serverspec' +set :backend, :exec + + +describe 'sinatra' do + describe port(9000) do + it { is_expected.to be_listening } + end + + let(:http) { Net::HTTP.new('localhost', 9000) } + + describe '/foo' do + subject { http.get('/foo') } + its(:code) { is_expected.to eq '404' } + end + + describe '/hi' do + subject { http.get('/hi') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to eq 'Hello World!' } + end +end diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb new file mode 100644 index 0000000..034e535 --- /dev/null +++ b/test/spec/resources/gunicorn_spec.rb @@ -0,0 +1,57 @@ +# +# 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. +# + +require 'spec_helper' + +describe PoiseApplicationPython::Resources::Gunicorn do + describe PoiseApplicationPython::Resources::Gunicorn::Resource do + describe '#default_app_module' do + let(:app_state) { {} } + let(:files) { [] } + let(:test_resource) { described_class.new(nil, nil) } + before do + allow(test_resource).to receive(:app_state).and_return(app_state) + allow(Dir).to receive(:entries).and_return(files) + end + subject { test_resource.send(:default_app_module) } + + context 'with an app_state key' do + let(:app_state) { {python_app_module: 'django'} } + it { is_expected.to eq 'django' } + end # /context with an app_state key + + context 'with a wsgi.py' do + let(:files) { %w{wsgi.py} } + it { is_expected.to eq 'wsgi' } + end # /context with a wsgi.py + + context 'with an app.py and main.py' do + let(:files) { %w{app.py main.py} } + it { is_expected.to eq 'main' } + end # /context with an app.py and main.py + + context 'with a foo.txt and bar.py' do + let(:files) { %w{foo.txt bar.py} } + it { is_expected.to eq 'bar' } + end # /context with a foo.txt and bar.py + + context 'with a foo.txt' do + let(:files) { %w{foo.txt } } + it { expect { subject }.to raise_error PoiseApplicationPython::Error } + end # /context with a foo.txt + end # /describe #default_app_module + end # /describe PoiseApplicationPython::Resources::Gunicorn::Resource +end From cf7632b9ce94d48e6bce0e21038f912d6e5b93c3 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 18:50:09 -0700 Subject: [PATCH 004/113] Don't need anymore. --- Gemfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index b593dff..d2d43f0 100644 --- a/Gemfile +++ b/Gemfile @@ -35,5 +35,3 @@ dev_gem 'poise-boiler' dev_gem 'poise-languages', github: 'poise/poise-languages' dev_gem 'poise-python', github: 'poise/poise-python' dev_gem 'poise-service', github: 'poise/poise-service' - -gem 'kitchen-docker', github: 'portertech/kitchen-docker' From 6c33b47c17dfd56859a0753bccc1ec0c823ace07 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 19:00:06 -0700 Subject: [PATCH 005/113] Pedantic whitespace. --- test/integration/default/serverspec/flask_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/default/serverspec/flask_spec.rb b/test/integration/default/serverspec/flask_spec.rb index 3a2f730..575293e 100644 --- a/test/integration/default/serverspec/flask_spec.rb +++ b/test/integration/default/serverspec/flask_spec.rb @@ -19,7 +19,6 @@ require 'serverspec' set :backend, :exec - describe 'sinatra' do describe port(9000) do it { is_expected.to be_listening } From 0fe7dedf450fb2c37ef0fc76983af2e90bdc9dd1 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 19:12:15 -0700 Subject: [PATCH 006/113] Pull poise from master for now. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d2d43f0..d9b0a95 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ def dev_gem(name, path: File.join('..', name), github: nil) end dev_gem 'halite' -dev_gem 'poise' +dev_gem 'poise', github: 'poise/github' dev_gem 'poise-application', path: '../application', github: 'poise/application' dev_gem 'poise-application-git', path: '../application_git', github: 'poise/application_git' dev_gem 'poise-boiler' From 3817b2126896eb87cfc46ab48de46784aace40f7 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 19:18:57 -0700 Subject: [PATCH 007/113] I should be paying attention when I type things. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d9b0a95..f09fcb7 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ def dev_gem(name, path: File.join('..', name), github: nil) end dev_gem 'halite' -dev_gem 'poise', github: 'poise/github' +dev_gem 'poise', github: 'poise/poise' dev_gem 'poise-application', path: '../application', github: 'poise/application' dev_gem 'poise-application-git', path: '../application_git', github: 'poise/application_git' dev_gem 'poise-boiler' From 59fe8e9567c7b7f4a85bf535ef3516fd2c0d5a94 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Jul 2015 19:45:47 -0700 Subject: [PATCH 008/113] Unbreak tests. This should probably go in a mixin though. --- lib/poise_application_python/resources/gunicorn.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 51a4c3a..9e9698a 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -83,6 +83,7 @@ def install_gunicorn def service_options(resource) super resource.command("#{new_resource.python} -m gunicorn.app.wsgiapp --bind 0.0.0.0:#{new_resource.port} #{new_resource.app_module}") + resource.environment.update(new_resource.parent_python.python_environment) if new_resource.parent_python end end From 9a662ff6dbd73d44e121a11b00c9fb3694031bba Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 22 Jul 2015 16:42:52 -0700 Subject: [PATCH 009/113] Moving forward on gunicorn config. --- .../resources/gunicorn.rb | 46 ++++++++++++++++++- test/spec/resources/gunicorn_spec.rb | 19 ++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 9e9698a..808cd3d 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -14,6 +14,8 @@ # limitations under the License. # +require 'shellwords' + require 'chef/provider' require 'chef/resource' require 'poise' @@ -33,9 +35,26 @@ class Resource < Chef::Resource attribute(:path, kind_of: String, name_attribute: true) attribute(:app_module, kind_of: String, default: lazy { default_app_module }) - attribute(:port, kind_of: [String, Integer], default: 80) + attribute(:bind, kind_of: [String, Array], default: '0.0.0.0:80') + attribute(:config, kind_of: [String, NilClass]) + attribute(:preload_app, equal_to: [true, false], default: false) attribute(:version, kind_of: [String, TrueClass, FalseClass], default: true) + # Helper to set {#bind} with just a port number. + # + # @param val [String, Integer] Port number to use. + # @return [void] + def port(val) + bind("0.0.0.0:#{val}") + end + + private + + # Compute the default application module to pass to gunicorn. This + # checks the app state and then looks for commonly used filenames. + # Raises an exception if no default can be found. + # + # @return [String] def default_app_module # If set in app_state, use that. return app_state[:python_app_module] if app_state[:python_app_module] @@ -79,10 +98,33 @@ def install_gunicorn end end + def gunicorn_command_options + # Based on http://docs.gunicorn.org/en/latest/settings.html + [].tap do |cmd| + # What options are common enough to deal with here? + # %w{config backlog workers worker_class threads worker_connections timeout graceful_timeout keepalive}.each do |opt| + %w{config}.each do |opt| + val = new_resource.send(opt) + if val && !(val.respond_to?(:empty?) && val.empty?) + cmd_opt = opt.gsub(/_/, '-') + cmd << "--#{cmd_opt} #{Shellwords.escape(val)}" + end + end + # Can be given multiple times. + Array(new_resource.bind).each do |bind| + cmd << "--bind #{bind}" if bind + end + # --preload doesn't take an argument and the name doesn't match. + if new_resource.preload_app + cmd << '--preload' + end + end + end + # (see PoiseApplication::ServiceMixin#service_options) def service_options(resource) super - resource.command("#{new_resource.python} -m gunicorn.app.wsgiapp --bind 0.0.0.0:#{new_resource.port} #{new_resource.app_module}") + resource.command("#{new_resource.python} -m gunicorn.app.wsgiapp #{gunicorn_command_options.join(' ')} #{new_resource.app_module}") resource.environment.update(new_resource.parent_python.python_environment) if new_resource.parent_python end diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index 034e535..8528fcb 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -54,4 +54,23 @@ end # /context with a foo.txt end # /describe #default_app_module end # /describe PoiseApplicationPython::Resources::Gunicorn::Resource + + describe PoiseApplicationPython::Resources::Gunicorn::Provider do + let(:new_resource) { double('new_resource') } + let(:test_provider) { described_class.new(new_resource, nil) } + + describe '#gunicorn_command_options' do + let(:props) { {} } + let(:new_resource) { PoiseApplicationPython::Resources::Gunicorn::Resource.new('/test', nil) } + subject { test_provider.send(:gunicorn_command_options).join(' ') } + before do + props.each {|key, value| new_resource.send(key, value) } + end + + context 'with defaults' do + it { is_expected.to eq '--bind 0.0.0.0:80' } + end # /context with defaults + + end # /describe #gunicorn_command_options + end # /describe PoiseApplicationPython::Resources::Gunicorn::Provider end From 7de35c8f66dfc1f98f1df52c877b709ace11fa87 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 22 Jul 2015 16:57:43 -0700 Subject: [PATCH 010/113] More tests. --- test/spec/resources/gunicorn_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index 8528fcb..7d54d90 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -71,6 +71,25 @@ it { is_expected.to eq '--bind 0.0.0.0:80' } end # /context with defaults + context 'with a config file' do + let(:props) { {config: '/test/myconfig.py'} } + it { is_expected.to eq '--config /test/myconfig.py --bind 0.0.0.0:80' } + end # /context with a config file + + context 'with a blank config file' do + let(:props) { {config: ''} } + it { is_expected.to eq '--bind 0.0.0.0:80' } + end # /context with a blank config file + + context 'with two binds' do + let(:props) { {bind: %w{0.0.0.0:80 0.0.0.0:81}} } + it { is_expected.to eq '--bind 0.0.0.0:80 --bind 0.0.0.0:81' } + end # /context with two binds + + context 'with a config file and preload' do + let(:props) { {config: '/test/myconfig.py', preload_app: true} } + it { is_expected.to eq '--config /test/myconfig.py --bind 0.0.0.0:80 --preload' } + end # /context with a config file and preload end # /describe #gunicorn_command_options end # /describe PoiseApplicationPython::Resources::Gunicorn::Provider end From 600bbc8e2b578b6a5640a005f72e1aba89fd2f5d Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 24 Jul 2015 14:28:28 -0700 Subject: [PATCH 011/113] Renamed. --- test/cookbooks/application_python_test/recipes/flask.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cookbooks/application_python_test/recipes/flask.rb b/test/cookbooks/application_python_test/recipes/flask.rb index 2098b1a..4fbbfa1 100644 --- a/test/cookbooks/application_python_test/recipes/flask.rb +++ b/test/cookbooks/application_python_test/recipes/flask.rb @@ -18,7 +18,7 @@ application '/opt/test_flask' do git 'https://github.com/poise/test_flask.git' - python_requirements + pip_requirements gunicorn do port 9000 end From b07c663e0119238a32c3caf1c114e62e7046cbbf Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 26 Jul 2015 20:05:43 -0700 Subject: [PATCH 012/113] Use the new helper! --- lib/poise_application_python/resources/gunicorn.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 808cd3d..8583542 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -88,12 +88,7 @@ def action_enable def install_gunicorn return unless new_resource.version python_package 'gunicorn' do - # Set the parent, could be either a resource or path string. - if new_resource.parent_python - parent_python new_resource.parent_python - elsif new_resource.python - python new_resource.python - end + python_from_parent new_resource version new_resource.version if new_resource.version.is_a?(String) end end From 9cedfee48b301e8048981dbab6dce9b2810a7bbe Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 26 Jul 2015 20:05:50 -0700 Subject: [PATCH 013/113] Use the new helper! From 1a7e5a136e8deab26dac1e0c255d373e8f4fff71 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 26 Jul 2015 20:07:07 -0700 Subject: [PATCH 014/113] Switch to port 9001 in anticipation of Django tests. --- test/cookbooks/application_python_test/recipes/flask.rb | 2 +- test/integration/default/serverspec/flask_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cookbooks/application_python_test/recipes/flask.rb b/test/cookbooks/application_python_test/recipes/flask.rb index 4fbbfa1..17bbd6c 100644 --- a/test/cookbooks/application_python_test/recipes/flask.rb +++ b/test/cookbooks/application_python_test/recipes/flask.rb @@ -20,6 +20,6 @@ git 'https://github.com/poise/test_flask.git' pip_requirements gunicorn do - port 9000 + port 9001 end end diff --git a/test/integration/default/serverspec/flask_spec.rb b/test/integration/default/serverspec/flask_spec.rb index 575293e..a2bf4d8 100644 --- a/test/integration/default/serverspec/flask_spec.rb +++ b/test/integration/default/serverspec/flask_spec.rb @@ -19,12 +19,12 @@ require 'serverspec' set :backend, :exec -describe 'sinatra' do - describe port(9000) do +describe 'flask' do + describe port(9001) do it { is_expected.to be_listening } end - let(:http) { Net::HTTP.new('localhost', 9000) } + let(:http) { Net::HTTP.new('localhost', 9001) } describe '/foo' do subject { http.get('/foo') } From 19fcb3fc70517200c796421ef7369f32b0b0dd79 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 26 Jul 2015 20:07:29 -0700 Subject: [PATCH 015/113] Django resource! Still needs more on the config output and whatnot but it does seem to work. --- .kitchen.yml | 1 + lib/poise_application_python/app_mixin.rb | 42 +++ lib/poise_application_python/resources.rb | 1 + .../resources/django.rb | 247 ++++++++++++++++++ .../application_python_test/recipes/django.rb | 31 +++ .../default/serverspec/django_spec.rb | 56 ++++ 6 files changed, 378 insertions(+) create mode 100644 lib/poise_application_python/app_mixin.rb create mode 100644 lib/poise_application_python/resources/django.rb create mode 100644 test/cookbooks/application_python_test/recipes/django.rb create mode 100644 test/integration/default/serverspec/django_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index d530aac..50dc9dd 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -6,4 +6,5 @@ suites: - name: default run_list: - recipe[application_python_test] + - recipe[application_python_test::django] - recipe[application_python_test::flask] diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb new file mode 100644 index 0000000..a1907cf --- /dev/null +++ b/lib/poise_application_python/app_mixin.rb @@ -0,0 +1,42 @@ +# +# 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. +# + +require 'chef/mash' +require 'poise/utils' +require 'poise_application/app_mixin' +require 'poise_python/python_command_mixin' + + +module PoiseApplicationPython + module AppMixin + include Poise::Utils::ResourceProviderMixin + + module Resource + include PoiseApplication::AppMixin::Resource + include PoisePython::PythonCommandMixin::Resource + + def app_state_environment_python + env = app_state_environment + env = env.merge(parent_python.python_environment) if parent_python + env + end + end + + module Provider + include PoiseApplication::AppMixin::Provider + end + end +end diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index 8498c32..e977c18 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -14,4 +14,5 @@ # limitations under the License. # +require 'poise_application_python/resources/django' require 'poise_application_python/resources/gunicorn' diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb new file mode 100644 index 0000000..399d7c3 --- /dev/null +++ b/lib/poise_application_python/resources/django.rb @@ -0,0 +1,247 @@ +# +# 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. +# + +require 'uri' + +require 'chef/provider' +require 'chef/resource' +require 'poise' +require 'poise_application' +require 'poise_python' + +require 'poise_application_python/app_mixin' +require 'poise_application_python/error' + + +module PoiseApplicationPython + module Resources + # (see Django::Resource) + # @since 4.0.0 + module Django + # Aliases for Django database engine names. Based on https://github.com/kennethreitz/dj-database-url/blob/master/dj_database_url.py + # Copyright 2014, Kenneth Reitz. + ENGINE_ALIASES = { + 'postgres' => 'django.db.backends.postgresql_psycopg2', + 'postgresql' => 'django.db.backends.postgresql_psycopg2', + 'pgsql' => 'django.db.backends.postgresql_psycopg2', + 'postgis' => 'django.contrib.gis.db.backends.postgis', + 'mysql2' => 'django.db.backends.mysql', + 'mysqlgis' => 'django.contrib.gis.db.backends.mysql', + 'spatialite' => 'django.contrib.gis.db.backends.spatialite', + 'sqlite' => 'django.db.backends.sqlite3', + } + + # An `application_django` resource to configure Django applications. + # + # @since 4.0.0 + # @provides application_django + # @action deploy + # @example + # application '/srv/myapp' do + # git '...' + # pip_requirements + # django do + # database do + # host node['rails_host'] + # end + # end + # gunicorn do + # port 8080 + # end + # end + class Resource < Chef::Resource + include PoiseApplicationPython::AppMixin + provides(:application_django) + actions(:deploy) + + # @!attribute path + # Application base path. + # @return [String] + attribute(:path, kind_of: String, name_attribute: true) + # @!attribute collectstatic + # Set to false to disable running manage.py collectstatic during + # deployment. + # @todo This could auto-detect based on config vars in settings? + # @return [Boolean] + attribute(:collectstatic, equal_to: [true, false], default: true) + # @!attribute database + # Option collector attribute for Django database configuration. + # @return [Hash] + # @example Setting via block + # database do + # engine 'postgresql' + # database 'blog' + # end + # @example Setting via URL + # database 'postgresql://localhost/blog' + attribute(:database, option_collector: true, parser: :parse_database_url) + # @!attribute local_settings + # Template content attribute for the contents of local_settings.py. + # @todo Redo this doc to cover the actual attributes created. + # @return [Poise::Helpers::TemplateContent] + attribute(:local_settings, template: true, default_source: 'settings.py.erb', default_options: lazy { default_local_settings_options }) + # @!attribute 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. Defaults to local_settings.py next to + # {#setting_module}. + # @return [String, nil false] + attribute(:local_settings_path, kind_of: [String, NilClass, FalseClass], default: lazy { default_local_settings_path }) + # @!attribute migrate + # Run database migrations. This is a bad idea for real apps. Please + # do not use it. + # @return [Boolean] + attribute(:migrate, equal_to: [true, false], default: false) + # @!attribute manage_path + # Path to manage.py. Defaults to scanning for the nearest manage.py + # to {#path}. + # @return [String] + attribute(:manage_path, kind_of: String, default: lazy { default_manage_path }) + # @!attribute settings_module + # Django settings module in dotted notation. Set to false to disable + # anything related to settings. Defaults to scanning for the nearest + # settings.py to {#path}. + # @return [Boolean] + attribute(:settings_module, kind_of: [String, NilClass, FalseClass], default: lazy { default_settings_module }) + # @!attribute syncdb + # Run database sync. This is a bad idea for real apps. Please do not + # use it. + # @return [Boolean] + attribute(:syncdb, equal_to: [true, false], default: false) + # @!attribute wsgi_module + # WSGI application module in dotted notation. Set to false to disable + # anything related to WSGI. Defaults to scanning for the nearest + # wsgi.py to {#path}. + # @return [Boolean] + attribute(:wsgi_module, kind_of: [String, NilClass, FalseClass], default: lazy { default_wsgi_module }) + + private + + def default_local_settings_options + raise todo + end + + def default_local_settings_path + # If no settings module, no default local settings. + return unless settings_module + settings_path = PoisePython::Utils.module_to_path(settings_module, path) + ::File.expand_path(::File.join('..', 'local_settings.py'), settings_path) + end + + def default_manage_path + find_file('manage.py') + end + + def default_settings_module + PoisePython::Utils.path_to_module(find_file('settings.py'), path) + end + + def default_wsgi_module + PoisePython::Utils.path_to_module(find_file('wsgi.py'), path) + end + + # Format a URL for DATABASES. + # + # @return [Hash] + def parse_database_url(url) + + parsed = URI(url) + {}.tap do |db| + # Store this for use later in #set_state, and maybe future use by + # Django in some magic world where operability happens. + db[:URL] = url + db[:ENGINE] = ENGINE_ALIASES[parsed.scheme] || "django.db.backends.#{parsed.scheme}" if parsed.scheme && !parsed.scheme.empty? + # Strip the leading /. + path = parsed.path ? parsed.path[1..-1] : parsed.path + # If we are using SQLite, make it an absolute path. + path = ::File.expand_path(path, self.path) if db[:ENGINE].include?('sqlite') + db[:NAME] = path if path && !path.empty? + db[:USER] = parsed.user if parsed.user && !parsed.user.empty? + db[:PASSWORD] = parsed.password if parsed.password && !parsed.password.empty? + db[:HOST] = parsed.host if parsed.host && !parsed.host.empty? + db[:PORT] = parsed.port if parsed.port && !parsed.port.empty? + end + end + + def find_file(name) + Dir[::File.join(path, '**', name)].min do |a, b| + cmp = a.count(::File::SEPARATOR) <=> b.count(::File::SEPARATOR) + if cmp == 0 + cmp = a <=> b + end + cmp + end.tap do |p| + raise PoiseApplicationPython::Error.new("Unable to find a file matching #{name}") unless p + end + end + + end + + class Provider < Chef::Provider + include PoiseApplicationPython::AppMixin + provides(:application_django) + + def action_deploy + set_state + notifying_block do + run_syncdb + run_migrate + run_collectstatic + write_config + end + end + + private + + def set_state + # Set environment variables for later services. + new_resource.app_state_environment[:DJANGO_SETTINGS_MODULE] = new_resource.settings_module if new_resource.settings_module + new_resource.app_state_environment[:DATABASE_URL] = new_resource.database[:URL] if new_resource.database[:URL] + # Set the app module. + new_resource.app_state[:python_app_module] = new_resource.wsgi_module if new_resource.wsgi_module + end + + def run_syncdb + manage_py_execute('syncdb', '--noinput') if new_resource.syncdb + end + + def run_migrate + manage_py_execute('migrate', '--noinput') if new_resource.migrate + end + + def run_collectstatic + manage_py_execute('collectstatic', '--noinput') if new_resource.collectstatic + end + + def write_config + # Allow disabling the local settings. + return unless new_resource.local_settings_path + # todo + end + + def manage_py_execute(*cmd) + python_execute "manage.py #{cmd.join(' ')}" do + python_from_parent new_resource + command [new_resource.manage_path] + cmd + environment new_resource.app_state_environment + cwd new_resource.path + end + end + + end + end + end +end diff --git a/test/cookbooks/application_python_test/recipes/django.rb b/test/cookbooks/application_python_test/recipes/django.rb new file mode 100644 index 0000000..0320073 --- /dev/null +++ b/test/cookbooks/application_python_test/recipes/django.rb @@ -0,0 +1,31 @@ +# +# 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. +# + +include_recipe 'poise-python' + +package value_for_platform_family(debian: 'libpq-dev', rhel: 'postgresql-devel') + +application '/opt/test_django' do + git 'https://github.com/poise/test_django.git' + pip_requirements + django do + database 'sqlite:///test_django.db' + migrate true + end + gunicorn do + port 9000 + end +end diff --git a/test/integration/default/serverspec/django_spec.rb b/test/integration/default/serverspec/django_spec.rb new file mode 100644 index 0000000..11af75a --- /dev/null +++ b/test/integration/default/serverspec/django_spec.rb @@ -0,0 +1,56 @@ +# +# 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. +# + +require 'net/http' + +require 'serverspec' +set :backend, :exec + +describe 'django' do + describe port(9000) do + it { is_expected.to be_listening } + end + + let(:http) { Net::HTTP.new('localhost', 9000) } + + describe '/foo' do + subject { http.get('/foo') } + its(:code) { is_expected.to eq '404' } + end + + describe '/admin/login/' do + subject { http.get('/admin/login/') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to include 'Polls Administration' } + end + + describe '/polls/' do + subject { http.get('/polls/') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to include 'No polls are available.' } + end + + describe '/static/polls/style.css' do + subject { http.get('/static/polls/style.css') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to include 'color: green;' } + end + + describe '/static/polls/images/background.gif' do + subject { http.get('/static/polls/images/background.gif') } + its(:code) { is_expected.to eq '200' } + end +end From 1e17cc3d6e8589f48a12bf7c0cec1359b78df652 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 26 Jul 2015 20:27:26 -0700 Subject: [PATCH 016/113] Need compiler for postgres binding. --- test/cookbooks/application_python_test/recipes/django.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cookbooks/application_python_test/recipes/django.rb b/test/cookbooks/application_python_test/recipes/django.rb index 0320073..9aee66f 100644 --- a/test/cookbooks/application_python_test/recipes/django.rb +++ b/test/cookbooks/application_python_test/recipes/django.rb @@ -14,6 +14,7 @@ # limitations under the License. # +include_recipe 'build-essential' include_recipe 'poise-python' package value_for_platform_family(debian: 'libpq-dev', rhel: 'postgresql-devel') From 95e213aae29e7f90cf6d4bfae8f69a82e7d74509 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 28 Jul 2015 18:58:16 -0700 Subject: [PATCH 017/113] Make app_mixin autoloaded. --- lib/poise_application_python.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/poise_application_python.rb b/lib/poise_application_python.rb index 279c1e4..9428658 100644 --- a/lib/poise_application_python.rb +++ b/lib/poise_application_python.rb @@ -16,6 +16,7 @@ module PoiseApplicationPython + autoload :AppMixin, 'poise_application_python/app_mixin' autoload :Error, 'poise_application_python/error' autoload :Resources, 'poise_application_python/resources' autoload :VERSION, 'poise_application_python/version' From 4d4485e92bf65fa7014e37ca3307ba2cb620a239 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 28 Jul 2015 19:03:18 -0700 Subject: [PATCH 018/113] Make parent_python check for a default in the app state before trying global lookup. This uses the new default flag for parent links. Not super happy with this but refactoring will require the full Property backport. --- lib/poise_application_python/app_mixin.rb | 9 ++++ test/spec/app_mixin_spec.rb | 63 +++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test/spec/app_mixin_spec.rb diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb index a1907cf..fe8f2f4 100644 --- a/lib/poise_application_python/app_mixin.rb +++ b/lib/poise_application_python/app_mixin.rb @@ -28,6 +28,15 @@ module Resource include PoiseApplication::AppMixin::Resource include PoisePython::PythonCommandMixin::Resource + parent_attribute(:python, type: :python_runtime, optional: true, default: lazy { app_state_python }) + + def app_state_python(*args) + unless args.empty? + app_state[:python] = args.first + end + app_state[:python] + end + def app_state_environment_python env = app_state_environment env = env.merge(parent_python.python_environment) if parent_python diff --git a/test/spec/app_mixin_spec.rb b/test/spec/app_mixin_spec.rb new file mode 100644 index 0000000..01eee25 --- /dev/null +++ b/test/spec/app_mixin_spec.rb @@ -0,0 +1,63 @@ +# +# 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. +# + +require 'spec_helper' +require 'poise_application/cheftie' +require 'poise_python/cheftie' + +describe PoiseApplicationPython::AppMixin do + describe '#parent_python' do + resource(:poise_test) do + include described_class + end + provider(:poise_test) + + context 'with an app_state python' do + recipe do + python_runtime 'outer' + application '/test' do + app_state[:python] = PoisePython::Resources::PythonRuntime::Resource.new('inner', run_context) + poise_test + end + end + let(:python) { chef_run.application('/test').app_state[:python] } + + it { is_expected.to run_poise_test('/test').with(parent_python: python) } + it { expect(python).to be_a Chef::Resource } + end # /context with an app_state python + + context 'with a global python' do + recipe do + python_runtime 'outer' + application '/test' do + poise_test + end + end + + it { is_expected.to run_poise_test('/test').with(parent_python: chef_run.python_runtime('outer')) } + end # /context with a global python + + context 'with no python' do + recipe do + application '/test' do + poise_test + end + end + + it { is_expected.to run_poise_test('/test').with(parent_python: nil) } + end # /context with no python + end # /describe #parent_python +end From 36de9a0381b24ba173672d8e6c25b160725fa9c3 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 29 Jul 2015 12:10:40 -0700 Subject: [PATCH 019/113] Expanded app_mixin spec. --- test/spec/app_mixin_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/spec/app_mixin_spec.rb b/test/spec/app_mixin_spec.rb index 01eee25..9fa3116 100644 --- a/test/spec/app_mixin_spec.rb +++ b/test/spec/app_mixin_spec.rb @@ -32,10 +32,16 @@ app_state[:python] = PoisePython::Resources::PythonRuntime::Resource.new('inner', run_context) poise_test end + python_runtime 'after' + poise_test 'after' + application '/other' + poise_test 'other' end let(:python) { chef_run.application('/test').app_state[:python] } it { is_expected.to run_poise_test('/test').with(parent_python: python) } + it { is_expected.to run_poise_test('after').with(parent_python: python) } + it { is_expected.to run_poise_test('other').with(parent_python: chef_run.python_runtime('after')) } it { expect(python).to be_a Chef::Resource } end # /context with an app_state python From 0a960ec9bb1ac913077f7f1f02dda191a9824a8b Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 29 Jul 2015 19:12:18 -0700 Subject: [PATCH 020/113] Add resources for runtime and virtualenv. This allows non-global parent injection. --- lib/poise_application_python/resources.rb | 2 + .../resources/python.rb | 58 +++++++++++++++ .../resources/virtualenv.rb | 73 +++++++++++++++++++ test/spec/resources/python_spec.rb | 44 +++++++++++ test/spec/resources/virtualenv_spec.rb | 44 +++++++++++ 5 files changed, 221 insertions(+) create mode 100644 lib/poise_application_python/resources/python.rb create mode 100644 lib/poise_application_python/resources/virtualenv.rb create mode 100644 test/spec/resources/python_spec.rb create mode 100644 test/spec/resources/virtualenv_spec.rb diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index e977c18..10bbf6a 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -16,3 +16,5 @@ require 'poise_application_python/resources/django' require 'poise_application_python/resources/gunicorn' +require 'poise_application_python/resources/python' +require 'poise_application_python/resources/virtualenv' diff --git a/lib/poise_application_python/resources/python.rb b/lib/poise_application_python/resources/python.rb new file mode 100644 index 0000000..a5a016e --- /dev/null +++ b/lib/poise_application_python/resources/python.rb @@ -0,0 +1,58 @@ +# +# 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. +# + +require 'poise_python/resources/python_runtime' + +require 'poise_application_python/app_mixin' + + +module PoiseApplicationPython + module Resources + # (see Python::Resource) + # @since 4.0.0 + module Python + # An `application_python_runtime` resource to manage Python runtimes + # inside an Application cookbook deployment. + # + # @provides application_python_runtime + # @provides application_python + # @action install + # @action uninstall + # @example + # application '/app' do + # python_runtime '2' + # end + class Resource < PoisePython::Resources::PythonRuntime::Resource + include PoiseApplicationPython::AppMixin + provides(:application_python) + # Need the double python for application resource rewriting. + provides(:application_python_python_runtime) + container_default(false) + subclass_providers! + + # Set this resource as the app_state's parent python. + # + # @api private + def after_created + super.tap do |val| + app_state_python(self) + end + end + + end + end + end +end diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb new file mode 100644 index 0000000..be23460 --- /dev/null +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -0,0 +1,73 @@ +# +# 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. +# + +require 'poise_python/resources/python_virtualenv' + +require 'poise_application_python/app_mixin' + + +module PoiseApplicationPython + module Resources + # (see Virtualenv::Resource) + # @since 4.0.0 + module Virtualenv + # An `application_python_virtualenv` resource to manage Python virtual + # environments inside an Application cookbook deployment. + # + # @provides application_python_virtualenv + # @provides application_virtualenv + # @action create + # @action delete + # @example + # application '/app' do + # python_virtualenv + # end + class Resource < PoisePython::Resources::PythonVirtualenv::Resource + include PoiseApplicationPython::AppMixin + provides(:application_virtualenv) + # Need the double python for application resource rewriting. + provides(:application_python_python_virtualenv) + container_default(false) + subclass_providers! + + # @!attribute path + # Override the normal path property to use name/.virtualenv for better + # compatibility with the application resource DSL. + # @return [String] + attribute(:path, kind_of: String, default: lazy { default_path }) + + # Set this resource as the app_state's parent python. + # + # @api private + def after_created + super.tap do |val| + app_state_python(self) + end + end + + private + + # Default value for the {#path} property. + # + # @return [String] + def default_path + ::File.join(name, '.virtualenv') + end + + end + end + end +end diff --git a/test/spec/resources/python_spec.rb b/test/spec/resources/python_spec.rb new file mode 100644 index 0000000..9312adf --- /dev/null +++ b/test/spec/resources/python_spec.rb @@ -0,0 +1,44 @@ +# +# 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. +# + +require 'spec_helper' + +describe PoiseApplicationPython::Resources::Python do + shared_examples 'application_python' do + it { is_expected.to install_application_python('ver') } + it { expect(chef_run.application('/test').app_state[:python]).to eq chef_run.application_python('ver') } + end # /shared_examples application_python + + context 'with #python_runtime' do + recipe do + application '/test' do + python_runtime 'ver' + end + end + + it_behaves_like 'application_python' + end # /context with #python_runtime + + context 'with #python' do + recipe do + application '/test' do + python 'ver' + end + end + + it_behaves_like 'application_python' + end # /context with #python +end diff --git a/test/spec/resources/virtualenv_spec.rb b/test/spec/resources/virtualenv_spec.rb new file mode 100644 index 0000000..f0102e7 --- /dev/null +++ b/test/spec/resources/virtualenv_spec.rb @@ -0,0 +1,44 @@ +# +# 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. +# + +require 'spec_helper' + +describe PoiseApplicationPython::Resources::Virtualenv do + shared_examples 'application_virtualenv' do + it { is_expected.to create_application_virtualenv('/test').with(path: '/test/.virtualenv') } + it { expect(chef_run.application('/test').app_state[:python]).to eq chef_run.application_virtualenv('/test') } + end # /shared_examples application_virtualenv + + context 'with #python_virtualenv' do + recipe do + application '/test' do + python_virtualenv + end + end + + it_behaves_like 'application_virtualenv' + end # /context with #python_virtualenv + + context 'with #virtualenv' do + recipe do + application '/test' do + virtualenv + end + end + + it_behaves_like 'application_virtualenv' + end # /context with #virtualenv +end From 8d99edaa15ec837ef2c15a292f3f3a1fdc44a202 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 1 Aug 2015 15:19:21 -0700 Subject: [PATCH 021/113] Shim resource for pip_requirements to use the app_state python. --- lib/poise_application_python/resources.rb | 1 + .../resources/pip_requirements.rb | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 lib/poise_application_python/resources/pip_requirements.rb diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index 10bbf6a..2b0eeb5 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -16,5 +16,6 @@ require 'poise_application_python/resources/django' require 'poise_application_python/resources/gunicorn' +require 'poise_application_python/resources/pip_requirements' require 'poise_application_python/resources/python' require 'poise_application_python/resources/virtualenv' diff --git a/lib/poise_application_python/resources/pip_requirements.rb b/lib/poise_application_python/resources/pip_requirements.rb new file mode 100644 index 0000000..d94eea8 --- /dev/null +++ b/lib/poise_application_python/resources/pip_requirements.rb @@ -0,0 +1,45 @@ +# +# 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. +# + +require 'poise_python/resources/pip_requirements' + +require 'poise_application_python/app_mixin' + + +module PoiseApplicationPython + module Resources + # (see PipRequirements::Resource) + # @since 4.0.0 + module PipRequirements + # An `application_pip_requirements` resource to manage Python virtual + # environments inside an Application cookbook deployment. + # + # @provides application_pip_requirements + # @provides application_virtualenv + # @action install + # @action upgrade + # @example + # application '/app' do + # pip_requirements + # end + class Resource < PoisePython::Resources::PipRequirements::Resource + include PoiseApplicationPython::AppMixin + provides(:application_pip_requirements) + subclass_providers! + end + end + end +end From a006a35110e458a52a3725b04040f093a6ae1373 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 1 Aug 2015 15:23:02 -0700 Subject: [PATCH 022/113] Update comments for current names. --- lib/poise_application_python/resources/python.rb | 6 +++--- lib/poise_application_python/resources/virtualenv.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/poise_application_python/resources/python.rb b/lib/poise_application_python/resources/python.rb index a5a016e..50d38c1 100644 --- a/lib/poise_application_python/resources/python.rb +++ b/lib/poise_application_python/resources/python.rb @@ -24,16 +24,16 @@ module Resources # (see Python::Resource) # @since 4.0.0 module Python - # An `application_python_runtime` resource to manage Python runtimes + # An `application_python` resource to manage Python runtimes # inside an Application cookbook deployment. # - # @provides application_python_runtime # @provides application_python + # @provides application_python_python_runtime # @action install # @action uninstall # @example # application '/app' do - # python_runtime '2' + # python '2' # end class Resource < PoisePython::Resources::PythonRuntime::Resource include PoiseApplicationPython::AppMixin diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb index be23460..126b4be 100644 --- a/lib/poise_application_python/resources/virtualenv.rb +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -24,7 +24,7 @@ module Resources # (see Virtualenv::Resource) # @since 4.0.0 module Virtualenv - # An `application_python_virtualenv` resource to manage Python virtual + # An `application_virtualenv` resource to manage Python virtual # environments inside an Application cookbook deployment. # # @provides application_python_virtualenv @@ -33,7 +33,7 @@ module Virtualenv # @action delete # @example # application '/app' do - # python_virtualenv + # virtualenv # end class Resource < PoisePython::Resources::PythonVirtualenv::Resource include PoiseApplicationPython::AppMixin From bbd894bfaf3c2dbf159b5efe4ab7f9ec6d4db724 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 1 Aug 2015 15:23:35 -0700 Subject: [PATCH 023/113] Use the app mixin instead of python command mixin. Pulls in python command anyway, and gets the app state python code. --- lib/poise_application_python/resources/gunicorn.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 8583542..fe1161f 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -20,7 +20,8 @@ require 'chef/resource' require 'poise' require 'poise_application/service_mixin' -require 'poise_python/python_command_mixin' + +require 'poise_application_python/app_mixin' module PoiseApplicationPython @@ -30,7 +31,7 @@ module Resources module Gunicorn class Resource < Chef::Resource include PoiseApplication::ServiceMixin - include PoisePython::PythonCommandMixin + include PoiseApplicationPython::AppMixin provides(:application_gunicorn) attribute(:path, kind_of: String, name_attribute: true) @@ -74,6 +75,7 @@ def default_app_module class Provider < Chef::Provider include PoiseApplication::ServiceMixin + include PoiseApplicationPython::AppMixin provides(:application_gunicorn) def action_enable From 84ddaba933b60ada67cd695b3706893796b75e43 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 1 Aug 2015 15:24:01 -0700 Subject: [PATCH 024/113] test_django no longer tries to install postgres stuffs. --- test/cookbooks/application_python_test/recipes/django.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/cookbooks/application_python_test/recipes/django.rb b/test/cookbooks/application_python_test/recipes/django.rb index 9aee66f..b9c579f 100644 --- a/test/cookbooks/application_python_test/recipes/django.rb +++ b/test/cookbooks/application_python_test/recipes/django.rb @@ -17,8 +17,6 @@ include_recipe 'build-essential' include_recipe 'poise-python' -package value_for_platform_family(debian: 'libpq-dev', rhel: 'postgresql-devel') - application '/opt/test_django' do git 'https://github.com/poise/test_django.git' pip_requirements From 9398ff5f491a9ecff11d7f258895d8da5d56fb51 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 11:46:18 -0700 Subject: [PATCH 025/113] Don't use self as a parent. --- lib/poise_application_python/app_mixin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb index fe8f2f4..2d5e4db 100644 --- a/lib/poise_application_python/app_mixin.rb +++ b/lib/poise_application_python/app_mixin.rb @@ -28,7 +28,7 @@ module Resource include PoiseApplication::AppMixin::Resource include PoisePython::PythonCommandMixin::Resource - parent_attribute(:python, type: :python_runtime, optional: true, default: lazy { app_state_python }) + parent_attribute(:python, type: :python_runtime, optional: true, default: lazy { app_state_python.equal?(self) ? nil : app_state_python }) def app_state_python(*args) unless args.empty? From 1ad3d5c67a2f1f8c5d465e6cc26d87ffc7ac228c Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 11:46:46 -0700 Subject: [PATCH 026/113] Try to resolve the virtualenv's parent before setting the app state python. This will pick up a runtime resource defined previously. --- lib/poise_application_python/resources/virtualenv.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb index 126b4be..723bfb4 100644 --- a/lib/poise_application_python/resources/virtualenv.rb +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -54,6 +54,8 @@ class Resource < PoisePython::Resources::PythonVirtualenv::Resource # @api private def after_created super.tap do |val| + # Force evaluation so we get any current parent if set. + parent_python app_state_python(self) end end From b3c339f7d1f22fc9c10c9f1984c8adddf9c063ce Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 11:46:56 -0700 Subject: [PATCH 027/113] Deploy in a virtualenv. --- test/cookbooks/application_python_test/recipes/django.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cookbooks/application_python_test/recipes/django.rb b/test/cookbooks/application_python_test/recipes/django.rb index b9c579f..4994ff5 100644 --- a/test/cookbooks/application_python_test/recipes/django.rb +++ b/test/cookbooks/application_python_test/recipes/django.rb @@ -19,6 +19,7 @@ application '/opt/test_django' do git 'https://github.com/poise/test_django.git' + virtualenv pip_requirements django do database 'sqlite:///test_django.db' From 347848579cc408bb092d2d0ecd3bea27592fa7fc Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 13:48:38 -0700 Subject: [PATCH 028/113] Let's deploy on PyPy3. --- test/cookbooks/application_python_test/recipes/django.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cookbooks/application_python_test/recipes/django.rb b/test/cookbooks/application_python_test/recipes/django.rb index 4994ff5..8141ec6 100644 --- a/test/cookbooks/application_python_test/recipes/django.rb +++ b/test/cookbooks/application_python_test/recipes/django.rb @@ -19,6 +19,7 @@ application '/opt/test_django' do git 'https://github.com/poise/test_django.git' + python 'pypy3' virtualenv pip_requirements django do From 58c496da0b62a87fe5e15c85365c79e31fbe11be Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 16:04:44 -0700 Subject: [PATCH 029/113] Run manage.py commands as the correct user. --- lib/poise_application_python/resources/django.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 399d7c3..07bf19d 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -236,8 +236,10 @@ def manage_py_execute(*cmd) python_execute "manage.py #{cmd.join(' ')}" do python_from_parent new_resource command [new_resource.manage_path] + cmd - environment new_resource.app_state_environment cwd new_resource.path + environment new_resource.app_state_environment + group new_resource.parent.group + user new_resource.parent.owner end end From 8feb72923f709a6ee5887bce092ac7932c2a8065 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 16:04:58 -0700 Subject: [PATCH 030/113] Fill in stuff for local settings. --- chef/templates/settings.py.erb | 5 ++++ .../resources/django.rb | 27 ++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 chef/templates/settings.py.erb diff --git a/chef/templates/settings.py.erb b/chef/templates/settings.py.erb new file mode 100644 index 0000000..da1a9a9 --- /dev/null +++ b/chef/templates/settings.py.erb @@ -0,0 +1,5 @@ +# Generated by Chef for <%= @new_resource.to_s %> + +DEBUG = <%= PoisePython::Utils.to_python(@debug) %> + +DATABASES = <%= PoisePython::Utils.to_python(@databases) %> diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 07bf19d..2e9185b 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -87,7 +87,13 @@ class Resource < Chef::Resource # end # @example Setting via URL # database 'postgresql://localhost/blog' - attribute(:database, option_collector: true, parser: :parse_database_url) + attribute(:database, option_collector: true, parser: :parse_database_url, forced_keys: %i{name}) + # @!attribute debug + # Enable debug mode for Django. + # @note + # If you use this in production you will get everything you deserve. + # @return [Boolean] + attribute(:debug, equal_to: [true, false], default: false) # @!attribute local_settings # Template content attribute for the contents of local_settings.py. # @todo Redo this doc to cover the actual attributes created. @@ -131,7 +137,16 @@ class Resource < Chef::Resource private def default_local_settings_options - raise todo + {}.tap do |options| + options[:debug] = debug + options[:databases] = {} + options[:databases]['default'] = database.inject({}) do |memo, (key, value)| + key = key.to_s.upcase + value = ENGINE_ALIASES[value] || "django.db.backends.#{value}" if key == 'ENGINE' && value && !value.empty? && !value.include?('.') + memo[key] = value + memo + end + end end def default_local_settings_path @@ -157,7 +172,6 @@ def default_wsgi_module # # @return [Hash] def parse_database_url(url) - parsed = URI(url) {}.tap do |db| # Store this for use later in #set_state, and maybe future use by @@ -229,7 +243,12 @@ def run_collectstatic def write_config # Allow disabling the local settings. return unless new_resource.local_settings_path - # todo + file new_resource.local_settings_path do + content new_resource.local_settings_content + mode '640' + owner new_resource.parent.owner + group new_resource.parent.group + end end def manage_py_execute(*cmd) From 737d1e6eb816f5bbf31b3e5aa4c4529a40f021ad Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 16:05:12 -0700 Subject: [PATCH 031/113] Mild tests for django local settings generation. --- test/spec/resources/django_spec.rb | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 test/spec/resources/django_spec.rb diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb new file mode 100644 index 0000000..ef916f7 --- /dev/null +++ b/test/spec/resources/django_spec.rb @@ -0,0 +1,73 @@ +# +# 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. +# + +require 'spec_helper' + +describe PoiseApplicationPython::Resources::Django do + describe PoiseApplicationPython::Resources::Django::Resource do + describe '#local_settings' do + subject { chef_run.application_django('/test').local_settings_content } + + context 'with defaults' do + recipe(subject: false) do + application_django '/test' + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +DEBUG = False + +DATABASES = {"default":{}} +SETTINGS + end # /context with defaults + + context 'with a URL' do + recipe(subject: false) do + application_django '/test' do + database 'postgres://myuser@dbhost/myapp' + end + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +DEBUG = False + +DATABASES = {"default":{"URL":"postgres://myuser@dbhost/myapp","ENGINE":"django.db.backends.postgresql_psycopg2","NAME":"myapp","USER":"myuser","HOST":"dbhost"}} +SETTINGS + end # /context with a URL + + context 'with an options block' do + recipe(subject: false) do + application_django '/test' do + database do + engine 'postgres' + name 'myapp' + user 'myuser' + host 'dbhost' + end + end + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +DEBUG = False + +DATABASES = {"default":{"ENGINE":"django.db.backends.postgresql_psycopg2","NAME":"myapp","USER":"myuser","HOST":"dbhost"}} +SETTINGS + end # /context with an options block + end # /describe #local_settings + end # /describe PoiseApplicationPython::Resources::Django::Resource +end From bfdb57af25ec745ab4087a019a2bb3db1eb34e97 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 16:07:44 -0700 Subject: [PATCH 032/113] Test the debug flag no one should ever use. --- test/spec/resources/django_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index ef916f7..ec6f5d6 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -68,6 +68,21 @@ DATABASES = {"default":{"ENGINE":"django.db.backends.postgresql_psycopg2","NAME":"myapp","USER":"myuser","HOST":"dbhost"}} SETTINGS end # /context with an options block + + context 'with debug mode' do + recipe(subject: false) do + application_django '/test' do + debug true + end + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +DEBUG = True + +DATABASES = {"default":{}} +SETTINGS + end # /context with debug mode end # /describe #local_settings end # /describe PoiseApplicationPython::Resources::Django::Resource end From 1bdc1f228bfca15613a84bf7a40c4dfcd9434dfc Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 16:23:28 -0700 Subject: [PATCH 033/113] Comments. --- .../resources/django.rb | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 2e9185b..bd5b1ef 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -142,7 +142,8 @@ def default_local_settings_options options[:databases] = {} options[:databases]['default'] = database.inject({}) do |memo, (key, value)| key = key.to_s.upcase - value = ENGINE_ALIASES[value] || "django.db.backends.#{value}" if key == 'ENGINE' && value && !value.empty? && !value.include?('.') + # Deal with engine aliases here too, just in case. + value = resolve_engine(value) if key == 'ENGINE' memo[key] = value memo end @@ -177,7 +178,7 @@ def parse_database_url(url) # Store this for use later in #set_state, and maybe future use by # Django in some magic world where operability happens. db[:URL] = url - db[:ENGINE] = ENGINE_ALIASES[parsed.scheme] || "django.db.backends.#{parsed.scheme}" if parsed.scheme && !parsed.scheme.empty? + db[:ENGINE] = resolve_engine(parsed.scheme) # Strip the leading /. path = parsed.path ? parsed.path[1..-1] : parsed.path # If we are using SQLite, make it an absolute path. @@ -202,12 +203,32 @@ def find_file(name) end end + # Resolve Django database engine from shortname to dotted module. + # + # @param name [String, nil] Engine name. + # @return [String, nil] + def resolve_engine(name) + if name && !name.empty? && !name.include?('.') + ENGINE_ALIASES[name] || "django.db.backends.#{name}" + else + name + end + end end + # Provider for `application_django`. + # + # @since 4.0.0 + # @see Resource + # @provides application_django class Provider < Chef::Provider include PoiseApplicationPython::AppMixin provides(:application_django) + # `deploy` action for `application_django`. Ensure all configuration + # files are created and other deploy tasks resolved. + # + # @return [void] def action_deploy set_state notifying_block do @@ -220,6 +241,7 @@ def action_deploy private + # Set app_state variables for future services et al. def set_state # Set environment variables for later services. new_resource.app_state_environment[:DJANGO_SETTINGS_MODULE] = new_resource.settings_module if new_resource.settings_module @@ -228,18 +250,23 @@ def set_state new_resource.app_state[:python_app_module] = new_resource.wsgi_module if new_resource.wsgi_module end + # Create the database using the older syncdb command. def run_syncdb manage_py_execute('syncdb', '--noinput') if new_resource.syncdb end + # Create the database using the newer migrate command. This should work + # for either South or the built-in migrations support. def run_migrate manage_py_execute('migrate', '--noinput') if new_resource.migrate end + # Run the asset pipeline. def run_collectstatic manage_py_execute('collectstatic', '--noinput') if new_resource.collectstatic end + # Create the local config settings. def write_config # Allow disabling the local settings. return unless new_resource.local_settings_path @@ -251,6 +278,7 @@ def write_config end end + # Run a manage.py command using `python_execute`. def manage_py_execute(*cmd) python_execute "manage.py #{cmd.join(' ')}" do python_from_parent new_resource From 1a6c214a880f2b90a2b40e041543e6bbb641c5d3 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 16:31:23 -0700 Subject: [PATCH 034/113] Lol rails host. --- lib/poise_application_python/resources/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index bd5b1ef..b1736e6 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -55,7 +55,7 @@ module Django # pip_requirements # django do # database do - # host node['rails_host'] + # host node['db_host'] # end # end # gunicorn do From 20a58044a6e143e15f73cf4695757ef84984f851 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 22:28:00 -0700 Subject: [PATCH 035/113] Not needed anymore. --- chef/templates/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 chef/templates/.gitkeep diff --git a/chef/templates/.gitkeep b/chef/templates/.gitkeep deleted file mode 100644 index e69de29..0000000 From c285b62e0a2e23a8b8046fb97aca0b90b42ae17c Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 22:28:20 -0700 Subject: [PATCH 036/113] Pedantic whitespace. --- lib/poise_application_python/resources/django.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index b1736e6..27e8c07 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -214,6 +214,7 @@ def resolve_engine(name) name end end + end # Provider for `application_django`. From ec2860c5ba34f81771dc1b43dbedf67df790fa17 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 3 Aug 2015 22:28:29 -0700 Subject: [PATCH 037/113] Add a celery_config resource. --- chef/templates/celeryconfig.py.erb | 5 + lib/poise_application_python/resources.rb | 1 + .../resources/celery_config.rb | 99 +++++++++++++++++++ test/spec/resources/celery_config_spec.rb | 58 +++++++++++ 4 files changed, 163 insertions(+) create mode 100644 chef/templates/celeryconfig.py.erb create mode 100644 lib/poise_application_python/resources/celery_config.rb create mode 100644 test/spec/resources/celery_config_spec.rb diff --git a/chef/templates/celeryconfig.py.erb b/chef/templates/celeryconfig.py.erb new file mode 100644 index 0000000..3e47b9a --- /dev/null +++ b/chef/templates/celeryconfig.py.erb @@ -0,0 +1,5 @@ +# Generated by Chef for <%= @new_resource.to_s %> + +<%- @new_resource.options.each do |key, value| -%> +<%= key.upcase %> = <%= PoisePython::Utils.to_python(value) %> +<%- end -%> diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index 2b0eeb5..ceddceb 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -14,6 +14,7 @@ # limitations under the License. # +require 'poise_application_python/resources/celery_config' require 'poise_application_python/resources/django' require 'poise_application_python/resources/gunicorn' require 'poise_application_python/resources/pip_requirements' diff --git a/lib/poise_application_python/resources/celery_config.rb b/lib/poise_application_python/resources/celery_config.rb new file mode 100644 index 0000000..42e9f67 --- /dev/null +++ b/lib/poise_application_python/resources/celery_config.rb @@ -0,0 +1,99 @@ +# +# 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. +# + +require 'uri' + +require 'chef/provider' +require 'chef/resource' +require 'poise' +require 'poise_application' +require 'poise_python' + +require 'poise_application_python/app_mixin' +require 'poise_application_python/error' + + +module PoiseApplicationPython + module Resources + # (see CeleryConfig::Resource) + # @since 4.0.0 + module CeleryConfig + # An `application_celery_config` resource to configure Celery workers. + # + # @since 4.0.0 + # @provides application_celery_config + # @action deploy + # @example + # application '/srv/myapp' do + # git '...' + # pip_requirements + # celery_config do + # broker_url '...' + # end + # celeryd + # end + class Resource < Chef::Resource + include PoiseApplicationPython::AppMixin + provides(:application_celery_config) + actions(:deploy) + + attribute('', template: true, default_source: 'celeryconfig.py.erb') + attribute(:path, kind_of: String, default: lazy { default_path }) + + private + + def default_path + if ::File.directory?(name) + ::File.join(name, 'celeryconfig.py') + else + name + end + end + end + + # Provider for `application_celery_config`. + # + # @since 4.0.0 + # @see Resource + # @provides application_celery_config + class Provider < Chef::Provider + include PoiseApplicationPython::AppMixin + provides(:application_celery_config) + + # `deploy` action for `application_celery_config`. Writes config file. + # + # @return [void] + def action_deploy + notifying_block do + write_config + end + end + + private + + def write_config + file new_resource.path do + content new_resource.content + mode '640' + owner new_resource.parent.owner if new_resource.parent + group new_resource.parent.group if new_resource.parent + end + end + + end + end + end +end diff --git a/test/spec/resources/celery_config_spec.rb b/test/spec/resources/celery_config_spec.rb new file mode 100644 index 0000000..561cdc7 --- /dev/null +++ b/test/spec/resources/celery_config_spec.rb @@ -0,0 +1,58 @@ +# +# 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. +# + +require 'spec_helper' + +describe PoiseApplicationPython::Resources::CeleryConfig do + step_into(:application_celery_config) + before do + allow(File).to receive(:directory?).and_call_original + allow(File).to receive(:directory?).with('/test').and_return(true) + end + + context 'with defaults' do + recipe do + application_celery_config '/test' + end + it { is_expected.to deploy_application_celery_config('/test').with(path: '/test/celeryconfig.py') } + it { is_expected.to render_file('/test/celeryconfig.py').with_content(eq(<<-CELERYCONFIG)) } +# Generated by Chef for application_celery_config[/test] + +CELERYCONFIG + end # /context with defaults + + context 'with a specific path' do + recipe do + application_celery_config '/test/foo.py' + end + it { is_expected.to deploy_application_celery_config('/test/foo.py').with(path: '/test/foo.py') } + end # /context with a specific path + + context 'with template options' do + recipe do + application_celery_config '/test' do + options do + broker_url 'amqp://' + end + end + end + it { is_expected.to render_file('/test/celeryconfig.py').with_content(eq(<<-CELERYCONFIG)) } +# Generated by Chef for application_celery_config[/test] + +BROKER_URL = "amqp://" +CELERYCONFIG + end # /context with template options +end From 429166bd8047dd8a4bb04314421c89637b57329d Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 5 Aug 2015 13:27:05 -0700 Subject: [PATCH 038/113] app_module -> wsgi_module in the state. Making room for the celery app module or something. --- lib/poise_application_python/resources/django.rb | 2 +- lib/poise_application_python/resources/gunicorn.rb | 2 +- test/spec/resources/gunicorn_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 27e8c07..0b1ee85 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -248,7 +248,7 @@ def set_state new_resource.app_state_environment[:DJANGO_SETTINGS_MODULE] = new_resource.settings_module if new_resource.settings_module new_resource.app_state_environment[:DATABASE_URL] = new_resource.database[:URL] if new_resource.database[:URL] # Set the app module. - new_resource.app_state[:python_app_module] = new_resource.wsgi_module if new_resource.wsgi_module + new_resource.app_state[:python_wsgi_module] = new_resource.wsgi_module if new_resource.wsgi_module end # Create the database using the older syncdb command. diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index fe1161f..ed54e83 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -58,7 +58,7 @@ def port(val) # @return [String] def default_app_module # If set in app_state, use that. - return app_state[:python_app_module] if app_state[:python_app_module] + return app_state[:python_wsgi_module] if app_state[:python_wsgi_module] files = Dir.entries(path) # Try to find a known filename. candidate_file = %w{wsgi.py main.py app.py application.py}.find {|file| files.include?(file) } diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index 7d54d90..f989e17 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -29,7 +29,7 @@ subject { test_resource.send(:default_app_module) } context 'with an app_state key' do - let(:app_state) { {python_app_module: 'django'} } + let(:app_state) { {python_wsgi_module: 'django'} } it { is_expected.to eq 'django' } end # /context with an app_state key From f99b5e4a7b2ffb65ce5f59157451ae94730bee45 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 5 Aug 2015 13:28:37 -0700 Subject: [PATCH 039/113] Refactor stuff to a python-specific service mixin. --- .../resources/gunicorn.rb | 11 ++--- lib/poise_application_python/service_mixin.rb | 49 +++++++++++++++++++ 2 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 lib/poise_application_python/service_mixin.rb diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index ed54e83..5c61c4c 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -19,9 +19,8 @@ require 'chef/provider' require 'chef/resource' require 'poise' -require 'poise_application/service_mixin' -require 'poise_application_python/app_mixin' +require 'poise_application_python/service_mixin' module PoiseApplicationPython @@ -30,11 +29,9 @@ module Resources # @since 4.0.0 module Gunicorn class Resource < Chef::Resource - include PoiseApplication::ServiceMixin - include PoiseApplicationPython::AppMixin + include PoiseApplicationPython::ServiceMixin provides(:application_gunicorn) - attribute(:path, kind_of: String, name_attribute: true) attribute(:app_module, kind_of: String, default: lazy { default_app_module }) attribute(:bind, kind_of: [String, Array], default: '0.0.0.0:80') attribute(:config, kind_of: [String, NilClass]) @@ -74,8 +71,7 @@ def default_app_module end class Provider < Chef::Provider - include PoiseApplication::ServiceMixin - include PoiseApplicationPython::AppMixin + include PoiseApplicationPython::ServiceMixin provides(:application_gunicorn) def action_enable @@ -122,7 +118,6 @@ def gunicorn_command_options def service_options(resource) super resource.command("#{new_resource.python} -m gunicorn.app.wsgiapp #{gunicorn_command_options.join(' ')} #{new_resource.app_module}") - resource.environment.update(new_resource.parent_python.python_environment) if new_resource.parent_python end end diff --git a/lib/poise_application_python/service_mixin.rb b/lib/poise_application_python/service_mixin.rb new file mode 100644 index 0000000..b3121ce --- /dev/null +++ b/lib/poise_application_python/service_mixin.rb @@ -0,0 +1,49 @@ +# +# 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. +# + +require 'poise/utils' +require 'poise_application/service_mixin' + +require 'poise_application_python/app_mixin' + + +module PoiseApplicationPython + # A helper mixin for Python service resources and providers. + # + # @since 4.0.0 + module ServiceMixin + include Poise::Utils::ResourceProviderMixin + + # A helper mixin for Python service resources. + module Resource + include PoiseApplication::ServiceMixin::Resource + include PoiseApplicationPython::AppMixin::Resource + end + + # A helper mixin for Python service providers. + module Provider + include PoiseApplication::ServiceMixin::Provider + include PoiseApplicationPython::AppMixin::Provider + + # Include the Python environment variables + def service_options(resource) + super + resource.environment.update(new_resource.parent_python.python_environment) if new_resource.parent_python + end + + end + end +end From d42bcfd33ccff4543b5d5bd5277f374a41637c7d Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 5 Aug 2015 13:28:50 -0700 Subject: [PATCH 040/113] New resources for celery worker and beat. --- lib/poise_application_python/resources.rb | 2 + .../resources/celery_beat.rb | 43 +++++++++++ .../resources/celery_worker.rb | 76 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 lib/poise_application_python/resources/celery_beat.rb create mode 100644 lib/poise_application_python/resources/celery_worker.rb diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index ceddceb..0746eae 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -14,7 +14,9 @@ # limitations under the License. # +require 'poise_application_python/resources/celery_beat' require 'poise_application_python/resources/celery_config' +require 'poise_application_python/resources/celery_worker' require 'poise_application_python/resources/django' require 'poise_application_python/resources/gunicorn' require 'poise_application_python/resources/pip_requirements' diff --git a/lib/poise_application_python/resources/celery_beat.rb b/lib/poise_application_python/resources/celery_beat.rb new file mode 100644 index 0000000..3085c62 --- /dev/null +++ b/lib/poise_application_python/resources/celery_beat.rb @@ -0,0 +1,43 @@ +# +# 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. +# + +require 'poise_application_python/resources/celery_worker' + + +module PoiseApplicationPython + module Resources + # (see CeleryBeat::Resource) + # @since 4.0.0 + module CeleryBeat + class Resource < PoiseApplicationPython::Resources::CeleryWorker::Resource + provides(:application_celery_beat) + end + + class Provider < PoiseApplicationPython::Resources::CeleryWorker::Provider + provides(:application_celery_beat) + + private + + # (see PoiseApplication::ServiceMixin#service_options) + def service_options(resource) + super + resource.command("#{new_resource.python} -m celery --app=#{new_resource.app_module} beat") + end + + end + end + end +end diff --git a/lib/poise_application_python/resources/celery_worker.rb b/lib/poise_application_python/resources/celery_worker.rb new file mode 100644 index 0000000..eb5aebc --- /dev/null +++ b/lib/poise_application_python/resources/celery_worker.rb @@ -0,0 +1,76 @@ +# +# 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. +# + +require 'chef/provider' +require 'chef/resource' + +require 'poise_application_python/service_mixin' + + +module PoiseApplicationPython + module Resources + # (see CeleryWorker::Resource) + # @since 4.0.0 + module CeleryWorker + class Resource < Chef::Resource + include PoiseApplicationPython::ServiceMixin + provides(:application_celery_worker) + + attribute(:app_module, kind_of: String, default: lazy { default_app_module }) + + private + + # Compute the default application module to pass to gunicorn. This + # checks the app state and then looks for commonly used filenames. + # Raises an exception if no default can be found. + # + # @return [String] + def default_app_module + # If set in app_state, use that. + return app_state[:python_celery_module] if app_state[:python_celery_module] + # If a Django settings module is set, use everything by the last + # dotted component of it. to_s handles nil since that won't match. + return $1 if app_state_environment[:DJANGO_SETTINGS_MODULE].to_s =~ /^(.+?)\.[^.]+$/ + files = Dir.entries(path) + # Try to find a known filename. + candidate_file = %w{tasks.py task.py celery.py main.py app.py application.py}.find {|file| files.include?(file) } + # Try the first Python file. Do I really want this? + candidate_file ||= files.find {|file| file.end_with?('.py') } + if candidate_file + ::File.basename(candidate_file, '.py') + else + raise PoiseApplicationPython::Error.new("Unable to determine app module for #{self}") + end + end + + end + + class Provider < Chef::Provider + include PoiseApplicationPython::ServiceMixin + provides(:application_celery_worker) + + private + + # (see PoiseApplication::ServiceMixin#service_options) + def service_options(resource) + super + resource.command("#{new_resource.python} -m celery --app=#{new_resource.app_module} worker") + end + + end + end + end +end From 31fa347e2b6dfa318fb6c467b9bd257043978e20 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 6 Aug 2015 13:53:06 -0700 Subject: [PATCH 041/113] Add support for configuring SECRET_KEY and ALLOWED_HOSTS for Django. Thanks to @ostap36 for their support on Kickstarter! --- chef/templates/settings.py.erb | 8 +++ .../resources/django.rb | 13 ++++- test/spec/resources/django_spec.rb | 51 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/chef/templates/settings.py.erb b/chef/templates/settings.py.erb index da1a9a9..88ee90f 100644 --- a/chef/templates/settings.py.erb +++ b/chef/templates/settings.py.erb @@ -1,5 +1,13 @@ # Generated by Chef for <%= @new_resource.to_s %> +<%- unless @allowed_hosts.empty? -%> +ALLOWED_HOSTS = <%= PoisePython::Utils.to_python(@allowed_hosts) %> + +<%- end -%> DEBUG = <%= PoisePython::Utils.to_python(@debug) %> DATABASES = <%= PoisePython::Utils.to_python(@databases) %> +<%- if @secret_key -%> + +SECRET_KEY = <%= PoisePython::Utils.to_python(@secret_key) %> +<%- end -%> diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 0b1ee85..4722f2b 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -71,6 +71,10 @@ class Resource < Chef::Resource # Application base path. # @return [String] attribute(:path, kind_of: String, name_attribute: true) + # @!attribute allowed_hosts + # Value for `ALLOWED_HOSTS` in the Django settings. + # @return [String, Array] + attribute(:allowed_hosts, kind_of: [String, Array], default: lazy { [] }) # @!attribute collectstatic # Set to false to disable running manage.py collectstatic during # deployment. @@ -116,6 +120,11 @@ class Resource < Chef::Resource # to {#path}. # @return [String] attribute(:manage_path, kind_of: String, default: lazy { default_manage_path }) + # @!attribute secret_key + # Value for `SECRET_KEY` in the Django settings. If unset, not key is + # added to the local settings. + # @return [String, false] + attribute(:secret_key, kind_of: [String, FalseClass]) # @!attribute settings_module # Django settings module in dotted notation. Set to false to disable # anything related to settings. Defaults to scanning for the nearest @@ -138,7 +147,7 @@ class Resource < Chef::Resource def default_local_settings_options {}.tap do |options| - options[:debug] = debug + options[:allowed_hosts] = Array(allowed_hosts) options[:databases] = {} options[:databases]['default'] = database.inject({}) do |memo, (key, value)| key = key.to_s.upcase @@ -147,6 +156,8 @@ def default_local_settings_options memo[key] = value memo end + options[:debug] = debug + options[:secret_key] = secret_key end end diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index ec6f5d6..9cc6928 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -83,6 +83,57 @@ DATABASES = {"default":{}} SETTINGS end # /context with debug mode + + context 'with a single allowed host' do + recipe(subject: false) do + application_django '/test' do + allowed_hosts 'example.com' + end + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +ALLOWED_HOSTS = ["example.com"] + +DEBUG = False + +DATABASES = {"default":{}} +SETTINGS + end # /context with a single allowed host + + context 'with multiple allowed hosts' do + recipe(subject: false) do + application_django '/test' do + allowed_hosts %w{example.com www.example.com} + end + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +ALLOWED_HOSTS = ["example.com","www.example.com"] + +DEBUG = False + +DATABASES = {"default":{}} +SETTINGS + end # /context with multiple allowed hosts + + context 'with a secret key' do + recipe(subject: false) do + application_django '/test' do + secret_key 'swordfish' + end + end + it { is_expected.to eq <<-SETTINGS } +# Generated by Chef for application_django[/test] + +DEBUG = False + +DATABASES = {"default":{}} + +SECRET_KEY = "swordfish" +SETTINGS + end # /context with a secret key end # /describe #local_settings end # /describe PoiseApplicationPython::Resources::Django::Resource end From c5b7419d29e0e775515632e09e3975b754c5cf50 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 6 Aug 2015 17:13:20 -0700 Subject: [PATCH 042/113] Docs! --- README.md | 258 +++++++++++++++++- .../resources/celery_config.rb | 4 +- .../resources/django.rb | 6 +- .../resources/pip_requirements.rb | 2 + .../resources/virtualenv.rb | 1 + 5 files changed, 264 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 08b35e2..d173012 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,263 @@ [![Gemnasium](https://img.shields.io/gemnasium/poise/application_python.svg)](https://gemnasium.com/poise/application_python) [![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -More info coming soon! +A [Chef](https://www.chef.io/) cookbook to deploy Python applications. + +## Quick Start + +To deploy a Django application from git: + +```ruby +application '/srv/myapp' do + git 'https://github.com/example/myapp.git' + virtualenv + pip_requirements + django do + database 'sqlite:///test_django.db' + migrate true + end + gunicorn do + port 8000 + end +end +``` + +## Requirements + +Chef 12 or newer is required. + +## Resources + +### `application_celery_worker` + +The `application_celery_beat` resource creates a service for the `celery beat` +process. + +```ruby +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 + +* `app_module` – Celery application module. *(default: auto-detect)* + +### `application_celery_config` + +The `application_celery_config` creates a `celeryconfig.py` configuration file. + +```ruby +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, + create `path/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. + +```ruby +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 + +* `app_module` – Celery application module. *(default: auto-detect)* + +### `application_django` + +The `application_django` resource creates configuration files and runs commands +for a Django application deployment. + +```ruby +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 for `ALLOWED_HOSTS` in the Django settings. + *(default: [])* +* `collectstatic` – Run `manage.py collectstatic` during deployment. + *(default: true)* +* `database` – Database settings for the default connection. See [the database + section below](#database-parameters) for more information. *(option collector)* +* `debug` – Enable debug mode for Django. *(default: false)* +* `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` – Run `manage.py migrate` during deployment. *(default: false)* +* `manage_path` – Path to `manage.py`. *(default: auto-detect)* +* `secret_key` – Value for `SECRET_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` – Run `manage.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`: + +```ruby +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: + +```ruby +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](http://gunicorn.org/) application server. + +```ruby +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 for `bind("0.0.0.0:#{port}")`. +* `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. + +```ruby +application '/srv/myapp' do + pip_requirements +end +``` + +All actions and properties are the same as the [`pip_requirements` resource](https://github.com/poise/poise-python#pip_requirements). + +### `application_python` + +The `application_python` resource installs a Python runtime for the deployment. + +```ruby +application '/srv/myapp' do + python '2.7' +end +``` + +All actions and properties are the same as the [`python_runtime` resource](https://github.com/poise/poise-python#python_runtime). + +### `application_virtualenv` + +The `application_virtualenv` resource creates a Python virtualenv for the +deployment. + +```ruby +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](https://github.com/poise/poise-python#python_virtualenv). ## Sponsors diff --git a/lib/poise_application_python/resources/celery_config.rb b/lib/poise_application_python/resources/celery_config.rb index 42e9f67..68aced6 100644 --- a/lib/poise_application_python/resources/celery_config.rb +++ b/lib/poise_application_python/resources/celery_config.rb @@ -41,7 +41,9 @@ module CeleryConfig # git '...' # pip_requirements # celery_config do - # broker_url '...' + # options do + # broker_url '...' + # end # end # celeryd # end diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 4722f2b..9fe59e0 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -67,10 +67,6 @@ class Resource < Chef::Resource provides(:application_django) actions(:deploy) - # @!attribute path - # Application base path. - # @return [String] - attribute(:path, kind_of: String, name_attribute: true) # @!attribute allowed_hosts # Value for `ALLOWED_HOSTS` in the Django settings. # @return [String, Array] @@ -121,7 +117,7 @@ class Resource < Chef::Resource # @return [String] attribute(:manage_path, kind_of: String, default: lazy { default_manage_path }) # @!attribute secret_key - # Value for `SECRET_KEY` in the Django settings. If unset, not key is + # Value for `SECRET_KEY` in the Django settings. If unset, no key is # added to the local settings. # @return [String, false] attribute(:secret_key, kind_of: [String, FalseClass]) diff --git a/lib/poise_application_python/resources/pip_requirements.rb b/lib/poise_application_python/resources/pip_requirements.rb index d94eea8..192a687 100644 --- a/lib/poise_application_python/resources/pip_requirements.rb +++ b/lib/poise_application_python/resources/pip_requirements.rb @@ -39,6 +39,8 @@ class Resource < PoisePython::Resources::PipRequirements::Resource include PoiseApplicationPython::AppMixin provides(:application_pip_requirements) subclass_providers! + + # @todo This should handle relative paths against parent.path. end end end diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb index 723bfb4..743251c 100644 --- a/lib/poise_application_python/resources/virtualenv.rb +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -66,6 +66,7 @@ def after_created # # @return [String] def default_path + # @todo This should handle relative paths as a name. ::File.join(name, '.virtualenv') end From 059686446d91baeb43dcb96c309703292d7b7b73 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 6 Aug 2015 17:14:00 -0700 Subject: [PATCH 043/113] Add examples section. [ci skip] --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d173012..9541567 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,13 @@ application deployment path. All actions and properties are the same as the [`python_virtualenv` resource](https://github.com/poise/poise-python#python_virtualenv). +## Examples + +Some test recipes are available as examples for common application frameworks: + +* [Flask](https://github.com/poise/application_python/blob/master/test/cookbooks/application_python_test/recipes/flask.rb) +* [Django](https://github.com/poise/application_python/blob/master/test/cookbooks/application_python_test/recipes/django.rb) + ## Sponsors Development sponsored by [Chef Software](https://www.chef.io/), [Symonds & Son](http://symondsandson.com/), and [Orion](https://www.orionlabs.co/). From 84cc206157c59a4219e8cad1849b0cb3c241abb1 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 7 Aug 2015 15:21:46 -0700 Subject: [PATCH 044/113] More docs! [ci skip] --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9541567..556a682 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ application '/srv/myapp' do pip_requirements django do database 'sqlite:///test_django.db' + secret_key 'd78fe08df56c9' migrate true end gunicorn do @@ -58,7 +59,10 @@ end #### 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` @@ -108,7 +112,10 @@ end #### 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` @@ -221,6 +228,8 @@ end * `config` – Path to a Guncorn configuration file. * `preload_app` – Enable code preloading. *(default: false)* * `port` – Port to listen on. Alias for `bind("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)* From 3d1b93963334b4366c19d9374d9d1a5b000a24f1 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 15 Aug 2015 23:33:42 -0700 Subject: [PATCH 045/113] Use the NOT_PASSED style for fixed arity. --- lib/poise_application_python/app_mixin.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb index 2d5e4db..821362d 100644 --- a/lib/poise_application_python/app_mixin.rb +++ b/lib/poise_application_python/app_mixin.rb @@ -15,6 +15,7 @@ # require 'chef/mash' +require 'poise/backports' require 'poise/utils' require 'poise_application/app_mixin' require 'poise_python/python_command_mixin' @@ -30,9 +31,10 @@ module Resource parent_attribute(:python, type: :python_runtime, optional: true, default: lazy { app_state_python.equal?(self) ? nil : app_state_python }) - def app_state_python(*args) - unless args.empty? - app_state[:python] = args.first + # @attribute app_state_python + def app_state_python(python=Poise::NOT_PASSED) + unless python == Poise::NOT_PASSED + app_state[:python] = python end app_state[:python] end From 18807e5ccc8e0459a3040f7d16a613e5fb981356 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 15 Aug 2015 23:33:49 -0700 Subject: [PATCH 046/113] Docstrings. --- lib/poise_application_python/app_mixin.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb index 821362d..6b39e1f 100644 --- a/lib/poise_application_python/app_mixin.rb +++ b/lib/poise_application_python/app_mixin.rb @@ -14,7 +14,6 @@ # limitations under the License. # -require 'chef/mash' require 'poise/backports' require 'poise/utils' require 'poise_application/app_mixin' @@ -22,16 +21,26 @@ module PoiseApplicationPython + # A helper mixin for Python application resources and providers. + # + # @since 4.0.0 module AppMixin include Poise::Utils::ResourceProviderMixin + # A helper mixin for Python application resources. module Resource include PoiseApplication::AppMixin::Resource include PoisePython::PythonCommandMixin::Resource + # @!attribute parent_python + # Override the #parent_python from PythonCommandMixin to grok the + # application level parent as a default value. + # @return [PoisePython::Resources::PythonRuntime::Resource, nil] parent_attribute(:python, type: :python_runtime, optional: true, default: lazy { app_state_python.equal?(self) ? nil : app_state_python }) # @attribute app_state_python + # The application-level Python parent. + # @return [PoisePython::Resources::PythonRuntime::Resource, nil] def app_state_python(python=Poise::NOT_PASSED) unless python == Poise::NOT_PASSED app_state[:python] = python @@ -39,6 +48,10 @@ def app_state_python(python=Poise::NOT_PASSED) app_state[:python] end + # A merged hash of environment variables for both the application state + # and parent python. + # + # @return [Hash] def app_state_environment_python env = app_state_environment env = env.merge(parent_python.python_environment) if parent_python @@ -46,6 +59,7 @@ def app_state_environment_python end end + # A helper mixin for Python application providers. module Provider include PoiseApplication::AppMixin::Provider end From bbff4a6e9d15a9d22e44d17d7efbd6d7a7a0b640 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 15 Aug 2015 23:34:48 -0700 Subject: [PATCH 047/113] Add a magic-y helper to the service resource. This mirrors a similar helper for ruby, but isn't actually that complex. Still nice for symmetry and possibly future expansion. --- lib/poise_application_python/service_mixin.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/poise_application_python/service_mixin.rb b/lib/poise_application_python/service_mixin.rb index b3121ce..2fe74d6 100644 --- a/lib/poise_application_python/service_mixin.rb +++ b/lib/poise_application_python/service_mixin.rb @@ -38,9 +38,16 @@ module Provider include PoiseApplication::ServiceMixin::Provider include PoiseApplicationPython::AppMixin::Provider - # Include the Python environment variables + # Set up the service for running Python stuff. def service_options(resource) super + # Closure scoping for #python_command below. + self_ = self + # Create a new singleton method that fills in Python for you. + resource.define_singleton_method(:python_command) do |val| + resource.command("#{self_.new_resource.python} #{val}") + end + # Include env vars as needed. resource.environment.update(new_resource.parent_python.python_environment) if new_resource.parent_python end From ef2af2175513eb690a6eaace7961244d0b047b1b Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 18 Aug 2015 01:18:29 -0700 Subject: [PATCH 048/113] Lazy defaults are less lazy than I previously remembered. Fixes #60. --- lib/poise_application_python/resources/celery_worker.rb | 7 ++++--- lib/poise_application_python/resources/gunicorn.rb | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/poise_application_python/resources/celery_worker.rb b/lib/poise_application_python/resources/celery_worker.rb index eb5aebc..e73c46f 100644 --- a/lib/poise_application_python/resources/celery_worker.rb +++ b/lib/poise_application_python/resources/celery_worker.rb @@ -29,7 +29,7 @@ class Resource < Chef::Resource include PoiseApplicationPython::ServiceMixin provides(:application_celery_worker) - attribute(:app_module, kind_of: String, default: lazy { default_app_module }) + attribute(:app_module, kind_of: [String, NilClass], default: lazy { default_app_module }) private @@ -44,7 +44,7 @@ def default_app_module # If a Django settings module is set, use everything by the last # dotted component of it. to_s handles nil since that won't match. return $1 if app_state_environment[:DJANGO_SETTINGS_MODULE].to_s =~ /^(.+?)\.[^.]+$/ - files = Dir.entries(path) + files = Dir.exist?(path) ? Dir.entries(path) : [] # Try to find a known filename. candidate_file = %w{tasks.py task.py celery.py main.py app.py application.py}.find {|file| files.include?(file) } # Try the first Python file. Do I really want this? @@ -52,7 +52,7 @@ def default_app_module if candidate_file ::File.basename(candidate_file, '.py') else - raise PoiseApplicationPython::Error.new("Unable to determine app module for #{self}") + nil end end @@ -67,6 +67,7 @@ class Provider < Chef::Provider # (see PoiseApplication::ServiceMixin#service_options) def service_options(resource) super + raise PoiseApplicationPython::Error.new("Unable to determine app module for #{new_resource}") unless new_resource.app_module resource.command("#{new_resource.python} -m celery --app=#{new_resource.app_module} worker") end diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 5c61c4c..8e2aecb 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -32,7 +32,7 @@ class Resource < Chef::Resource include PoiseApplicationPython::ServiceMixin provides(:application_gunicorn) - attribute(:app_module, kind_of: String, default: lazy { default_app_module }) + attribute(:app_module, kind_of: [String, NilClass], default: lazy { default_app_module }) attribute(:bind, kind_of: [String, Array], default: '0.0.0.0:80') attribute(:config, kind_of: [String, NilClass]) attribute(:preload_app, equal_to: [true, false], default: false) @@ -56,7 +56,7 @@ def port(val) def default_app_module # If set in app_state, use that. return app_state[:python_wsgi_module] if app_state[:python_wsgi_module] - files = Dir.entries(path) + files = Dir.exist?(path) ? Dir.entries(path) : [] # Try to find a known filename. candidate_file = %w{wsgi.py main.py app.py application.py}.find {|file| files.include?(file) } # Try the first Python file. Do I really want this? @@ -64,7 +64,7 @@ def default_app_module if candidate_file ::File.basename(candidate_file, '.py') else - raise PoiseApplicationPython::Error.new("Unable to determine app module for #{self}") + nil end end @@ -117,6 +117,7 @@ def gunicorn_command_options # (see PoiseApplication::ServiceMixin#service_options) def service_options(resource) super + raise PoiseApplicationPython::Error.new("Unable to determine app module for #{new_resource}") unless new_resource.app_module resource.command("#{new_resource.python} -m gunicorn.app.wsgiapp #{gunicorn_command_options.join(' ')} #{new_resource.app_module}") end From 9596e14f017d2d3e64cd09565c4b698d2584a325 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 18 Aug 2015 01:22:59 -0700 Subject: [PATCH 049/113] Unbreak tests. --- test/spec/resources/gunicorn_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index f989e17..e6d0590 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -24,6 +24,7 @@ let(:test_resource) { described_class.new(nil, nil) } before do allow(test_resource).to receive(:app_state).and_return(app_state) + allow(Dir).to receive(:exist?).and_return(!files.empty?) allow(Dir).to receive(:entries).and_return(files) end subject { test_resource.send(:default_app_module) } @@ -50,7 +51,7 @@ context 'with a foo.txt' do let(:files) { %w{foo.txt } } - it { expect { subject }.to raise_error PoiseApplicationPython::Error } + it { is_expected.to be_nil } end # /context with a foo.txt end # /describe #default_app_module end # /describe PoiseApplicationPython::Resources::Gunicorn::Resource From e570c8dce20640e92fdbbec40d6fc4f9dab9c88a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 18 Aug 2015 15:31:34 -0700 Subject: [PATCH 050/113] Use absolute_command for service commands. --- lib/poise_application_python/service_mixin.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/poise_application_python/service_mixin.rb b/lib/poise_application_python/service_mixin.rb index 2fe74d6..7d50b9a 100644 --- a/lib/poise_application_python/service_mixin.rb +++ b/lib/poise_application_python/service_mixin.rb @@ -16,6 +16,7 @@ require 'poise/utils' require 'poise_application/service_mixin' +require 'poise_languages/utils' require 'poise_application_python/app_mixin' @@ -45,7 +46,7 @@ def service_options(resource) self_ = self # Create a new singleton method that fills in Python for you. resource.define_singleton_method(:python_command) do |val| - resource.command("#{self_.new_resource.python} #{val}") + resource.command("#{self_.new_resource.python} #{PoiseLanguages::Utils.absolute_command(val, path: self_.new_resource.app_state_environment_python['PATH'])}") end # Include env vars as needed. resource.environment.update(new_resource.parent_python.python_environment) if new_resource.parent_python From b0d8e19b6ff546ba4a70ce64df680983cdc71d0b Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 18 Aug 2015 16:09:01 -0700 Subject: [PATCH 051/113] Add a more generic integration test for a simple Python app. --- .../recipes/default.rb | 21 ++++++++++++++ .../default/serverspec/default_spec.rb | 28 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/test/cookbooks/application_python_test/recipes/default.rb b/test/cookbooks/application_python_test/recipes/default.rb index 2adbfa6..ddb3fa3 100644 --- a/test/cookbooks/application_python_test/recipes/default.rb +++ b/test/cookbooks/application_python_test/recipes/default.rb @@ -16,3 +16,24 @@ # For netstat in serverspec. package 'net-tools' + +application '/opt/wsgi1' do + file '/opt/wsgi1/main.py' do + content <<-EOH +def application(environ, start_response): + status = '200 OK' + response_headers = [('Content-type', 'text/plain')] + start_response(status, response_headers) + return ['Hello world!\\n'] +EOH + end + gunicorn do + port 8000 + end + gunicorn 'wsgi1b' do + path parent.path + service_name 'wsgi1b' + app_module 'main' + port 8001 + end +end diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index e284a0f..d4bbe4a 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -18,3 +18,31 @@ require 'serverspec' set :backend, :exec + +describe 'wsgi1' do + describe port(8000) do + it { is_expected.to be_listening } + end + + let(:http) { Net::HTTP.new('localhost', 8000) } + + describe '/' do + subject { http.get('/') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to eq "Hello world!\n" } + end +end + +describe 'wsgi1b' do + describe port(8001) do + it { is_expected.to be_listening } + end + + let(:http) { Net::HTTP.new('localhost', 8001) } + + describe '/' do + subject { http.get('/') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to eq "Hello world!\n" } + end +end From f80d9316bf3abea38b0d58c92a523377cadeaa3b Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 18 Aug 2015 17:13:59 -0700 Subject: [PATCH 052/113] Add some more general integration tests. These make sure virtualenvs work. --- .../recipes/default.rb | 48 ++++++++++++++++++- .../default/serverspec/default_spec.rb | 33 +++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/test/cookbooks/application_python_test/recipes/default.rb b/test/cookbooks/application_python_test/recipes/default.rb index ddb3fa3..3b718f5 100644 --- a/test/cookbooks/application_python_test/recipes/default.rb +++ b/test/cookbooks/application_python_test/recipes/default.rb @@ -14,17 +14,19 @@ # limitations under the License. # +include_recipe 'poise-python' + # For netstat in serverspec. package 'net-tools' application '/opt/wsgi1' do file '/opt/wsgi1/main.py' do - content <<-EOH + content <<-'EOH' def application(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) - return ['Hello world!\\n'] + return ['Hello world!\n'] EOH end gunicorn do @@ -37,3 +39,45 @@ def application(environ, start_response): port 8001 end end + +application '/opt/wsgi2' do + file "#{path}/main.py" do + content <<-'EOH' +import sys +def application(environ, start_response): + status = '200 OK' + response_headers = [('Content-type', 'text/plain')] + start_response(status, response_headers) + return ['\n'.join(sys.path)] +EOH + end + gunicorn do + port 8002 + end +end + +application '/opt/wsgi3' do + file "#{path}/requirements.txt" do + content <<-EOH +requests +six +EOH + end + virtualenv + pip_requirements + file "#{path}/main.py" do + content <<-'EOH' +import sys +import requests +def application(environ, start_response): + status = '200 OK' + response_headers = [('Content-type', 'text/plain')] + start_response(status, response_headers) + return ['\n'.join(sys.path)] +EOH + end + gunicorn do + port 8003 + end +end + diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index d4bbe4a..ce79103 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -46,3 +46,36 @@ its(:body) { is_expected.to eq "Hello world!\n" } end end + +describe 'wsgi2' do + describe port(8002) do + it { is_expected.to be_listening } + end + + let(:http) { Net::HTTP.new('localhost', 8002) } + + describe '/' do + subject { http.get('/') } + its(:code) { is_expected.to eq '200' } + its(:body) { is_expected.to include '/opt/wsgi2' } + its(:body) { is_expected.to include '/lib/python2.7' } + its(:body) { is_expected.to match %r'(? Date: Tue, 18 Aug 2015 17:29:50 -0700 Subject: [PATCH 053/113] Trying out a better regexp. --- test/integration/default/serverspec/default_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index ce79103..09a6785 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -59,7 +59,7 @@ its(:code) { is_expected.to eq '200' } its(:body) { is_expected.to include '/opt/wsgi2' } its(:body) { is_expected.to include '/lib/python2.7' } - its(:body) { is_expected.to match %r'(? Date: Tue, 15 Sep 2015 23:51:42 -0700 Subject: [PATCH 054/113] Nuke all the remaining old content. --- examples/recipes-packaginator.rb | 48 -------- providers/celery.rb | 123 --------------------- providers/django.rb | 146 ------------------------- providers/gunicorn.rb | 152 -------------------------- resources/celery.rb | 48 -------- resources/django.rb | 46 -------- resources/gunicorn.rb | 50 --------- templates/default/celeryconfig.py.erb | 15 --- templates/default/settings.py.erb | 20 ---- 9 files changed, 648 deletions(-) delete mode 100644 examples/recipes-packaginator.rb delete mode 100644 providers/celery.rb delete mode 100644 providers/django.rb delete mode 100644 providers/gunicorn.rb delete mode 100644 resources/celery.rb delete mode 100644 resources/django.rb delete mode 100644 resources/gunicorn.rb delete mode 100644 templates/default/celeryconfig.py.erb delete mode 100644 templates/default/settings.py.erb diff --git a/examples/recipes-packaginator.rb b/examples/recipes-packaginator.rb deleted file mode 100644 index 7fa2bee..0000000 --- a/examples/recipes-packaginator.rb +++ /dev/null @@ -1,48 +0,0 @@ -application "packaginator" do - path "/srv/packaginator" - owner "nobody" - group "nogroup" - repository "https://github.com/coderanger/packaginator.git" - revision "master" - migrate true - packages ["libpq-dev", "git-core", "mercurial"] - - django do - packages ["redis"] - requirements "requirements/mkii.txt" - settings_template "settings.py.erb" - debug true - collectstatic "build_static --noinput" - database do - database "packaginator" - engine "postgresql_psycopg2" - username "packaginator" - password "awesome_password" - end - database_master_role "packaginator_database_master" - end - - gunicorn do - only_if { node['roles'].include? 'packaginator_application_server' } - app_module :django - port 8080 - end - - celery do - only_if { node['roles'].include? 'packaginator_application_server' } - config "celery_settings.py" - django true - celerybeat true - celerycam true - broker do - transport "redis" - end - end - - nginx_load_balancer do - only_if { node['roles'].include? 'packaginator_load_balancer' } - application_port 8080 - static_files "/site_media" => "site_media" - end - -end diff --git a/providers/celery.rb b/providers/celery.rb deleted file mode 100644 index 30fe27f..0000000 --- a/providers/celery.rb +++ /dev/null @@ -1,123 +0,0 @@ -# -# Author:: Noah Kantrowitz -# Cookbook Name:: application_python -# Provider:: django -# -# Copyright:: 2011, Opscode, Inc -# -# 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. -# - -include Chef::DSL::IncludeRecipe - -action :before_compile do - - include_recipe "supervisor" - - raise "You must specify an application module to load" unless new_resource.config - - if !new_resource.restart_command - r = new_resource - new_resource.restart_command do - run_context.resource_collection.find(:supervisor_service => "#{r.application.name}-celeryd").run_action(:restart) if r.celeryd - run_context.resource_collection.find(:supervisor_service => "#{r.application.name}-celerybeat").run_action(:restart) if r.celerybeat - run_context.resource_collection.find(:supervisor_service => "#{r.application.name}-celerycam").run_action(:restart) if r.celerycam - end - end - - new_resource.symlink_before_migrate.update({ - new_resource.config_base => new_resource.config, - }) - - new_resource.broker[:transport] ||= "amqplib" - new_resource.broker[:host_role] ||= "#{new_resource.application.name}_task_broker" - new_resource.broker[:host] ||= begin - host = new_resource.find_matching_role(new_resource.broker[:host_role]) - raise "No task broker host found" unless host - host.attribute?('cloud') ? host['cloud']['local_ipv4'] : host['ipaddress'] - end -end - -action :before_deploy do - - new_resource = @new_resource - - template ::File.join(new_resource.application.path, "shared", new_resource.config_base) do - source new_resource.template || "celeryconfig.py.erb" - cookbook new_resource.template ? new_resource.cookbook_name.to_s : "application_python" - owner new_resource.owner - group new_resource.group - mode "644" - variables :broker => new_resource.broker, :results => new_resource.results - end - - if new_resource.celerycam - # turn on events automatically, if we are going to run celerycam - new_resource.enable_events(true) - end - - cmds = {} - if new_resource.celeryd - case new_resource.queues - when Array - cmds[:celeryd] = "celeryd -Q #{new_resource.queues.join(',')} #{new_resource.enable_events ? "-E" : ""}" - when NilClass - cmds[:celeryd] = "celeryd #{new_resource.enable_events ? "-E" : ""}" - end - end - cmds[:celerybeat] = "celerybeat" if new_resource.celerybeat - if new_resource.celerycam - if new_resource.django - cmd = "celerycam" - else - raise "No camera class specified" unless new_resource.camera_class - cmd = "celeryev --camera=\"#{new_resource.camera_class}\"" - end - cmds[:celerycam] = cmd - end - - cmds.each do |type, cmd| - supervisor_service "#{new_resource.application.name}-#{type}" do - action :enable - if new_resource.django - django_resource = new_resource.application.sub_resources.select{|res| res.type == :django}.first - raise "No Django deployment resource found" unless django_resource - command "#{::File.join(django_resource.virtualenv, "bin", "python")} manage.py #{cmd}" - environment new_resource.environment - else - command cmd - if new_resource.environment - environment new_resource.environment.merge({'CELERY_CONFIG_MODULE' => new_resource.config}) - else - environment 'CELERY_CONFIG_MODULE' => new_resource.config - end - end - directory ::File.join(new_resource.path, "current") - autostart false - user new_resource.owner - end - end - -end - -action :before_migrate do -end - -action :before_symlink do -end - -action :before_restart do -end - -action :after_restart do -end diff --git a/providers/django.rb b/providers/django.rb deleted file mode 100644 index 0a58936..0000000 --- a/providers/django.rb +++ /dev/null @@ -1,146 +0,0 @@ -# -# Author:: Noah Kantrowitz -# Cookbook Name:: application_python -# Provider:: django -# -# Copyright:: 2011, Opscode, Inc -# -# 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. -# - -require 'tmpdir' - -include Chef::DSL::IncludeRecipe - -action :before_compile do - - include_recipe 'python' - - new_resource.migration_command "#{::File.join(new_resource.virtualenv, "bin", "python")} manage.py syncdb --noinput" if !new_resource.migration_command - - new_resource.symlink_before_migrate.update({ - new_resource.local_settings_base => new_resource.local_settings_file, - }) -end - -action :before_deploy do - - install_packages - - created_settings_file - -end - -action :before_migrate do - - if new_resource.requirements.nil? - # look for requirements.txt files in common locations - [ - ::File.join(new_resource.release_path, "requirements", "#{node.chef_environment}.txt"), - ::File.join(new_resource.release_path, "requirements.txt") - ].each do |path| - if ::File.exists?(path) - new_resource.requirements path - break - end - end - end - if new_resource.requirements - Chef::Log.info("Installing using requirements file: #{new_resource.requirements}") - pip_cmd = ::File.join(new_resource.virtualenv, 'bin', 'pip') - execute "#{pip_cmd} install --source=#{Dir.tmpdir} -r #{new_resource.requirements}" do - cwd new_resource.release_path - # seems that if we don't set the HOME env var pip tries to log to /root/.pip, which fails due to permissions - # setting HOME also enables us to control pip behavior on per-project basis by dropping off a pip.conf file there - # GIT_SSH allow us to reuse the deployment key used to clone the main - # repository to clone any private requirements - if new_resource.deploy_key - environment 'HOME' => ::File.join(new_resource.path,'shared'), 'GIT_SSH' => "#{new_resource.path}/deploy-ssh-wrapper" - else - environment 'HOME' => ::File.join(new_resource.path,'shared') - end - user new_resource.owner - group new_resource.group - end - else - Chef::Log.debug("No requirements file found") - end - -end - -action :before_symlink do - - if new_resource.collectstatic - cmd = new_resource.collectstatic.is_a?(String) ? new_resource.collectstatic : "collectstatic --noinput" - execute "#{::File.join(new_resource.virtualenv, "bin", "python")} manage.py #{cmd}" do - user new_resource.owner - group new_resource.group - cwd new_resource.release_path - end - end - - ruby_block "remove_run_migrations" do - block do - if node.role?("#{new_resource.application.name}_run_migrations") - Chef::Log.info("Migrations were run, removing role[#{new_resource.name}_run_migrations]") - node.run_list.remove("role[#{new_resource.name}_run_migrations]") - end - end - end - -end - -action :before_restart do -end - -action :after_restart do -end - -protected - -def install_packages - python_virtualenv new_resource.virtualenv do - path new_resource.virtualenv - owner new_resource.owner - group new_resource.group - action :create - end - - new_resource.packages.each do |name, ver| - python_pip name do - version ver if ver && ver.length > 0 - virtualenv new_resource.virtualenv - user new_resource.owner - group new_resource.group - action :install - end - end -end - -def created_settings_file - host = new_resource.find_database_server(new_resource.database_master_role) - - template "#{new_resource.path}/shared/#{new_resource.local_settings_base}" do - source new_resource.settings_template || "settings.py.erb" - cookbook new_resource.settings_template ? new_resource.cookbook_name.to_s : "application_python" - owner new_resource.owner - group new_resource.group - mode "644" - variables new_resource.settings.clone - variables.update :django => new_resource, :debug => new_resource.debug, :database => { - :host => host, - :settings => new_resource.database, - :legacy => new_resource.legacy_database_settings - } - end -end diff --git a/providers/gunicorn.rb b/providers/gunicorn.rb deleted file mode 100644 index 4a863b2..0000000 --- a/providers/gunicorn.rb +++ /dev/null @@ -1,152 +0,0 @@ -# -# Author:: Noah Kantrowitz -# Cookbook Name:: application_python -# Provider:: gunicorn -# -# Copyright:: 2011, Opscode, Inc -# -# 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. -# - -require 'tmpdir' - -include Chef::DSL::IncludeRecipe - -action :before_compile do - - include_recipe "supervisor" - - install_packages - - django_resource = new_resource.application.sub_resources.select{|res| res.type == :django}.first - gunicorn_install "gunicorn-#{new_resource.application.name}" do - virtualenv django_resource ? django_resource.virtualenv : new_resource.virtualenv - end - - if !new_resource.restart_command - r = new_resource - new_resource.restart_command do - run_context.resource_collection.find(:supervisor_service => r.application.name).run_action(:restart) - end - end - - raise "You must specify an application module to load" unless new_resource.app_module - -end - -action :before_deploy do - - new_resource = @new_resource - - gunicorn_config "#{new_resource.application.path}/shared/gunicorn_config.py" do - action :create - template new_resource.settings_template || 'gunicorn.py.erb' - cookbook new_resource.settings_template ? new_resource.cookbook_name.to_s : 'gunicorn' - if new_resource.socket_path - listen_uri = "unix:#{new_resource.socket_path}" - else - listen_uri = "#{new_resource.host}:#{new_resource.port}" - end - listen listen_uri - backlog new_resource.backlog - worker_processes new_resource.workers - worker_class new_resource.worker_class.to_s - #worker_connections - worker_max_requests new_resource.max_requests - worker_timeout new_resource.timeout - worker_keepalive new_resource.keepalive - #debug - #trace - preload_app new_resource.preload_app - #daemon - pid new_resource.pidfile - #umask - #logfile - #loglevel - #proc_name - end - - supervisor_service new_resource.application.name do - action :enable - if new_resource.environment - environment new_resource.environment - end - if new_resource.app_module == :django - django_resource = new_resource.application.sub_resources.select{|res| res.type == :django}.first - raise "No Django deployment resource found" unless django_resource - base_command = "#{::File.join(django_resource.virtualenv, "bin", "python")} manage.py run_gunicorn" - else - gunicorn_command = new_resource.virtualenv.nil? ? "gunicorn" : "#{::File.join(new_resource.virtualenv, "bin", "gunicorn")}" - base_command = "#{gunicorn_command} #{new_resource.app_module}" - end - command "#{base_command} -c #{new_resource.application.path}/shared/gunicorn_config.py" - directory new_resource.directory.nil? ? ::File.join(new_resource.path, "current") : new_resource.directory - autostart new_resource.autostart - user new_resource.owner - end - -end - -action :before_migrate do - install_requirements -end - -action :before_symlink do -end - -action :before_restart do -end - -action :after_restart do -end - -protected - -def install_packages - new_resource.packages.each do |name, ver| - python_pip name do - version ver if ver && ver.length > 0 - virtualenv new_resource.virtualenv - action :install - end - end -end - -def install_requirements - if new_resource.requirements.nil? - # look for requirements.txt files in common locations - [ - ::File.join(new_resource.release_path, "requirements", "#{node.chef_environment}.txt"), - ::File.join(new_resource.release_path, "requirements.txt") - ].each do |path| - if ::File.exists?(path) - new_resource.requirements path - break - end - end - end - if new_resource.requirements - Chef::Log.info("Installing using requirements file: #{new_resource.requirements}") - # TODO normalise with python/providers/pip.rb 's pip_cmd - if new_resource.virtualenv.nil? - pip_cmd = 'pip' - else - pip_cmd = ::File.join(new_resource.virtualenv, 'bin', 'pip') - end - execute "#{pip_cmd} install --src=#{Dir.tmpdir} -r #{new_resource.requirements}" do - cwd new_resource.release_path - end - else - Chef::Log.debug("No requirements file found") - end -end diff --git a/resources/celery.rb b/resources/celery.rb deleted file mode 100644 index 205aac0..0000000 --- a/resources/celery.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Author:: Noah Kantrowitz -# Cookbook Name:: application_python -# Resource:: celery -# -# Copyright:: 2011, Opscode, Inc -# -# 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. -# - -include ApplicationCookbook::ResourceBase - -attribute :config, :kind_of => [String, NilClass], :default => nil -attribute :template, :kind_of => [String, NilClass], :default => nil -attribute :django, :kind_of => [TrueClass, FalseClass], :default => false -attribute :celeryd, :kind_of => [TrueClass, FalseClass], :default => true -attribute :celerybeat, :kind_of => [TrueClass, FalseClass], :default => false -attribute :celerycam, :kind_of => [TrueClass, FalseClass], :default => false -attribute :camera_class, :kind_of => [String, NilClass], :default => nil -attribute :enable_events, :kind_of => [TrueClass, FalseClass], :default => false -attribute :environment, :kind_of => [Hash], :default => {} -attribute :queues, :kind_of => [Array,NilClass], :default => nil - -def config_base - config.split(/[\\\/]/).last -end - -def broker(*args, &block) - @broker ||= Mash.new - @broker.update(options_block(*args, &block)) - @broker -end - -def results(*args, &block) - @results ||= Mash.new - @results.update(options_block(*args, &block)) - @results -end diff --git a/resources/django.rb b/resources/django.rb deleted file mode 100644 index 5c5e601..0000000 --- a/resources/django.rb +++ /dev/null @@ -1,46 +0,0 @@ -# -# Author:: Noah Kantrowitz -# Cookbook Name:: application_python -# Resource:: django -# -# Copyright:: 2011, Opscode, Inc -# -# 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. -# - -include ApplicationCookbook::ResourceBase - -attribute :database_master_role, :kind_of => [String, NilClass], :default => nil -attribute :packages, :kind_of => [Array, Hash], :default => [] -attribute :requirements, :kind_of => [NilClass, String, FalseClass], :default => nil -attribute :legacy_database_settings, :kind_of => [TrueClass, FalseClass], :default => false -attribute :settings, :kind_of => Hash, :default => {} -# Actually defaults to "settings.py.erb", but nil means it wasn't set by the user -attribute :settings_template, :kind_of => [String, NilClass], :default => nil -attribute :local_settings_file, :kind_of => String, :default => 'local_settings.py' -attribute :debug, :kind_of => [TrueClass, FalseClass], :default => false -attribute :collectstatic, :kind_of => [TrueClass, FalseClass, String], :default => false - -def local_settings_base - local_settings_file.split(/[\\\/]/).last -end - -def virtualenv - "#{path}/shared/env" -end - -def database(*args, &block) - @database ||= Mash.new - @database.update(options_block(*args, &block)) - @database -end diff --git a/resources/gunicorn.rb b/resources/gunicorn.rb deleted file mode 100644 index 30e51ca..0000000 --- a/resources/gunicorn.rb +++ /dev/null @@ -1,50 +0,0 @@ -# -# Author:: Noah Kantrowitz -# Cookbook Name:: application_python -# Resource:: gunicorn -# -# Copyright:: 2011, Opscode, Inc -# -# 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. -# - -include ApplicationCookbook::ResourceBase - -attribute :app_module, :kind_of => [String, Symbol, NilClass], :default => nil -# Actually defaults to "settings.py.erb", but nil means it wasn't set by the user -attribute :settings_template, :kind_of => [String, NilClass], :default => nil -attribute :socket_path, :kind_of => [String, NilClass], :default => nil -attribute :host, :kind_of => String, :default => '0.0.0.0' -attribute :port, :kind_of => Integer, :default => 8080 -attribute :backlog, :kind_of => Integer, :default => 2048 -attribute :workers, :kind_of => Integer, :default => (node['cpu'] && node['cpu']['total']) && [node['cpu']['total'].to_i * 4, 8].min || 8 -attribute :worker_class, :kind_of => [String, Symbol], :default => :sync -attribute :worker_connections, :kind_of => Integer, :default => 1000 -attribute :max_requests, :kind_of => Integer, :default => 0 -attribute :timeout, :kind_of => Integer, :default => 30 -attribute :keepalive, :kind_of => Integer, :default => 2 -attribute :debug, :kind_of => [TrueClass, FalseClass], :default => false -attribute :trace, :kind_of => [TrueClass, FalseClass], :default => false -attribute :preload_app, :kind_of => [TrueClass, FalseClass], :default => false -attribute :daemon, :kind_of => [TrueClass, FalseClass], :default => false -attribute :pidfile, :kind_of => [String, NilClass], :default => nil -attribute :umask, :kind_of => [String, Integer], :default => 0 -attribute :logfile, :kind_of => String, :default => '-' -attribute :loglevel, :kind_of => [String, Symbol], :default => :info -attribute :proc_name, :kind_of => [String, NilClass], :default => nil -attribute :virtualenv, :kind_of => String, :default => nil -attribute :packages, :kind_of => [Array, Hash], :default => [] -attribute :requirements, :kind_of => [NilClass, String, FalseClass], :default => nil -attribute :environment, :kind_of => [Hash], :default => {} -attribute :autostart, :kind_of => [TrueClass, FalseClass], :default => false -attribute :directory, :kind_of => [NilClass, String], :default => nil diff --git a/templates/default/celeryconfig.py.erb b/templates/default/celeryconfig.py.erb deleted file mode 100644 index 1aad650..0000000 --- a/templates/default/celeryconfig.py.erb +++ /dev/null @@ -1,15 +0,0 @@ -BROKER_TRANSPORT = "<%= @broker[:transport] %>" -BROKER_HOST = "<%= @broker[:host] %>" -<% %w{port user password vhost}.each do |key| %> -<% if @broker[key] %> -BROKER_<%= key.upcase %> = "<%= @broker[key] %>" -<% end %> -<% end %> -<% %w{pool_limit connection_timeout connection_retry connection_max_retries}.each do |key| %> -<% if @broker[key] %> -BROKER_<%= key.upcase %> = <%= @broker[key] %> -<% end %> -<% end %> -<% if @broker[:use_ssl] %> -BROKER_USE_SSL = True -<% end %> diff --git a/templates/default/settings.py.erb b/templates/default/settings.py.erb deleted file mode 100644 index 794eb25..0000000 --- a/templates/default/settings.py.erb +++ /dev/null @@ -1,20 +0,0 @@ -DEBUG = <%= @debug ? "True" : "False" %> - -DATABASES = { - 'default': { - 'NAME': '<%= @database[:settings][:database] %>', - 'ENGINE': 'django.db.backends.<%= @database[:settings][:adapter] %>', - 'USER': '<%= @database[:settings][:username] %>', - 'PASSWORD': '<%= @database[:settings][:password] %>', - 'HOST': '<%= @database[:host] %>', - 'PORT': '<%= @database[:settings][:port] %>', - }, -} -<% if @database[:legacy] -%> -DATABASE_ENGINE = DATABASES['default']['ENGINE'] -DATABASE_NAME = DATABASES['default']['NAME'] -DATABASE_USER = DATABASES['default']['USER'] -DATABASE_PASSWORD = DATABASES['default']['PASSWORD'] -DATABASE_HOST = DATABASES['default']['HOST'] -DATABASE_PORT = DATABASES['default']['PORT'] -<% end -%> From b0da493a3e72368e84ecd78725c1fefd73bc5b11 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 16 Sep 2015 18:02:15 -0700 Subject: [PATCH 055/113] Copy pasta fail. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 556a682..305f2ec 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Chef 12 or newer is required. ## Resources -### `application_celery_worker` +### `application_celery_beat` The `application_celery_beat` resource creates a service for the `celery beat` process. From 9a7f233debc967dd2454efa2dca4b9d4890909a6 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 16 Sep 2015 18:02:31 -0700 Subject: [PATCH 056/113] Add wrapper resources for python_execute and python_package. --- README.md | 28 ++++++ lib/poise_application_python/resources.rb | 2 + .../resources/python_execute.rb | 93 +++++++++++++++++++ .../resources/python_package.rb | 64 +++++++++++++ test/spec/resources/python_execute_spec.rb | 46 +++++++++ test/spec/spec_helper.rb | 1 + 6 files changed, 234 insertions(+) create mode 100644 lib/poise_application_python/resources/python_execute.rb create mode 100644 lib/poise_application_python/resources/python_package.rb create mode 100644 test/spec/resources/python_execute_spec.rb diff --git a/README.md b/README.md index 305f2ec..0da386f 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,34 @@ end All actions and properties are the same as the [`python_runtime` resource](https://github.com/poise/poise-python#python_runtime). +### `application_python_execute` + +The `application_python_execute` resource runs Python commands for the deployment. + +```ruby +application '/srv/myapp' do + python_execute 'setup.py install' +end +``` + +All actions and properties are the same as the [`python_execute` resource](https://github.com/poise/poise-python#python_execute), +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. + +```ruby +application '/srv/myapp' do + python_package 'requests' +end +``` + +All actions and properties are the same as the [`python_package` resource](https://github.com/poise/poise-python#python_package), +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 diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index 0746eae..7504c82 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -21,4 +21,6 @@ require 'poise_application_python/resources/gunicorn' require 'poise_application_python/resources/pip_requirements' require 'poise_application_python/resources/python' +require 'poise_application_python/resources/python_execute' +require 'poise_application_python/resources/python_package' require 'poise_application_python/resources/virtualenv' diff --git a/lib/poise_application_python/resources/python_execute.rb b/lib/poise_application_python/resources/python_execute.rb new file mode 100644 index 0000000..c4a28a0 --- /dev/null +++ b/lib/poise_application_python/resources/python_execute.rb @@ -0,0 +1,93 @@ +# +# 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. +# + +require 'poise_python/resources/python_execute' + +require 'poise_application_python/app_mixin' + + +module PoiseApplicationPython + module Resources + # (see PythonExecute::Resource) + # @since 4.0.0 + module PythonExecute + # An `application_python_execute` resource to run Python commands inside an + # Application cookbook deployment. + # + # @provides application_python_execute + # @provides application_python_python_execute + # @action run + # @example + # application '/srv/myapp' do + # python_execute 'setup.py install' + # end + class Resource < PoisePython::Resources::PythonExecute::Resource + include PoiseApplicationPython::AppMixin + provides(:application_python_execute) + provides(:application_python_python_execute) + + def initialize(*args) + super + # Clear some instance variables so my defaults work. + remove_instance_variable(:@cwd) + remove_instance_variable(:@group) + remove_instance_variable(:@user) + end + + # #!attribute cwd + # Override the default directory to be the app path if unspecified. + # @return [String] + attribute(:cwd, kind_of: [String, NilClass, FalseClass], default: lazy { parent && parent.path }) + + # #!attribute group + # Override the default group to be the app group if unspecified. + # @return [String, Integer] + attribute(:group, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.group }) + + # #!attribute user + # Override the default user to be the app owner if unspecified. + # @return [String, Integer] + attribute(:user, kind_of: [String, Integer, NilClass, FalseClass], default: lazy { parent && parent.owner }) + end + + # The default provider for `application_python_execute`. + # + # @see Resource + # @provides application_python_execute + # @provides application_python_python_execute + class Provider < PoisePython::Resources::PythonExecute::Provider + provides(:application_python_execute) + provides(:application_python_python_execute) + + private + + # Override environment to add the application envivonrment instead. + # + # @return [Hash] + def environment + super.tap do |environment| + # Don't use the app_state_environment_python because we already have + # those values in place. + environment.update(new_resource.app_state_environment) + # Re-apply the resource environment for correct ordering. + environment.update(new_resource.environment) if new_resource.environment + end + end + end + + end + end +end diff --git a/lib/poise_application_python/resources/python_package.rb b/lib/poise_application_python/resources/python_package.rb new file mode 100644 index 0000000..eda4fec --- /dev/null +++ b/lib/poise_application_python/resources/python_package.rb @@ -0,0 +1,64 @@ +# +# 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. +# + +require 'poise_python/resources/python_package' + +require 'poise_application_python/app_mixin' + + +module PoiseApplicationPython + module Resources + # (see PythonPackage::Resource) + # @since 4.0.0 + module PythonPackage + # An `application_python_package` resource to install Python + # packages inside an Application cookbook deployment. + # + # @provides application_python_package + # @provides application_python_python_package + # @action install + # @action upgrade + # @action remove + # @example + # application '/srv/myapp' do + # python_package 'requests' + # end + class Resource < PoisePython::Resources::PythonPackage::Resource + include PoiseApplicationPython::AppMixin + provides(:application_python_package) + provides(:application_python_python_package) + subclass_providers! + + def initialize(*args) + super + # For older Chef. + @resource_name = :application_python_package + end + + # #!attribute group + # Override the default group to be the app group if unspecified. + # @return [String, Integer] + attribute(:group, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.group }) + + # #!attribute user + # Override the default user to be the app owner if unspecified. + # @return [String, Integer] + attribute(:user, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.owner }) + end + + end + end +end diff --git a/test/spec/resources/python_execute_spec.rb b/test/spec/resources/python_execute_spec.rb new file mode 100644 index 0000000..cec088c --- /dev/null +++ b/test/spec/resources/python_execute_spec.rb @@ -0,0 +1,46 @@ +# +# 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. +# + +require 'spec_helper' + +describe PoiseApplicationPython::Resources::PythonExecute do + step_into(:application_python_execute) + recipe do + application '/srv/myapp' do + owner 'myuser' + group 'mygroup' + environment ENVKEY: 'ENVVALUE' + + python('') { provider :dummy } + python_execute 'myapp.py' + end + end + + it do + expect_any_instance_of(described_class::Provider).to receive(:shell_out!).with( + '/python myapp.py', + user: 'myuser', + group: 'mygroup', + cwd: '/srv/myapp', + timeout: 3600, + returns: 0, + environment: {'ENVKEY' => 'ENVVALUE'}, + log_level: :info, + log_tag: 'application_python_execute[myapp.py]', + ) + is_expected.to run_application_python_execute('myapp.py').with(user: 'myuser', group: 'mygroup', cwd: '/srv/myapp') + end +end diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb index d8ca917..582e987 100644 --- a/test/spec/spec_helper.rb +++ b/test/spec/spec_helper.rb @@ -16,3 +16,4 @@ require 'poise_boiler/spec_helper' require 'poise_application_python' +require 'poise_application/cheftie' From 062d6a8e942e5c5f6004a75f054c7216271a9f2a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 17 Sep 2015 12:15:42 -0700 Subject: [PATCH 057/113] Name de-mangle. --- lib/poise_application_python/resources/python.rb | 5 ++--- lib/poise_application_python/resources/python_execute.rb | 4 ---- lib/poise_application_python/resources/python_package.rb | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/poise_application_python/resources/python.rb b/lib/poise_application_python/resources/python.rb index 50d38c1..2c40d58 100644 --- a/lib/poise_application_python/resources/python.rb +++ b/lib/poise_application_python/resources/python.rb @@ -28,7 +28,7 @@ module Python # inside an Application cookbook deployment. # # @provides application_python - # @provides application_python_python_runtime + # @provides application_python_runtime # @action install # @action uninstall # @example @@ -38,8 +38,7 @@ module Python class Resource < PoisePython::Resources::PythonRuntime::Resource include PoiseApplicationPython::AppMixin provides(:application_python) - # Need the double python for application resource rewriting. - provides(:application_python_python_runtime) + provides(:application_python_runtime) container_default(false) subclass_providers! diff --git a/lib/poise_application_python/resources/python_execute.rb b/lib/poise_application_python/resources/python_execute.rb index c4a28a0..43275b0 100644 --- a/lib/poise_application_python/resources/python_execute.rb +++ b/lib/poise_application_python/resources/python_execute.rb @@ -28,7 +28,6 @@ module PythonExecute # Application cookbook deployment. # # @provides application_python_execute - # @provides application_python_python_execute # @action run # @example # application '/srv/myapp' do @@ -37,7 +36,6 @@ module PythonExecute class Resource < PoisePython::Resources::PythonExecute::Resource include PoiseApplicationPython::AppMixin provides(:application_python_execute) - provides(:application_python_python_execute) def initialize(*args) super @@ -67,10 +65,8 @@ def initialize(*args) # # @see Resource # @provides application_python_execute - # @provides application_python_python_execute class Provider < PoisePython::Resources::PythonExecute::Provider provides(:application_python_execute) - provides(:application_python_python_execute) private diff --git a/lib/poise_application_python/resources/python_package.rb b/lib/poise_application_python/resources/python_package.rb index eda4fec..7936a25 100644 --- a/lib/poise_application_python/resources/python_package.rb +++ b/lib/poise_application_python/resources/python_package.rb @@ -28,7 +28,6 @@ module PythonPackage # packages inside an Application cookbook deployment. # # @provides application_python_package - # @provides application_python_python_package # @action install # @action upgrade # @action remove @@ -39,7 +38,6 @@ module PythonPackage class Resource < PoisePython::Resources::PythonPackage::Resource include PoiseApplicationPython::AppMixin provides(:application_python_package) - provides(:application_python_python_package) subclass_providers! def initialize(*args) From c6467615cdac0d01ac524a82c152e65c318cb0ce Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 17 Sep 2015 12:31:16 -0700 Subject: [PATCH 058/113] Fix name mangle here too. --- lib/poise_application_python/resources/virtualenv.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb index 743251c..442d74c 100644 --- a/lib/poise_application_python/resources/virtualenv.rb +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -27,8 +27,8 @@ module Virtualenv # An `application_virtualenv` resource to manage Python virtual # environments inside an Application cookbook deployment. # - # @provides application_python_virtualenv # @provides application_virtualenv + # @provides application_python_virtualenv # @action create # @action delete # @example @@ -38,8 +38,7 @@ module Virtualenv class Resource < PoisePython::Resources::PythonVirtualenv::Resource include PoiseApplicationPython::AppMixin provides(:application_virtualenv) - # Need the double python for application resource rewriting. - provides(:application_python_python_virtualenv) + provides(:application_python_virtualenv) container_default(false) subclass_providers! From 6ef495d93cea0a52281a87865cf04218b7bead8c Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 20 Sep 2015 22:04:00 -0700 Subject: [PATCH 059/113] Why did I think it was okay to write the config last? Why did this work at all? --- lib/poise_application_python/resources/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 9fe59e0..ad5dd8d 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -240,10 +240,10 @@ class Provider < Chef::Provider def action_deploy set_state notifying_block do + write_config run_syncdb run_migrate run_collectstatic - write_config end end From c41658178adfb60f176be630d5ef1dc4437c2022 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 20 Sep 2015 22:05:45 -0700 Subject: [PATCH 060/113] Errors have to be late-binding because defaults are always evaluated now. Bleh, this is gross but it will take a much deeper poise rewrite to allow it. --- .../resources/django.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index ad5dd8d..29e48f2 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -169,11 +169,21 @@ def default_manage_path end def default_settings_module - PoisePython::Utils.path_to_module(find_file('settings.py'), path) + settings_path = find_file('settings.py') + if settings_path + PoisePython::Utils.path_to_module(settings_path, path) + else + nil + end end def default_wsgi_module - PoisePython::Utils.path_to_module(find_file('wsgi.py'), path) + wsgi_path = find_file('wsgi.py') + if wsgi_path + PoisePython::Utils.path_to_module(wsgi_path, path) + else + nil + end end # Format a URL for DATABASES. @@ -205,8 +215,6 @@ def find_file(name) cmp = a <=> b end cmp - end.tap do |p| - raise PoiseApplicationPython::Error.new("Unable to find a file matching #{name}") unless p end end @@ -288,6 +296,7 @@ def write_config # Run a manage.py command using `python_execute`. def manage_py_execute(*cmd) + raise PoiseApplicationPython::Error.new("Unable to find a find a manage.py for #{new_resource}, please set manage_path") unless new_resource.manage_path python_execute "manage.py #{cmd.join(' ')}" do python_from_parent new_resource command [new_resource.manage_path] + cmd From 4044900846b87e3b2ddbf43b25008183a470d351 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 2 Oct 2015 14:57:38 -0700 Subject: [PATCH 061/113] Release versions of a bunch of things, for testing! --- Gemfile | 8 ++++---- poise-application-python.gemspec | 2 +- test/gemfiles/master.gemfile | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index f09fcb7..3484877 100644 --- a/Gemfile +++ b/Gemfile @@ -28,10 +28,10 @@ def dev_gem(name, path: File.join('..', name), github: nil) end dev_gem 'halite' -dev_gem 'poise', github: 'poise/poise' +dev_gem 'poise' dev_gem 'poise-application', path: '../application', github: 'poise/application' dev_gem 'poise-application-git', path: '../application_git', github: 'poise/application_git' dev_gem 'poise-boiler' -dev_gem 'poise-languages', github: 'poise/poise-languages' -dev_gem 'poise-python', github: 'poise/poise-python' -dev_gem 'poise-service', github: 'poise/poise-service' +dev_gem 'poise-languages' +dev_gem 'poise-python' +dev_gem 'poise-service' diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 9913100..fa6d127 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'halite', '~> 1.0' spec.add_dependency 'poise', '~> 2.0' spec.add_dependency 'poise-application', '~> 5.0.pre' - spec.add_dependency 'poise-python', '~> 1.0.pre' + spec.add_dependency 'poise-python', '~> 1.0' spec.add_dependency 'poise-service', '~> 1.0' spec.add_development_dependency 'poise-boiler', '~> 1.0' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 191be7e..9e1acf1 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -22,5 +22,6 @@ gem 'poise', github: 'poise/poise' # gem 'poise-application', github: 'poise/application' # gem 'poise-application-git', github: 'poise/application_git' gem 'poise-boiler', github: 'poise/poise-boiler' -# gem 'poise-python', github: 'poise/poise-python' +gem 'poise-languages', github: 'poise/poise-languages' +gem 'poise-python', github: 'poise/poise-python' gem 'poise-service', github: 'poise/poise-service' From a02befd3134d2b810aa356fdd0d7dc87e2328418 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 2 Oct 2015 20:31:13 -0700 Subject: [PATCH 062/113] Release version testing. --- Gemfile | 4 ++-- poise-application-python.gemspec | 3 ++- test/gemfiles/master.gemfile | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 3484877..be4f84d 100644 --- a/Gemfile +++ b/Gemfile @@ -29,8 +29,8 @@ end dev_gem 'halite' dev_gem 'poise' -dev_gem 'poise-application', path: '../application', github: 'poise/application' -dev_gem 'poise-application-git', path: '../application_git', github: 'poise/application_git' +dev_gem 'poise-application', path: '../application' +dev_gem 'poise-application-git', path: '../application_git' dev_gem 'poise-boiler' dev_gem 'poise-languages' dev_gem 'poise-python' diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index fa6d127..889e7ef 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -36,9 +36,10 @@ Gem::Specification.new do |spec| spec.add_dependency 'halite', '~> 1.0' spec.add_dependency 'poise', '~> 2.0' - spec.add_dependency 'poise-application', '~> 5.0.pre' + spec.add_dependency 'poise-application', '~> 5.0' spec.add_dependency 'poise-python', '~> 1.0' spec.add_dependency 'poise-service', '~> 1.0' spec.add_development_dependency 'poise-boiler', '~> 1.0' + spec.add_development_dependency 'poise-application-git', '~> 1.0' end diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 9e1acf1..4d2eaa6 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -19,8 +19,8 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', github: 'chef/chef' gem 'halite', github: 'poise/halite' gem 'poise', github: 'poise/poise' -# gem 'poise-application', github: 'poise/application' -# gem 'poise-application-git', github: 'poise/application_git' +gem 'poise-application', github: 'poise/application' +gem 'poise-application-git', github: 'poise/application_git' gem 'poise-boiler', github: 'poise/poise-boiler' gem 'poise-languages', github: 'poise/poise-languages' gem 'poise-python', github: 'poise/poise-python' From edb690cd9b75250c2e47d953376f01338d6b3bda Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 11:45:13 -0700 Subject: [PATCH 063/113] Reformat changelog. [ci skip] --- CHANGELOG.md | 104 ++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 313da6f..df1d7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,83 +1,67 @@ -application_python Cookbok CHANGELOG -==================================== -This file is used to list changes made in each version of the application_python cookbook. +# Application_Python Changelog +## v3.0.0 -v3.0.0 ------- -### Breaking -- Drop support for Chef 10 +* Drop support for Chef 10. +* [COOK-2212](https://tickets.opscode.com/browse/COOK-2212) - autostart when server reboots. +* [COOK-3432](https://tickets.opscode.com/browse/COOK-3432) - Use `Chef::DSL::IncludeRecipe` because `Chef::Mixin::LanguageIncludeRecipe` is deprecated. -### Bug -- **[COOK-2212](https://tickets.opscode.com/browse/COOK-2212)** - autostart when server reboots -- **[COOK-3432](https://tickets.opscode.com/browse/COOK-3432)** - Use `Chef::DSL::IncludeRecipe` because `Chef::Mixin::LanguageIncludeRecipe` is deprecated +## v2.0.4 -v2.0.4 ------- -- Revery changes that broke backwards compatability +* Revert changes that broke backwards compatibility. -v2.0.2 ------- -**This release did not follow semver and was reverted in 2.0.4!** +## v2.0.2 -### Bug -- **[COOK-3432](https://tickets.opscode.com/browse/COOK-3432)** - Use `Chef::DSL::IncludeRecipe` because `Chef::Mixin::LanguageIncludeRecipe` is deprecated +* **This release did not follow semver and was reverted in 2.0.4!** +* [COOK-3432](https://tickets.opscode.com/browse/COOK-3432) - Use `Chef::DSL::IncludeRecipe` because `Chef::Mixin::LanguageIncludeRecipe` is deprecated. -v2.0.0 ------- -### Bug -- [COOK-3306]: Multiple Memory Leaks in Application Cookbook +## v2.0.0 -v1.2.4 ------- -### Bug +* [COOK-3306]: Multiple Memory Leaks in Application Cookbook. -- [COOK-2747]: celerycam configuration is not suitable for multiple node celery installation -- [COOK-2766]: pip does not use `deploy_key` in django ressource of `application_python` +## v1.2.4 -v1.2.2 ------- -### Bug -- [COOK-2796]: celery provider tries to case switch on 'queue' parameter instead of 'queues' parameter +* [COOK-2747]: celerycam configuration is not suitable for multiple node celery installation. +* [COOK-2766]: pip does not use `deploy_key` in django ressource of `application_python`. -v1.2.0 ------- -### Improvement -- [COOK-2611]: Celery LWRP should configure which queues a celeryd worker binds to +## v1.2.2 -### Bug +* [COOK-2796]: celery provider tries to case switch on 'queue' parameter instead of 'queues' parameter. -- [COOK-2599]: gunicorn provider fails if no `node['cpu']['total']` +## 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 -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 +* [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 -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.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 -v1.0.4 ------- -* [COOK-2042] - gunicorn LWRP support for virtualenv, deps +* [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.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 -v1.0.0 ------- * [COOK-1246] - Initial release - relates to COOK-634. From 4ed8de8561d77c9b56830d8fa27cda5d5f6c2c44 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 11:47:16 -0700 Subject: [PATCH 064/113] Update changelog. [ci skip] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df1d7c5..f2b213a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 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. From 04c78e745d105d89d169260335cde970fc0fe84a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 16:35:53 -0700 Subject: [PATCH 065/113] Sigh windows, not sure how to handle this. --- lib/poise_application_python/resources/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 29e48f2..211546c 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -210,7 +210,7 @@ def parse_database_url(url) def find_file(name) Dir[::File.join(path, '**', name)].min do |a, b| - cmp = a.count(::File::SEPARATOR) <=> b.count(::File::SEPARATOR) + cmp = a.count(::File::ALT_SEPARATOR || ::File::SEPARATOR) <=> b.count(::File::ALT_SEPARATOR || ::File::SEPARATOR) if cmp == 0 cmp = a <=> b end From 01d71a096dc7f7dbc1ba8fbd129ca04c55804031 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 16:36:17 -0700 Subject: [PATCH 066/113] Docstring. --- lib/poise_application_python/resources/django.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 211546c..811acc3 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -208,6 +208,11 @@ def parse_database_url(url) end end + # Search for a file somewhere under the application path. Prefers files + # closer to the root, then sort alphabetically for stability. + # + # @param name [String] Filename to search for. + # @return [String, nil] def find_file(name) Dir[::File.join(path, '**', name)].min do |a, b| cmp = a.count(::File::ALT_SEPARATOR || ::File::SEPARATOR) <=> b.count(::File::ALT_SEPARATOR || ::File::SEPARATOR) From b0986b6eb2da7ca8aa32e7abf5f110ee3a7aa9ce Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 16:36:23 -0700 Subject: [PATCH 067/113] Tests for find_file. --- test/spec/resources/django_spec.rb | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index 9cc6928..53a0b34 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -135,5 +135,41 @@ SETTINGS end # /context with a secret key end # /describe #local_settings + + describe '#find_file' do + let(:files) { [] } + recipe(subject: false) do + application_django '/test' + end + subject { chef_run.application_django('/test').send(:find_file, 'myfile.py') } + before do + allow(Dir).to receive(:[]).and_call_original + allow(Dir).to receive(:[]).with('/test/**/myfile.py').and_return(files) + end + + context 'with no matching files' do + it { is_expected.to be_nil } + end # /context with no matching files + + context 'with one matching file' do + let(:files) { %w{/test/myfile.py} } + it { is_expected.to eq '/test/myfile.py' } + end # /context with one matching file + + context 'with two matching files' do + let(:files) { %w{/test/myfile.py /test/sub/myfile.py} } + it { is_expected.to eq '/test/myfile.py' } + end # /context with two matching files + + context 'with two matching files in a different order' do + let(:files) { %w{/test/sub/myfile.py /test/myfile.py} } + it { is_expected.to eq '/test/myfile.py' } + end # /context with two matching files in a different order + + context 'with two matching files on the same level' do + let(:files) { %w{/test/b/myfile.py /test/a/myfile.py} } + it { is_expected.to eq '/test/a/myfile.py' } + end # /context with two matching files on the same level + end # /describe #find_file end # /describe PoiseApplicationPython::Resources::Django::Resource end From c715af2c0350b696b31cd8c6f0272c7149a7da62 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 16:40:06 -0700 Subject: [PATCH 068/113] Better logic for counting folder layers. --- lib/poise_application_python/resources/django.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 811acc3..0e71609 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -214,8 +214,15 @@ def parse_database_url(url) # @param name [String] Filename to search for. # @return [String, nil] def find_file(name) + num_separators = lambda do |path| + if ::File::ALT_SEPARATOR && path.include?(::File::ALT_SEPARATOR) + path.count(::File::ALT_SEPARATOR) + else + path.count(::File::SEPARATOR) + end + end Dir[::File.join(path, '**', name)].min do |a, b| - cmp = a.count(::File::ALT_SEPARATOR || ::File::SEPARATOR) <=> b.count(::File::ALT_SEPARATOR || ::File::SEPARATOR) + cmp = num_separators.call(a) <=> num_separators.call(b) if cmp == 0 cmp = a <=> b end From a7935d696cf46f07f88a310d1936eff7ef7bbe1f Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 17:11:13 -0700 Subject: [PATCH 069/113] Don't do coverage checking on this line because it only hits on Windows. --- lib/poise_application_python/resources/django.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 0e71609..9299b49 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -216,7 +216,9 @@ def parse_database_url(url) def find_file(name) num_separators = lambda do |path| if ::File::ALT_SEPARATOR && path.include?(::File::ALT_SEPARATOR) + # :nocov: path.count(::File::ALT_SEPARATOR) + # :nocov: else path.count(::File::SEPARATOR) end From f30395d3a3bd7a80bcb07f832d5f028a0abac20c Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 17:11:54 -0700 Subject: [PATCH 070/113] Docstrings! --- .../resources/django.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 9299b49..03089a5 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -141,6 +141,10 @@ class Resource < Chef::Resource private + # Default value for {#local_settings_options}. Adds Django settings data + # from the resource to be rendered in the local settings template. + # + # @return [Hash] def default_local_settings_options {}.tap do |options| options[:allowed_hosts] = Array(allowed_hosts) @@ -157,6 +161,10 @@ def default_local_settings_options end end + # Default value for {#local_settings_path}, local_settings.py next to + # the configured {#settings_module}. + # + # @return [String, nil] def default_local_settings_path # If no settings module, no default local settings. return unless settings_module @@ -164,10 +172,18 @@ def default_local_settings_path ::File.expand_path(::File.join('..', 'local_settings.py'), settings_path) end + # Default value for {#manage_path}, searches for manage.py in the + # application path. + # + # @return [String, nil] def default_manage_path find_file('manage.py') end + # Default value for {#settings_module}, searches for settings.py in the + # application path. + # + # @return [String, nil] def default_settings_module settings_path = find_file('settings.py') if settings_path @@ -177,6 +193,10 @@ def default_settings_module end end + # Default value for {#wsgi_module}, searchs for wsgi.py in the + # application path. + # + # @return [String, nil] def default_wsgi_module wsgi_path = find_file('wsgi.py') if wsgi_path From d4eb7a614360cc09a3f5e6c72e60425c01a674f9 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 17:11:59 -0700 Subject: [PATCH 071/113] More tests! --- test/spec/resources/django_spec.rb | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index 53a0b34..ee0899b 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -136,6 +136,42 @@ end # /context with a secret key end # /describe #local_settings + describe '#default_local_settings_path' do + subject { chef_run.application_django('/test').send(:default_local_settings_path) } + + context 'with no settings.py' do + recipe(subject: false) do + application_django '/test' do + def settings_module + nil + end + end + end + it { is_expected.to be_nil } + end # /context with no settings.py + + context 'with basic settings.py' do + recipe(subject: false) do + application_django '/test' do + settings_module 'myapp.settings' + end + end + it { is_expected.to eq '/test/myapp/local_settings.py' } + end # /context with basic settings.py + end # /describe #default_local_settings_path + + describe '#default_manage_path' do + subject { chef_run.application_django('/test').send(:default_manage_path) } + recipe(subject: false) do + application_django '/test' + end + before do + allow(chef_run.application_django('/test')).to receive(:find_file).with('manage.py').and_return('/test/manage.py') + end + + it { is_expected.to eq '/test/manage.py' } + end # /describe #default_manage_path + describe '#find_file' do let(:files) { [] } recipe(subject: false) do From ffdfbc1ba38e56a20d40ec4203029aed00aca061 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 17:40:56 -0700 Subject: [PATCH 072/113] Deal with relative manage paths. --- lib/poise_application_python/resources/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 03089a5..f9b5edf 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -333,7 +333,7 @@ def manage_py_execute(*cmd) raise PoiseApplicationPython::Error.new("Unable to find a find a manage.py for #{new_resource}, please set manage_path") unless new_resource.manage_path python_execute "manage.py #{cmd.join(' ')}" do python_from_parent new_resource - command [new_resource.manage_path] + cmd + command [::File.expand_path(new_resource.manage_path, new_resource.path)] + cmd cwd new_resource.path environment new_resource.app_state_environment group new_resource.parent.group From 3fd30f721619263934da421a7559bd7318862d73 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 17:41:22 -0700 Subject: [PATCH 073/113] Use the new #owner and #group properties from AppMixin. This allows running without a parent. --- Gemfile | 2 +- lib/poise_application_python/resources/django.rb | 8 ++++---- poise-application-python.gemspec | 2 +- test/gemfiles/master.gemfile | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index be4f84d..0d699f0 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ end dev_gem 'halite' dev_gem 'poise' -dev_gem 'poise-application', path: '../application' +dev_gem 'poise-application', path: '../application', github: 'poise/application' dev_gem 'poise-application-git', path: '../application_git' dev_gem 'poise-boiler' dev_gem 'poise-languages' diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index f9b5edf..add4b91 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -323,8 +323,8 @@ def write_config file new_resource.local_settings_path do content new_resource.local_settings_content mode '640' - owner new_resource.parent.owner - group new_resource.parent.group + owner new_resource.owner + group new_resource.group end end @@ -336,8 +336,8 @@ def manage_py_execute(*cmd) command [::File.expand_path(new_resource.manage_path, new_resource.path)] + cmd cwd new_resource.path environment new_resource.app_state_environment - group new_resource.parent.group - user new_resource.parent.owner + group new_resource.group + user new_resource.owner end end diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 889e7ef..285f26e 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'halite', '~> 1.0' spec.add_dependency 'poise', '~> 2.0' - spec.add_dependency 'poise-application', '~> 5.0' + spec.add_dependency 'poise-application', '~> 5.1.pre' spec.add_dependency 'poise-python', '~> 1.0' spec.add_dependency 'poise-service', '~> 1.0' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 4d2eaa6..204b033 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -19,7 +19,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', github: 'chef/chef' gem 'halite', github: 'poise/halite' gem 'poise', github: 'poise/poise' -gem 'poise-application', github: 'poise/application' +# gem 'poise-application', github: 'poise/application' gem 'poise-application-git', github: 'poise/application_git' gem 'poise-boiler', github: 'poise/poise-boiler' gem 'poise-languages', github: 'poise/poise-languages' From bee3a8ef7b120f0d3ab932de11cb8c28b73a93d4 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 17:41:26 -0700 Subject: [PATCH 074/113] A bunch more tests. --- test/spec/resources/django_spec.rb | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index ee0899b..159eb57 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -172,6 +172,46 @@ def settings_module it { is_expected.to eq '/test/manage.py' } end # /describe #default_manage_path + describe '#default_settings_module' do + let(:settings_path) { nil } + subject { chef_run.application_django('/test').send(:default_settings_module) } + recipe(subject: false) do + application_django '/test' + end + before do + allow(chef_run.application_django('/test')).to receive(:find_file).with('settings.py').and_return(settings_path) + end + + context 'with no settings.py' do + it { is_expected.to be_nil } + end # /context with no settings.py + + context 'with simple settings.py' do + let(:settings_path) { '/test/myapp/settings.py' } + it { is_expected.to eq 'myapp.settings' } + end # /context with simple settings.py + end # /describe #default_settings_module + + describe '#default_wsgi_module' do + let(:wsgi_path) { nil } + subject { chef_run.application_django('/test').send(:default_wsgi_module) } + recipe(subject: false) do + application_django '/test' + end + before do + allow(chef_run.application_django('/test')).to receive(:find_file).with('wsgi.py').and_return(wsgi_path) + end + + context 'with no wsgi.py' do + it { is_expected.to be_nil } + end # /context with no wsgi.py + + context 'with simple wsgi.py' do + let(:wsgi_path) { '/test/wsgi.py' } + it { is_expected.to eq 'wsgi' } + end # /context with simple wsgi.py + end # /describe #default_wsgi_module + describe '#find_file' do let(:files) { [] } recipe(subject: false) do @@ -208,4 +248,56 @@ def settings_module end # /context with two matching files on the same level end # /describe #find_file end # /describe PoiseApplicationPython::Resources::Django::Resource + + describe PoiseApplicationPython::Resources::Django::Provider do + step_into(:application_django) + context 'with default settings' do + recipe do + application_django '/test' do + # Hardwire all paths so it doesn't have to search. + manage_path 'manage.py' + settings_module 'myapp.settings' + wsgi_module 'wsgi' + end + end + + it { is_expected.to run_python_execute('manage.py collectstatic --noinput') } + it { is_expected.to_not run_python_execute('manage.py syncdb --noinput') } + it { is_expected.to_not run_python_execute('manage.py migrate --noinput') } + it { is_expected.to render_file('/test/myapp/local_settings.py') } + end # /context with default settings + + context 'with syncdb' do + recipe do + application_django '/test' do + # Hardwire all paths so it doesn't have to search. + manage_path 'manage.py' + settings_module 'myapp.settings' + syncdb true + wsgi_module 'wsgi' + end + end + + it { is_expected.to run_python_execute('manage.py collectstatic --noinput') } + it { is_expected.to run_python_execute('manage.py syncdb --noinput') } + it { is_expected.to_not run_python_execute('manage.py migrate --noinput') } + end # /context with syncdb + + context 'with migrate' do + recipe do + application_django '/test' do + # Hardwire all paths so it doesn't have to search. + manage_path 'manage.py' + migrate true + settings_module 'myapp.settings' + wsgi_module 'wsgi' + end + end + + it { is_expected.to run_python_execute('manage.py collectstatic --noinput') } + it { is_expected.to_not run_python_execute('manage.py syncdb --noinput') } + it { is_expected.to run_python_execute('manage.py migrate --noinput') } + it { is_expected.to render_file('/test/myapp/local_settings.py') } + end # /context with migrate + end # /describe PoiseApplicationPython::Resources::Django::Provider end From 8ba4436c15a9e747647af82c37db82ce41be505f Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sat, 3 Oct 2015 18:03:47 -0700 Subject: [PATCH 075/113] Mention the local_settings property. [ci skip] --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0da386f..5b9340e 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,8 @@ end * `database` – Database settings for the default connection. See [the database section below](#database-parameters) for more information. *(option collector)* * `debug` – Enable debug mode for Django. *(default: false)* +* `local_settings` – A [Poise template property](https://github.com/poise/poise#template-content) + 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)* From d012d476cd152ee2e0034fed2e38b3585b90c8cf Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 4 Oct 2015 15:30:27 -0700 Subject: [PATCH 076/113] Undo the changes to appmixin, roll them into the resources that need them. --- .../resources/celery_config.rb | 12 ++++++++++-- lib/poise_application_python/resources/django.rb | 8 ++++++++ poise-application-python.gemspec | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/poise_application_python/resources/celery_config.rb b/lib/poise_application_python/resources/celery_config.rb index 68aced6..a8680e0 100644 --- a/lib/poise_application_python/resources/celery_config.rb +++ b/lib/poise_application_python/resources/celery_config.rb @@ -53,6 +53,14 @@ class Resource < Chef::Resource actions(:deploy) attribute('', template: true, default_source: 'celeryconfig.py.erb') + # @!attribute group + # Owner for the Django application, defaults to application group. + # @return [String] + attribute(:group, kind_of: String, default: lazy { parent && parent.group }) + # @!attribute owner + # Owner for the Django application, defaults to application owner. + # @return [String] + attribute(:owner, kind_of: String, default: lazy { parent && parent.owner }) attribute(:path, kind_of: String, default: lazy { default_path }) private @@ -90,8 +98,8 @@ def write_config file new_resource.path do content new_resource.content mode '640' - owner new_resource.parent.owner if new_resource.parent - group new_resource.parent.group if new_resource.parent + owner new_resource.owner + group new_resource.group end end diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index add4b91..e950deb 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -94,6 +94,10 @@ class Resource < Chef::Resource # If you use this in production you will get everything you deserve. # @return [Boolean] attribute(:debug, equal_to: [true, false], default: false) + # @!attribute group + # Owner for the Django application, defaults to application group. + # @return [String] + attribute(:group, kind_of: String, default: lazy { parent && parent.group }) # @!attribute local_settings # Template content attribute for the contents of local_settings.py. # @todo Redo this doc to cover the actual attributes created. @@ -116,6 +120,10 @@ class Resource < Chef::Resource # to {#path}. # @return [String] attribute(:manage_path, kind_of: String, default: lazy { default_manage_path }) + # @!attribute owner + # Owner for the Django application, defaults to application owner. + # @return [String] + attribute(:owner, kind_of: String, default: lazy { parent && parent.owner }) # @!attribute secret_key # Value for `SECRET_KEY` in the Django settings. If unset, no key is # added to the local settings. diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 285f26e..889e7ef 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'halite', '~> 1.0' spec.add_dependency 'poise', '~> 2.0' - spec.add_dependency 'poise-application', '~> 5.1.pre' + spec.add_dependency 'poise-application', '~> 5.0' spec.add_dependency 'poise-python', '~> 1.0' spec.add_dependency 'poise-service', '~> 1.0' From e92018817c3b811e864e196032770d0194847ca0 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 5 Oct 2015 12:31:17 -0700 Subject: [PATCH 077/113] Bump version for release. --- lib/poise_application_python/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/version.rb b/lib/poise_application_python/version.rb index 30313a8..bb2748c 100644 --- a/lib/poise_application_python/version.rb +++ b/lib/poise_application_python/version.rb @@ -15,5 +15,5 @@ # module PoiseApplicationPython - VERSION = '4.0.0.pre' + VERSION = '4.0.0' end From c9d0d1292a6a08dde18a9b6c47d755253ef50639 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 5 Oct 2015 12:31:55 -0700 Subject: [PATCH 078/113] Bump version for dev. --- lib/poise_application_python/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/version.rb b/lib/poise_application_python/version.rb index bb2748c..efb9fd3 100644 --- a/lib/poise_application_python/version.rb +++ b/lib/poise_application_python/version.rb @@ -15,5 +15,5 @@ # module PoiseApplicationPython - VERSION = '4.0.0' + VERSION = '4.0.1.pre' end From da19155c51679a5146c702940237718b3fdde6d0 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 14 Jan 2016 19:23:30 -0800 Subject: [PATCH 079/113] Support defaulting the new properties on pip_requirements to app properties. --- .../resources/pip_requirements.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/poise_application_python/resources/pip_requirements.rb b/lib/poise_application_python/resources/pip_requirements.rb index 192a687..fe8314c 100644 --- a/lib/poise_application_python/resources/pip_requirements.rb +++ b/lib/poise_application_python/resources/pip_requirements.rb @@ -41,6 +41,16 @@ class Resource < PoisePython::Resources::PipRequirements::Resource subclass_providers! # @todo This should handle relative paths against parent.path. + + # #!attribute group + # Override the default group to be the app group if unspecified. + # @return [String, Integer] + attribute(:group, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.group }) + + # #!attribute user + # Override the default user to be the app owner if unspecified. + # @return [String, Integer] + attribute(:user, kind_of: [String, Integer, NilClass], default: lazy { parent && parent.owner }) end end end From 360b43b363e651892e95d7d7a67a99e57c30271f Mon Sep 17 00:00:00 2001 From: Jeff Blaine Date: Tue, 26 Jan 2016 16:54:18 -0500 Subject: [PATCH 080/113] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b9340e..f6df191 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ end * `preload_app` – Enable code preloading. *(default: false)* * `port` – Port to listen on. Alias for `bind("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)* +* `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)* From 105b8400d5db9ea4e76e00afb7b696729dfd2a61 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 28 Jan 2016 18:01:02 -0800 Subject: [PATCH 081/113] Upgrade test harness. --- .kitchen.travis.yml | 9 --------- .kitchen.yml | 9 +-------- .travis.yml | 7 ++++++- Berksfile | 10 ---------- Gemfile | 3 ++- README.md | 2 +- poise-application-python.gemspec | 3 ++- .../attributes/default.rb | 0 .../metadata.rb | 0 .../recipes/default.rb | 2 ++ .../recipes/django.rb | 0 .../recipes/flask.rb | 0 test/gemfiles/chef-12.1.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.2.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.3.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.4.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.5.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.6.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.gemfile | 2 +- 19 files changed, 129 insertions(+), 32 deletions(-) delete mode 100644 .kitchen.travis.yml rename test/{cookbooks/application_python_test => cookbook}/attributes/default.rb (100%) rename test/{cookbooks/application_python_test => cookbook}/metadata.rb (100%) rename test/{cookbooks/application_python_test => cookbook}/recipes/default.rb (97%) rename test/{cookbooks/application_python_test => cookbook}/recipes/django.rb (100%) rename test/{cookbooks/application_python_test => cookbook}/recipes/flask.rb (100%) create mode 100644 test/gemfiles/chef-12.1.gemfile create mode 100644 test/gemfiles/chef-12.2.gemfile create mode 100644 test/gemfiles/chef-12.3.gemfile create mode 100644 test/gemfiles/chef-12.4.gemfile create mode 100644 test/gemfiles/chef-12.5.gemfile create mode 100644 test/gemfiles/chef-12.6.gemfile diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml deleted file mode 100644 index 53d18c2..0000000 --- a/.kitchen.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -driver: - name: docker - binary: "./docker" - socket: tcp://docker.poise.io:443 - tls_verify: true - tls_cacert: test/docker/docker.ca - tls_cert: test/docker/docker.pem - tls_key: test/docker/docker.key diff --git a/.kitchen.yml b/.kitchen.yml index 50dc9dd..919aef4 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,10 +1,3 @@ --- #<% require 'poise_boiler' %> -<%= PoiseBoiler.kitchen(platforms: 'linux') %> - -suites: -- name: default - run_list: - - recipe[application_python_test] - - recipe[application_python_test::django] - - recipe[application_python_test::flask] +<%= PoiseBoiler.kitchen %> diff --git a/.travis.yml b/.travis.yml index 8b64321..5610976 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,16 @@ addons: env: global: - USE_SYSTEM_GECODE=true - - KITCHEN_LOCAL_YAML=.kitchen.travis.yml - secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U= bundler_args: "--binstubs=$PWD/bin --jobs 3 --retry 3" script: - "./bin/rake travis" gemfile: - test/gemfiles/chef-12.gemfile +- test/gemfiles/chef-12.1.gemfile +- test/gemfiles/chef-12.2.gemfile +- test/gemfiles/chef-12.3.gemfile +- test/gemfiles/chef-12.4.gemfile +- test/gemfiles/chef-12.5.gemfile +- test/gemfiles/chef-12.6.gemfile - test/gemfiles/master.gemfile diff --git a/Berksfile b/Berksfile index c9c4042..769a41d 100644 --- a/Berksfile +++ b/Berksfile @@ -19,17 +19,7 @@ source 'https://supermarket.chef.io/' extension 'halite' -# Force the rebuild every time for development. -cookbook 'poise', gem: 'poise' -cookbook 'application', gem: 'poise-application' -cookbook 'application_python', gem: 'poise-application-python' -cookbook 'poise-languages', gem: 'poise-languages' -cookbook 'poise-python', gem: 'poise-python' -cookbook 'poise-service', gem: 'poise-service' - group :test do cookbook 'application_git', gem: 'poise-application-git' - cookbook 'application_python_test', path: 'test/cookbooks/application_python_test' - cookbook 'apt' cookbook 'git' end diff --git a/Gemfile b/Gemfile index 0d699f0..32b5da1 100644 --- a/Gemfile +++ b/Gemfile @@ -29,9 +29,10 @@ end dev_gem 'halite' dev_gem 'poise' -dev_gem 'poise-application', path: '../application', github: 'poise/application' +dev_gem 'poise-application', path: '../application' dev_gem 'poise-application-git', path: '../application_git' dev_gem 'poise-boiler' dev_gem 'poise-languages' +dev_gem 'poise-profiler' dev_gem 'poise-python' dev_gem 'poise-service' diff --git a/README.md b/README.md index f6df191..6753109 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ end ## Requirements -Chef 12 or newer is required. +Chef 12.1 or newer is required. ## Resources diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 889e7ef..1e81971 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -40,6 +40,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'poise-python', '~> 1.0' spec.add_dependency 'poise-service', '~> 1.0' - spec.add_development_dependency 'poise-boiler', '~> 1.0' + spec.add_development_dependency 'berkshelf', '~> 4.0' + spec.add_development_dependency 'poise-boiler', '~> 1.6' spec.add_development_dependency 'poise-application-git', '~> 1.0' end diff --git a/test/cookbooks/application_python_test/attributes/default.rb b/test/cookbook/attributes/default.rb similarity index 100% rename from test/cookbooks/application_python_test/attributes/default.rb rename to test/cookbook/attributes/default.rb diff --git a/test/cookbooks/application_python_test/metadata.rb b/test/cookbook/metadata.rb similarity index 100% rename from test/cookbooks/application_python_test/metadata.rb rename to test/cookbook/metadata.rb diff --git a/test/cookbooks/application_python_test/recipes/default.rb b/test/cookbook/recipes/default.rb similarity index 97% rename from test/cookbooks/application_python_test/recipes/default.rb rename to test/cookbook/recipes/default.rb index 3b718f5..e6e2595 100644 --- a/test/cookbooks/application_python_test/recipes/default.rb +++ b/test/cookbook/recipes/default.rb @@ -81,3 +81,5 @@ def application(environ, start_response): end end +include_recipe '::django' +include_recipe '::flask' diff --git a/test/cookbooks/application_python_test/recipes/django.rb b/test/cookbook/recipes/django.rb similarity index 100% rename from test/cookbooks/application_python_test/recipes/django.rb rename to test/cookbook/recipes/django.rb diff --git a/test/cookbooks/application_python_test/recipes/flask.rb b/test/cookbook/recipes/flask.rb similarity index 100% rename from test/cookbooks/application_python_test/recipes/flask.rb rename to test/cookbook/recipes/flask.rb diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile new file mode 100644 index 0000000..e9f154f --- /dev/null +++ b/test/gemfiles/chef-12.1.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.1.2' diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile new file mode 100644 index 0000000..91c5d1b --- /dev/null +++ b/test/gemfiles/chef-12.2.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.2.1' diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile new file mode 100644 index 0000000..75bc24a --- /dev/null +++ b/test/gemfiles/chef-12.3.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.3.0' diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile new file mode 100644 index 0000000..dd90427 --- /dev/null +++ b/test/gemfiles/chef-12.4.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.4.3' diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile new file mode 100644 index 0000000..5aa6378 --- /dev/null +++ b/test/gemfiles/chef-12.5.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.5.1' diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile new file mode 100644 index 0000000..c25288e --- /dev/null +++ b/test/gemfiles/chef-12.6.gemfile @@ -0,0 +1,19 @@ +# +# 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.6.0' diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile index 65b686b..6b7e2ff 100644 --- a/test/gemfiles/chef-12.gemfile +++ b/test/gemfiles/chef-12.gemfile @@ -16,4 +16,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', '~> 12.0' +gem 'chef', '~> 12.6' From 7f529037189f5fdfb17a6e939358023560bd3b2f Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 28 Jan 2016 18:02:47 -0800 Subject: [PATCH 082/113] Update copyright years. --- Berksfile | 2 +- Gemfile | 2 +- README.md | 2 +- Rakefile | 2 +- lib/poise_application_python.rb | 2 +- lib/poise_application_python/app_mixin.rb | 2 +- lib/poise_application_python/cheftie.rb | 2 +- lib/poise_application_python/error.rb | 2 +- lib/poise_application_python/resources.rb | 2 +- lib/poise_application_python/resources/celery_beat.rb | 2 +- lib/poise_application_python/resources/celery_config.rb | 2 +- lib/poise_application_python/resources/celery_worker.rb | 2 +- lib/poise_application_python/resources/django.rb | 4 ++-- lib/poise_application_python/resources/gunicorn.rb | 2 +- lib/poise_application_python/resources/pip_requirements.rb | 2 +- lib/poise_application_python/resources/python.rb | 2 +- lib/poise_application_python/resources/python_execute.rb | 2 +- lib/poise_application_python/resources/python_package.rb | 2 +- lib/poise_application_python/resources/virtualenv.rb | 2 +- lib/poise_application_python/service_mixin.rb | 2 +- lib/poise_application_python/version.rb | 2 +- poise-application-python.gemspec | 2 +- test/cookbook/attributes/default.rb | 2 +- test/cookbook/metadata.rb | 2 +- test/cookbook/recipes/default.rb | 2 +- test/cookbook/recipes/django.rb | 2 +- test/cookbook/recipes/flask.rb | 2 +- test/gemfiles/chef-12.1.gemfile | 2 +- test/gemfiles/chef-12.2.gemfile | 2 +- test/gemfiles/chef-12.3.gemfile | 2 +- test/gemfiles/chef-12.4.gemfile | 2 +- test/gemfiles/chef-12.5.gemfile | 2 +- test/gemfiles/chef-12.6.gemfile | 2 +- test/gemfiles/chef-12.gemfile | 2 +- test/gemfiles/master.gemfile | 2 +- test/integration/default/serverspec/default_spec.rb | 2 +- test/integration/default/serverspec/django_spec.rb | 2 +- test/integration/default/serverspec/flask_spec.rb | 2 +- test/spec/app_mixin_spec.rb | 2 +- test/spec/resources/celery_config_spec.rb | 2 +- test/spec/resources/django_spec.rb | 2 +- test/spec/resources/gunicorn_spec.rb | 2 +- test/spec/resources/python_execute_spec.rb | 2 +- test/spec/resources/python_spec.rb | 2 +- test/spec/resources/virtualenv_spec.rb | 2 +- test/spec/spec_helper.rb | 2 +- 46 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Berksfile b/Berksfile index 769a41d..5b70b2d 100644 --- a/Berksfile +++ b/Berksfile @@ -1,7 +1,7 @@ # # Author:: Noah Kantrowitz # -# Copyright 2013, Balanced, Inc. +# Copyright 2013-2016, Balanced, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/Gemfile b/Gemfile index 32b5da1..25e422c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 6753109..eed6cbe 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,7 @@ The Poise test server infrastructure is sponsored by [Rackspace](https://rackspa ## License -Copyright 2015, Noah Kantrowitz +Copyright 2015-2016, Noah Kantrowitz Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Rakefile b/Rakefile index bc878ed..8e19409 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python.rb b/lib/poise_application_python.rb index 9428658..b0c9f8c 100644 --- a/lib/poise_application_python.rb +++ b/lib/poise_application_python.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb index 6b39e1f..b5c4d74 100644 --- a/lib/poise_application_python/app_mixin.rb +++ b/lib/poise_application_python/app_mixin.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/cheftie.rb b/lib/poise_application_python/cheftie.rb index 8d47201..ed8a0ad 100644 --- a/lib/poise_application_python/cheftie.rb +++ b/lib/poise_application_python/cheftie.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/error.rb b/lib/poise_application_python/error.rb index 10fdc61..187831f 100644 --- a/lib/poise_application_python/error.rb +++ b/lib/poise_application_python/error.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index 7504c82..9d69155 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/celery_beat.rb b/lib/poise_application_python/resources/celery_beat.rb index 3085c62..03700f7 100644 --- a/lib/poise_application_python/resources/celery_beat.rb +++ b/lib/poise_application_python/resources/celery_beat.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/celery_config.rb b/lib/poise_application_python/resources/celery_config.rb index a8680e0..77bd3d7 100644 --- a/lib/poise_application_python/resources/celery_config.rb +++ b/lib/poise_application_python/resources/celery_config.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/celery_worker.rb b/lib/poise_application_python/resources/celery_worker.rb index e73c46f..2bb6513 100644 --- a/lib/poise_application_python/resources/celery_worker.rb +++ b/lib/poise_application_python/resources/celery_worker.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index e950deb..91b9c7c 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ module Resources # @since 4.0.0 module Django # Aliases for Django database engine names. Based on https://github.com/kennethreitz/dj-database-url/blob/master/dj_database_url.py - # Copyright 2014, Kenneth Reitz. + # Copyright 2014-2016, Kenneth Reitz. ENGINE_ALIASES = { 'postgres' => 'django.db.backends.postgresql_psycopg2', 'postgresql' => 'django.db.backends.postgresql_psycopg2', diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 8e2aecb..ece8198 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/pip_requirements.rb b/lib/poise_application_python/resources/pip_requirements.rb index fe8314c..e01dba8 100644 --- a/lib/poise_application_python/resources/pip_requirements.rb +++ b/lib/poise_application_python/resources/pip_requirements.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/python.rb b/lib/poise_application_python/resources/python.rb index 2c40d58..22ee945 100644 --- a/lib/poise_application_python/resources/python.rb +++ b/lib/poise_application_python/resources/python.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/python_execute.rb b/lib/poise_application_python/resources/python_execute.rb index 43275b0..b24f074 100644 --- a/lib/poise_application_python/resources/python_execute.rb +++ b/lib/poise_application_python/resources/python_execute.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/python_package.rb b/lib/poise_application_python/resources/python_package.rb index 7936a25..e3604bb 100644 --- a/lib/poise_application_python/resources/python_package.rb +++ b/lib/poise_application_python/resources/python_package.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb index 442d74c..fba83b7 100644 --- a/lib/poise_application_python/resources/virtualenv.rb +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/service_mixin.rb b/lib/poise_application_python/service_mixin.rb index 7d50b9a..d21d18b 100644 --- a/lib/poise_application_python/service_mixin.rb +++ b/lib/poise_application_python/service_mixin.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/version.rb b/lib/poise_application_python/version.rb index efb9fd3..80d8e5b 100644 --- a/lib/poise_application_python/version.rb +++ b/lib/poise_application_python/version.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 1e81971..b0e9d19 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/attributes/default.rb b/test/cookbook/attributes/default.rb index 39ae375..4e6ae40 100644 --- a/test/cookbook/attributes/default.rb +++ b/test/cookbook/attributes/default.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/metadata.rb b/test/cookbook/metadata.rb index 2b26afc..9658053 100644 --- a/test/cookbook/metadata.rb +++ b/test/cookbook/metadata.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/recipes/default.rb b/test/cookbook/recipes/default.rb index e6e2595..a54694c 100644 --- a/test/cookbook/recipes/default.rb +++ b/test/cookbook/recipes/default.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index 8141ec6..4d15589 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/recipes/flask.rb b/test/cookbook/recipes/flask.rb index 17bbd6c..868dad8 100644 --- a/test/cookbook/recipes/flask.rb +++ b/test/cookbook/recipes/flask.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index e9f154f..d06524e 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index 91c5d1b..7b7ce03 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index 75bc24a..b670201 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index dd90427..1be9814 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index 5aa6378..09ec87d 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index c25288e..b220e23 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile index 6b7e2ff..b27748e 100644 --- a/test/gemfiles/chef-12.gemfile +++ b/test/gemfiles/chef-12.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 204b033..b7c7de7 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 09a6785..bea8ab0 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/integration/default/serverspec/django_spec.rb b/test/integration/default/serverspec/django_spec.rb index 11af75a..c054c3a 100644 --- a/test/integration/default/serverspec/django_spec.rb +++ b/test/integration/default/serverspec/django_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/integration/default/serverspec/flask_spec.rb b/test/integration/default/serverspec/flask_spec.rb index a2bf4d8..45f8e82 100644 --- a/test/integration/default/serverspec/flask_spec.rb +++ b/test/integration/default/serverspec/flask_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/app_mixin_spec.rb b/test/spec/app_mixin_spec.rb index 9fa3116..ae4e96f 100644 --- a/test/spec/app_mixin_spec.rb +++ b/test/spec/app_mixin_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/celery_config_spec.rb b/test/spec/resources/celery_config_spec.rb index 561cdc7..8c5ae3f 100644 --- a/test/spec/resources/celery_config_spec.rb +++ b/test/spec/resources/celery_config_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index 159eb57..65a712e 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index e6d0590..0ba6cb9 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/python_execute_spec.rb b/test/spec/resources/python_execute_spec.rb index cec088c..0803339 100644 --- a/test/spec/resources/python_execute_spec.rb +++ b/test/spec/resources/python_execute_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/python_spec.rb b/test/spec/resources/python_spec.rb index 9312adf..cb819cd 100644 --- a/test/spec/resources/python_spec.rb +++ b/test/spec/resources/python_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/virtualenv_spec.rb b/test/spec/resources/virtualenv_spec.rb index f0102e7..e007509 100644 --- a/test/spec/resources/virtualenv_spec.rb +++ b/test/spec/resources/virtualenv_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb index 582e987..3e9a0bf 100644 --- a/test/spec/spec_helper.rb +++ b/test/spec/spec_helper.rb @@ -1,5 +1,5 @@ # -# Copyright 2015, Noah Kantrowitz +# Copyright 2015-2016, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From d595bea0d1cf35cdbc00c424ba70a25e72fedd34 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 28 Jan 2016 18:05:09 -0800 Subject: [PATCH 083/113] Update master build gemfile. --- test/gemfiles/master.gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index b7c7de7..a284541 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -19,9 +19,10 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', github: 'chef/chef' gem 'halite', github: 'poise/halite' gem 'poise', github: 'poise/poise' -# gem 'poise-application', github: 'poise/application' +gem 'poise-application', github: 'poise/application' gem 'poise-application-git', github: 'poise/application_git' gem 'poise-boiler', github: 'poise/poise-boiler' gem 'poise-languages', github: 'poise/poise-languages' +gem 'poise-profiler', github: 'poise/poise-profiler' gem 'poise-python', github: 'poise/poise-python' gem 'poise-service', github: 'poise/poise-service' From 98225d5a1d526518bb54702531f14b3ff27c6ae6 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 5 Feb 2016 13:05:05 -0800 Subject: [PATCH 084/113] Pin Ridley for now. --- test/gemfiles/chef-12.4.gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index 1be9814..2f1f66c 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -17,3 +17,5 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.4.3' +# Pending https://github.com/berkshelf/ridley/pull/335 +gem 'ridley', '4.4.1' From c884400368a676ee3296b7ca55e745bcf1bf501d Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 4 Mar 2016 14:27:42 -0800 Subject: [PATCH 085/113] Upgrade bundler for Chef compat --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5610976..eb6566e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: global: - USE_SYSTEM_GECODE=true - secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U= +before_install: "gem install bundler" bundler_args: "--binstubs=$PWD/bin --jobs 3 --retry 3" script: - "./bin/rake travis" From b020bf1394273ed6386e9f503bc00d14c49e391d Mon Sep 17 00:00:00 2001 From: Matt Bacchi Date: Thu, 17 Mar 2016 21:14:40 -0400 Subject: [PATCH 086/113] update example Django and Flask links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eed6cbe..fea4500 100644 --- a/README.md +++ b/README.md @@ -308,8 +308,8 @@ All actions and properties are the same as the [`python_virtualenv` resource](ht Some test recipes are available as examples for common application frameworks: -* [Flask](https://github.com/poise/application_python/blob/master/test/cookbooks/application_python_test/recipes/flask.rb) -* [Django](https://github.com/poise/application_python/blob/master/test/cookbooks/application_python_test/recipes/django.rb) +* [Flask](https://github.com/poise/application_python/blob/master/test/cookbook/recipes/flask.rb) +* [Django](https://github.com/poise/application_python/blob/master/test/cookbook/recipes/django.rb) ## Sponsors From 4d75f9048e8bc43c3b01beb4717b7dfd25010044 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 5 Jul 2016 13:50:19 -0700 Subject: [PATCH 087/113] Update Ruby version on Travis. See https://github.com/travis-ci/travis-rubies/issues/19 for details --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eb6566e..c0cc6d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: false cache: bundler language: ruby rvm: -- '2.2' +- 2.3.1 addons: apt: packages: From 359c323cd4f2287e489317f98586995499a3cd69 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 7 Nov 2016 15:48:21 -0500 Subject: [PATCH 088/113] Update docstring. [ci skip] --- lib/poise_application_python/resources/gunicorn.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index ece8198..8f51724 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -50,7 +50,7 @@ def port(val) # Compute the default application module to pass to gunicorn. This # checks the app state and then looks for commonly used filenames. - # Raises an exception if no default can be found. + # Returns nil if no default can be found. # # @return [String] def default_app_module From f885a25cc8137ad4e70a149b76f06b07ed610b8e Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 7 Nov 2016 15:50:29 -0500 Subject: [PATCH 089/113] Update testing harness. --- .travis.yml | 65 ++++++++++++++++++++++---------- poise-application-python.gemspec | 1 + test/gemfiles/chef-12.1.gemfile | 3 ++ test/gemfiles/chef-12.10.gemfile | 22 +++++++++++ test/gemfiles/chef-12.11.gemfile | 22 +++++++++++ test/gemfiles/chef-12.12.gemfile | 21 +++++++++++ test/gemfiles/chef-12.13.gemfile | 21 +++++++++++ test/gemfiles/chef-12.14.gemfile | 19 ++++++++++ test/gemfiles/chef-12.15.gemfile | 19 ++++++++++ test/gemfiles/chef-12.2.gemfile | 3 ++ test/gemfiles/chef-12.3.gemfile | 3 ++ test/gemfiles/chef-12.4.gemfile | 4 +- test/gemfiles/chef-12.5.gemfile | 3 ++ test/gemfiles/chef-12.6.gemfile | 3 ++ test/gemfiles/chef-12.7.gemfile | 22 +++++++++++ test/gemfiles/chef-12.8.gemfile | 22 +++++++++++ test/gemfiles/chef-12.9.gemfile | 22 +++++++++++ test/gemfiles/chef-12.gemfile | 2 +- 18 files changed, 255 insertions(+), 22 deletions(-) create mode 100644 test/gemfiles/chef-12.10.gemfile create mode 100644 test/gemfiles/chef-12.11.gemfile create mode 100644 test/gemfiles/chef-12.12.gemfile create mode 100644 test/gemfiles/chef-12.13.gemfile create mode 100644 test/gemfiles/chef-12.14.gemfile create mode 100644 test/gemfiles/chef-12.15.gemfile create mode 100644 test/gemfiles/chef-12.7.gemfile create mode 100644 test/gemfiles/chef-12.8.gemfile create mode 100644 test/gemfiles/chef-12.9.gemfile diff --git a/.travis.yml b/.travis.yml index c0cc6d5..62068d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,51 @@ sudo: false cache: bundler language: ruby -rvm: -- 2.3.1 -addons: - apt: - packages: - - libgecode-dev env: global: - - USE_SYSTEM_GECODE=true - - secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U= -before_install: "gem install bundler" -bundler_args: "--binstubs=$PWD/bin --jobs 3 --retry 3" + - secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U= + - USE_SYSTEM_GECODE=true +before_install: gem install bundler +bundler_args: '--binstubs=$PWD/bin --jobs 3 --retry 3' script: -- "./bin/rake travis" -gemfile: -- test/gemfiles/chef-12.gemfile -- test/gemfiles/chef-12.1.gemfile -- test/gemfiles/chef-12.2.gemfile -- test/gemfiles/chef-12.3.gemfile -- test/gemfiles/chef-12.4.gemfile -- test/gemfiles/chef-12.5.gemfile -- test/gemfiles/chef-12.6.gemfile -- test/gemfiles/master.gemfile + - ./bin/rake travis +matrix: + include: + - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.gemfile + - rvm: 2.1.4 + gemfile: test/gemfiles/chef-12.1.gemfile + - rvm: 2.1.4 + gemfile: test/gemfiles/chef-12.2.gemfile + - rvm: 2.1.4 + gemfile: test/gemfiles/chef-12.3.gemfile + - rvm: 2.1.6 + gemfile: test/gemfiles/chef-12.4.gemfile + - rvm: 2.1.6 + gemfile: test/gemfiles/chef-12.5.gemfile + - rvm: 2.1.6 + gemfile: test/gemfiles/chef-12.6.gemfile + - rvm: 2.1.6 + gemfile: test/gemfiles/chef-12.7.gemfile + - rvm: 2.1.6 + gemfile: test/gemfiles/chef-12.8.gemfile + - rvm: 2.1.8 + gemfile: test/gemfiles/chef-12.9.gemfile + - rvm: 2.1.8 + gemfile: test/gemfiles/chef-12.10.gemfile + - rvm: 2.1.8 + gemfile: test/gemfiles/chef-12.11.gemfile + - rvm: 2.1.8 + gemfile: test/gemfiles/chef-12.12.gemfile + - rvm: 2.1.9 + gemfile: test/gemfiles/chef-12.13.gemfile + - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.14.gemfile + - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.15.gemfile + - rvm: 2.3.1 + gemfile: test/gemfiles/master.gemfile +addons: + apt: + packages: + - libgecode-dev diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index b0e9d19..6e70cf0 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -34,6 +34,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = %w{lib} + spec.add_dependency 'chef', '~> 12.1' spec.add_dependency 'halite', '~> 1.0' spec.add_dependency 'poise', '~> 2.0' spec.add_dependency 'poise-application', '~> 5.0' diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index d06524e..46d9d2c 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -17,3 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.1.2' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.10.gemfile b/test/gemfiles/chef-12.10.gemfile new file mode 100644 index 0000000..44c9ef6 --- /dev/null +++ b/test/gemfiles/chef-12.10.gemfile @@ -0,0 +1,22 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.10.24' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.11.gemfile b/test/gemfiles/chef-12.11.gemfile new file mode 100644 index 0000000..8e39522 --- /dev/null +++ b/test/gemfiles/chef-12.11.gemfile @@ -0,0 +1,22 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.11.18' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.12.gemfile b/test/gemfiles/chef-12.12.gemfile new file mode 100644 index 0000000..d11f0e3 --- /dev/null +++ b/test/gemfiles/chef-12.12.gemfile @@ -0,0 +1,21 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.12.15' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.13.gemfile b/test/gemfiles/chef-12.13.gemfile new file mode 100644 index 0000000..5334cda --- /dev/null +++ b/test/gemfiles/chef-12.13.gemfile @@ -0,0 +1,21 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.13.37' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.14.gemfile b/test/gemfiles/chef-12.14.gemfile new file mode 100644 index 0000000..85816f7 --- /dev/null +++ b/test/gemfiles/chef-12.14.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.14.89' diff --git a/test/gemfiles/chef-12.15.gemfile b/test/gemfiles/chef-12.15.gemfile new file mode 100644 index 0000000..7bea12d --- /dev/null +++ b/test/gemfiles/chef-12.15.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.15.19' diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index 7b7ce03..1701010 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -17,3 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.2.1' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index b670201..595db0d 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -17,3 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.3.0' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index 2f1f66c..ab2643b 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -17,5 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.4.3' -# Pending https://github.com/berkshelf/ridley/pull/335 +gem 'rack', '< 2' gem 'ridley', '4.4.1' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index 09ec87d..bb14884 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -17,3 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.5.1' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index b220e23..7eb8bbc 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -17,3 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.6.0' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.7.gemfile b/test/gemfiles/chef-12.7.gemfile new file mode 100644 index 0000000..0ad2264 --- /dev/null +++ b/test/gemfiles/chef-12.7.gemfile @@ -0,0 +1,22 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.7.2' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.8.gemfile b/test/gemfiles/chef-12.8.gemfile new file mode 100644 index 0000000..7d4e86f --- /dev/null +++ b/test/gemfiles/chef-12.8.gemfile @@ -0,0 +1,22 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.8.1' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.9.gemfile b/test/gemfiles/chef-12.9.gemfile new file mode 100644 index 0000000..23d7769 --- /dev/null +++ b/test/gemfiles/chef-12.9.gemfile @@ -0,0 +1,22 @@ +# +# Copyright 2016, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.9.41' +gem 'rack', '< 2' +gem 'foodcritic', '< 8' +gem 'fauxhai', '<= 3.9.0' diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile index b27748e..325c822 100644 --- a/test/gemfiles/chef-12.gemfile +++ b/test/gemfiles/chef-12.gemfile @@ -16,4 +16,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', '~> 12.6' +gem 'chef', '~> 12.15' From 204018f28bae634ea622d59f5d552d536dcf9780 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 9 Nov 2016 21:06:30 -0500 Subject: [PATCH 090/113] Use poise-python from master for now. --- Gemfile | 2 +- test/gemfiles/master.gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 25e422c..0ab5ee3 100644 --- a/Gemfile +++ b/Gemfile @@ -34,5 +34,5 @@ dev_gem 'poise-application-git', path: '../application_git' dev_gem 'poise-boiler' dev_gem 'poise-languages' dev_gem 'poise-profiler' -dev_gem 'poise-python' +dev_gem 'poise-python', github: 'poise/poise-python' dev_gem 'poise-service' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index a284541..72ae8d3 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -24,5 +24,5 @@ gem 'poise-application-git', github: 'poise/application_git' gem 'poise-boiler', github: 'poise/poise-boiler' gem 'poise-languages', github: 'poise/poise-languages' gem 'poise-profiler', github: 'poise/poise-profiler' -gem 'poise-python', github: 'poise/poise-python' +# gem 'poise-python', github: 'poise/poise-python' gem 'poise-service', github: 'poise/poise-service' From a7b30f6414e2e8c09d9f5dde058d7bed79801079 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 9 Nov 2016 21:06:57 -0500 Subject: [PATCH 091/113] Make pypy3 work again by switching to the 3.3 compat alpha, which works with pip 9. --- test/cookbook/recipes/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index 4d15589..49e4a41 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -19,7 +19,7 @@ application '/opt/test_django' do git 'https://github.com/poise/test_django.git' - python 'pypy3' + python 'pypy3-5.5' virtualenv pip_requirements django do From d0532329096692e7cae41797d919f6570acb53b5 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Fri, 18 Nov 2016 15:15:22 -0500 Subject: [PATCH 092/113] Update test harness. --- test/gemfiles/chef-12.4.gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index ab2643b..d7a2c2c 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -18,6 +18,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.4.3' gem 'rack', '< 2' -gem 'ridley', '4.4.1' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'ridley', '4.4.1' +gem 'gh', '0.14.0' From 30bed64eff40cf10414df3001b2e0f2faece3032 Mon Sep 17 00:00:00 2001 From: Farshid Ghods Date: Thu, 22 Dec 2016 13:23:28 -0800 Subject: [PATCH 093/113] allow the user to pass worker_pool to the celery_worker worker_pool can not be set in the celery configuration and it needs to be set via -P option while starting the worker i added it to the celery_worker.rb ref: http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-worker_pool --- lib/poise_application_python/resources/celery_worker.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/celery_worker.rb b/lib/poise_application_python/resources/celery_worker.rb index 2bb6513..0306da2 100644 --- a/lib/poise_application_python/resources/celery_worker.rb +++ b/lib/poise_application_python/resources/celery_worker.rb @@ -29,6 +29,7 @@ class Resource < Chef::Resource include PoiseApplicationPython::ServiceMixin provides(:application_celery_worker) + attribute(:worker_pool, kind_of: [String, NilClass], default: "prefork") attribute(:app_module, kind_of: [String, NilClass], default: lazy { default_app_module }) private @@ -68,7 +69,7 @@ class Provider < Chef::Provider def service_options(resource) super raise PoiseApplicationPython::Error.new("Unable to determine app module for #{new_resource}") unless new_resource.app_module - resource.command("#{new_resource.python} -m celery --app=#{new_resource.app_module} worker") + resource.command("#{new_resource.python} -m celery --app=#{new_resource.app_module} -P #{new_resource.worker_pool} worker") end end From 7bd0c9a97e1dbf0c6ff173239d741879d0a84105 Mon Sep 17 00:00:00 2001 From: Farshid Ghods Date: Thu, 22 Dec 2016 13:32:50 -0800 Subject: [PATCH 094/113] updated the README file to reflect changes made to celery_worker --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fea4500..1b563bc 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ end * `path` – Base path for the application. *(name attribute)* * `app_module` – Celery application module. *(default: auto-detect)* +* `worker_pool` – The Pool implementation used by the Celery worker (gevent,eventlet or prefork). *(default: prefork)* * `service_name` – Name of the service to create. *(default: auto-detect)* # `user` – User to run the service as. *(default: application owner)* From 43e3ac18d7000ce795753c6797e1afbda05cd10a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 1 Jan 2017 14:05:27 -0800 Subject: [PATCH 095/113] Update test harness. --- .travis.yml | 4 ++++ test/gemfiles/chef-12.1.gemfile | 2 ++ test/gemfiles/chef-12.10.gemfile | 2 ++ test/gemfiles/chef-12.11.gemfile | 2 ++ test/gemfiles/chef-12.12.gemfile | 2 ++ test/gemfiles/chef-12.13.gemfile | 2 ++ test/gemfiles/chef-12.16.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.17.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.2.gemfile | 2 ++ test/gemfiles/chef-12.3.gemfile | 2 ++ test/gemfiles/chef-12.4.gemfile | 4 +++- test/gemfiles/chef-12.5.gemfile | 2 ++ test/gemfiles/chef-12.6.gemfile | 2 ++ test/gemfiles/chef-12.7.gemfile | 2 ++ test/gemfiles/chef-12.8.gemfile | 2 ++ test/gemfiles/chef-12.9.gemfile | 2 ++ test/gemfiles/chef-12.gemfile | 2 +- 17 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 test/gemfiles/chef-12.16.gemfile create mode 100644 test/gemfiles/chef-12.17.gemfile diff --git a/.travis.yml b/.travis.yml index 62068d3..dba0b5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,10 @@ matrix: gemfile: test/gemfiles/chef-12.14.gemfile - rvm: 2.3.1 gemfile: test/gemfiles/chef-12.15.gemfile + - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.16.gemfile + - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.17.gemfile - rvm: 2.3.1 gemfile: test/gemfiles/master.gemfile addons: diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index 46d9d2c..943d54f 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.1.2' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.10.gemfile b/test/gemfiles/chef-12.10.gemfile index 44c9ef6..38fe1ae 100644 --- a/test/gemfiles/chef-12.10.gemfile +++ b/test/gemfiles/chef-12.10.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.10.24' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.11.gemfile b/test/gemfiles/chef-12.11.gemfile index 8e39522..f854da7 100644 --- a/test/gemfiles/chef-12.11.gemfile +++ b/test/gemfiles/chef-12.11.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.11.18' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.12.gemfile b/test/gemfiles/chef-12.12.gemfile index d11f0e3..8502fd1 100644 --- a/test/gemfiles/chef-12.12.gemfile +++ b/test/gemfiles/chef-12.12.gemfile @@ -19,3 +19,5 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.12.15' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.13.gemfile b/test/gemfiles/chef-12.13.gemfile index 5334cda..780276b 100644 --- a/test/gemfiles/chef-12.13.gemfile +++ b/test/gemfiles/chef-12.13.gemfile @@ -19,3 +19,5 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.13.37' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.16.gemfile b/test/gemfiles/chef-12.16.gemfile new file mode 100644 index 0000000..601a96c --- /dev/null +++ b/test/gemfiles/chef-12.16.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.16.42' diff --git a/test/gemfiles/chef-12.17.gemfile b/test/gemfiles/chef-12.17.gemfile new file mode 100644 index 0000000..2b2dbab --- /dev/null +++ b/test/gemfiles/chef-12.17.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.17.44' diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index 1701010..8fc6b63 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.2.1' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index 595db0d..6b8b3c7 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.3.0' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index d7a2c2c..d3f8bf5 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -20,5 +20,7 @@ gem 'chef', '~> 12.4.3' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'ridley', '4.4.1' gem 'gh', '0.14.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' +gem 'ridley', '4.4.1' diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index bb14884..5027835 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.5.1' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index 7eb8bbc..9b8d2c6 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.6.0' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.7.gemfile b/test/gemfiles/chef-12.7.gemfile index 0ad2264..a1b4716 100644 --- a/test/gemfiles/chef-12.7.gemfile +++ b/test/gemfiles/chef-12.7.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.7.2' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.8.gemfile b/test/gemfiles/chef-12.8.gemfile index 7d4e86f..5bda051 100644 --- a/test/gemfiles/chef-12.8.gemfile +++ b/test/gemfiles/chef-12.8.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.8.1' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.9.gemfile b/test/gemfiles/chef-12.9.gemfile index 23d7769..c30fe2a 100644 --- a/test/gemfiles/chef-12.9.gemfile +++ b/test/gemfiles/chef-12.9.gemfile @@ -20,3 +20,5 @@ gem 'chef', '~> 12.9.41' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'nio4r', '< 2' +gem 'buff-extensions', '< 2' diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile index 325c822..8327c89 100644 --- a/test/gemfiles/chef-12.gemfile +++ b/test/gemfiles/chef-12.gemfile @@ -16,4 +16,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', '~> 12.15' +gem 'chef', '~> 12.17' From 6928ba83699835f418b187a024d51b592f763486 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 1 Jan 2017 14:06:20 -0800 Subject: [PATCH 096/113] Update copyright years. --- Berksfile | 2 +- Gemfile | 2 +- README.md | 2 +- Rakefile | 2 +- lib/poise_application_python.rb | 2 +- lib/poise_application_python/app_mixin.rb | 2 +- lib/poise_application_python/cheftie.rb | 2 +- lib/poise_application_python/error.rb | 2 +- lib/poise_application_python/resources.rb | 2 +- lib/poise_application_python/resources/celery_beat.rb | 2 +- lib/poise_application_python/resources/celery_config.rb | 2 +- lib/poise_application_python/resources/celery_worker.rb | 2 +- lib/poise_application_python/resources/django.rb | 4 ++-- lib/poise_application_python/resources/gunicorn.rb | 2 +- lib/poise_application_python/resources/pip_requirements.rb | 2 +- lib/poise_application_python/resources/python.rb | 2 +- lib/poise_application_python/resources/python_execute.rb | 2 +- lib/poise_application_python/resources/python_package.rb | 2 +- lib/poise_application_python/resources/virtualenv.rb | 2 +- lib/poise_application_python/service_mixin.rb | 2 +- lib/poise_application_python/version.rb | 2 +- poise-application-python.gemspec | 2 +- test/cookbook/attributes/default.rb | 2 +- test/cookbook/metadata.rb | 2 +- test/cookbook/recipes/default.rb | 2 +- test/cookbook/recipes/django.rb | 2 +- test/cookbook/recipes/flask.rb | 2 +- test/gemfiles/chef-12.1.gemfile | 2 +- test/gemfiles/chef-12.10.gemfile | 2 +- test/gemfiles/chef-12.11.gemfile | 2 +- test/gemfiles/chef-12.12.gemfile | 2 +- test/gemfiles/chef-12.13.gemfile | 2 +- test/gemfiles/chef-12.14.gemfile | 2 +- test/gemfiles/chef-12.15.gemfile | 2 +- test/gemfiles/chef-12.2.gemfile | 2 +- test/gemfiles/chef-12.3.gemfile | 2 +- test/gemfiles/chef-12.4.gemfile | 2 +- test/gemfiles/chef-12.5.gemfile | 2 +- test/gemfiles/chef-12.6.gemfile | 2 +- test/gemfiles/chef-12.7.gemfile | 2 +- test/gemfiles/chef-12.8.gemfile | 2 +- test/gemfiles/chef-12.9.gemfile | 2 +- test/gemfiles/chef-12.gemfile | 2 +- test/gemfiles/master.gemfile | 2 +- test/integration/default/serverspec/default_spec.rb | 2 +- test/integration/default/serverspec/django_spec.rb | 2 +- test/integration/default/serverspec/flask_spec.rb | 2 +- test/spec/app_mixin_spec.rb | 2 +- test/spec/resources/celery_config_spec.rb | 2 +- test/spec/resources/django_spec.rb | 2 +- test/spec/resources/gunicorn_spec.rb | 2 +- test/spec/resources/python_execute_spec.rb | 2 +- test/spec/resources/python_spec.rb | 2 +- test/spec/resources/virtualenv_spec.rb | 2 +- test/spec/spec_helper.rb | 2 +- 55 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Berksfile b/Berksfile index 5b70b2d..77ce3d7 100644 --- a/Berksfile +++ b/Berksfile @@ -1,7 +1,7 @@ # # Author:: Noah Kantrowitz # -# Copyright 2013-2016, Balanced, Inc. +# Copyright 2013-2017, Balanced, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/Gemfile b/Gemfile index 0ab5ee3..5a2b613 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index fea4500..e20f1a0 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,7 @@ The Poise test server infrastructure is sponsored by [Rackspace](https://rackspa ## License -Copyright 2015-2016, Noah Kantrowitz +Copyright 2015-2017, Noah Kantrowitz Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Rakefile b/Rakefile index 8e19409..d2b12d0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python.rb b/lib/poise_application_python.rb index b0c9f8c..028595f 100644 --- a/lib/poise_application_python.rb +++ b/lib/poise_application_python.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/app_mixin.rb b/lib/poise_application_python/app_mixin.rb index b5c4d74..048ce6e 100644 --- a/lib/poise_application_python/app_mixin.rb +++ b/lib/poise_application_python/app_mixin.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/cheftie.rb b/lib/poise_application_python/cheftie.rb index ed8a0ad..ad04a51 100644 --- a/lib/poise_application_python/cheftie.rb +++ b/lib/poise_application_python/cheftie.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/error.rb b/lib/poise_application_python/error.rb index 187831f..dfdacd0 100644 --- a/lib/poise_application_python/error.rb +++ b/lib/poise_application_python/error.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources.rb b/lib/poise_application_python/resources.rb index 9d69155..a7b8fa3 100644 --- a/lib/poise_application_python/resources.rb +++ b/lib/poise_application_python/resources.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/celery_beat.rb b/lib/poise_application_python/resources/celery_beat.rb index 03700f7..e5664ca 100644 --- a/lib/poise_application_python/resources/celery_beat.rb +++ b/lib/poise_application_python/resources/celery_beat.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/celery_config.rb b/lib/poise_application_python/resources/celery_config.rb index 77bd3d7..f4a835e 100644 --- a/lib/poise_application_python/resources/celery_config.rb +++ b/lib/poise_application_python/resources/celery_config.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/celery_worker.rb b/lib/poise_application_python/resources/celery_worker.rb index 2bb6513..cd0fd2d 100644 --- a/lib/poise_application_python/resources/celery_worker.rb +++ b/lib/poise_application_python/resources/celery_worker.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index 91b9c7c..dbe044c 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ module Resources # @since 4.0.0 module Django # Aliases for Django database engine names. Based on https://github.com/kennethreitz/dj-database-url/blob/master/dj_database_url.py - # Copyright 2014-2016, Kenneth Reitz. + # Copyright 2014-2017, Kenneth Reitz. ENGINE_ALIASES = { 'postgres' => 'django.db.backends.postgresql_psycopg2', 'postgresql' => 'django.db.backends.postgresql_psycopg2', diff --git a/lib/poise_application_python/resources/gunicorn.rb b/lib/poise_application_python/resources/gunicorn.rb index 8f51724..e9daed3 100644 --- a/lib/poise_application_python/resources/gunicorn.rb +++ b/lib/poise_application_python/resources/gunicorn.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/pip_requirements.rb b/lib/poise_application_python/resources/pip_requirements.rb index e01dba8..8c236d8 100644 --- a/lib/poise_application_python/resources/pip_requirements.rb +++ b/lib/poise_application_python/resources/pip_requirements.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/python.rb b/lib/poise_application_python/resources/python.rb index 22ee945..021bec0 100644 --- a/lib/poise_application_python/resources/python.rb +++ b/lib/poise_application_python/resources/python.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/python_execute.rb b/lib/poise_application_python/resources/python_execute.rb index b24f074..646a117 100644 --- a/lib/poise_application_python/resources/python_execute.rb +++ b/lib/poise_application_python/resources/python_execute.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/python_package.rb b/lib/poise_application_python/resources/python_package.rb index e3604bb..54ec9ee 100644 --- a/lib/poise_application_python/resources/python_package.rb +++ b/lib/poise_application_python/resources/python_package.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/resources/virtualenv.rb b/lib/poise_application_python/resources/virtualenv.rb index fba83b7..3bec6fa 100644 --- a/lib/poise_application_python/resources/virtualenv.rb +++ b/lib/poise_application_python/resources/virtualenv.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/service_mixin.rb b/lib/poise_application_python/service_mixin.rb index d21d18b..2c52420 100644 --- a/lib/poise_application_python/service_mixin.rb +++ b/lib/poise_application_python/service_mixin.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/poise_application_python/version.rb b/lib/poise_application_python/version.rb index 80d8e5b..50af440 100644 --- a/lib/poise_application_python/version.rb +++ b/lib/poise_application_python/version.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 6e70cf0..9cd2efd 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/attributes/default.rb b/test/cookbook/attributes/default.rb index 4e6ae40..56cb0d7 100644 --- a/test/cookbook/attributes/default.rb +++ b/test/cookbook/attributes/default.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/metadata.rb b/test/cookbook/metadata.rb index 9658053..b5ba1a2 100644 --- a/test/cookbook/metadata.rb +++ b/test/cookbook/metadata.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/recipes/default.rb b/test/cookbook/recipes/default.rb index a54694c..e1db35e 100644 --- a/test/cookbook/recipes/default.rb +++ b/test/cookbook/recipes/default.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index 49e4a41..b6c2f3f 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/cookbook/recipes/flask.rb b/test/cookbook/recipes/flask.rb index 868dad8..59d98f2 100644 --- a/test/cookbook/recipes/flask.rb +++ b/test/cookbook/recipes/flask.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index 943d54f..f82c240 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.10.gemfile b/test/gemfiles/chef-12.10.gemfile index 38fe1ae..5e0b86d 100644 --- a/test/gemfiles/chef-12.10.gemfile +++ b/test/gemfiles/chef-12.10.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.11.gemfile b/test/gemfiles/chef-12.11.gemfile index f854da7..4cd4519 100644 --- a/test/gemfiles/chef-12.11.gemfile +++ b/test/gemfiles/chef-12.11.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.12.gemfile b/test/gemfiles/chef-12.12.gemfile index 8502fd1..4e89d53 100644 --- a/test/gemfiles/chef-12.12.gemfile +++ b/test/gemfiles/chef-12.12.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.13.gemfile b/test/gemfiles/chef-12.13.gemfile index 780276b..192cedc 100644 --- a/test/gemfiles/chef-12.13.gemfile +++ b/test/gemfiles/chef-12.13.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.14.gemfile b/test/gemfiles/chef-12.14.gemfile index 85816f7..e0cb5c1 100644 --- a/test/gemfiles/chef-12.14.gemfile +++ b/test/gemfiles/chef-12.14.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.15.gemfile b/test/gemfiles/chef-12.15.gemfile index 7bea12d..1095dd8 100644 --- a/test/gemfiles/chef-12.15.gemfile +++ b/test/gemfiles/chef-12.15.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index 8fc6b63..e69d777 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index 6b8b3c7..e99f51e 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index d3f8bf5..d742275 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index 5027835..83a8175 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index 9b8d2c6..5aae4fe 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.7.gemfile b/test/gemfiles/chef-12.7.gemfile index a1b4716..87dc205 100644 --- a/test/gemfiles/chef-12.7.gemfile +++ b/test/gemfiles/chef-12.7.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.8.gemfile b/test/gemfiles/chef-12.8.gemfile index 5bda051..34468bd 100644 --- a/test/gemfiles/chef-12.8.gemfile +++ b/test/gemfiles/chef-12.8.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.9.gemfile b/test/gemfiles/chef-12.9.gemfile index c30fe2a..d98a12f 100644 --- a/test/gemfiles/chef-12.9.gemfile +++ b/test/gemfiles/chef-12.9.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2016, Noah Kantrowitz +# Copyright 2016-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile index 8327c89..a9effa0 100644 --- a/test/gemfiles/chef-12.gemfile +++ b/test/gemfiles/chef-12.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 72ae8d3..1821fd7 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index bea8ab0..7d56643 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/integration/default/serverspec/django_spec.rb b/test/integration/default/serverspec/django_spec.rb index c054c3a..b9d8380 100644 --- a/test/integration/default/serverspec/django_spec.rb +++ b/test/integration/default/serverspec/django_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/integration/default/serverspec/flask_spec.rb b/test/integration/default/serverspec/flask_spec.rb index 45f8e82..8c0d0f2 100644 --- a/test/integration/default/serverspec/flask_spec.rb +++ b/test/integration/default/serverspec/flask_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/app_mixin_spec.rb b/test/spec/app_mixin_spec.rb index ae4e96f..2e34119 100644 --- a/test/spec/app_mixin_spec.rb +++ b/test/spec/app_mixin_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/celery_config_spec.rb b/test/spec/resources/celery_config_spec.rb index 8c5ae3f..846c221 100644 --- a/test/spec/resources/celery_config_spec.rb +++ b/test/spec/resources/celery_config_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/django_spec.rb b/test/spec/resources/django_spec.rb index 65a712e..dccbd3c 100644 --- a/test/spec/resources/django_spec.rb +++ b/test/spec/resources/django_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index 0ba6cb9..77661e5 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/python_execute_spec.rb b/test/spec/resources/python_execute_spec.rb index 0803339..7b64852 100644 --- a/test/spec/resources/python_execute_spec.rb +++ b/test/spec/resources/python_execute_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/python_spec.rb b/test/spec/resources/python_spec.rb index cb819cd..6e5ff3c 100644 --- a/test/spec/resources/python_spec.rb +++ b/test/spec/resources/python_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/resources/virtualenv_spec.rb b/test/spec/resources/virtualenv_spec.rb index e007509..082d2e7 100644 --- a/test/spec/resources/virtualenv_spec.rb +++ b/test/spec/resources/virtualenv_spec.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb index 3e9a0bf..2ed212f 100644 --- a/test/spec/spec_helper.rb +++ b/test/spec/spec_helper.rb @@ -1,5 +1,5 @@ # -# Copyright 2015-2016, Noah Kantrowitz +# Copyright 2015-2017, Noah Kantrowitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 376340155701cf23b6856e99e377d9f58c6b08e2 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 2 Mar 2017 15:16:44 -0800 Subject: [PATCH 097/113] Chef 13 compat. --- poise-application-python.gemspec | 2 +- test/gemfiles/master.gemfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 9cd2efd..49d4f24 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = %w{lib} - spec.add_dependency 'chef', '~> 12.1' + spec.add_dependency 'chef', '>= 12.1', '< 14' spec.add_dependency 'halite', '~> 1.0' spec.add_dependency 'poise', '~> 2.0' spec.add_dependency 'poise-application', '~> 5.0' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 1821fd7..7f04ac5 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -18,6 +18,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', github: 'chef/chef' gem 'halite', github: 'poise/halite' +gem 'ohai', github: 'chef/ohai' gem 'poise', github: 'poise/poise' gem 'poise-application', github: 'poise/application' gem 'poise-application-git', github: 'poise/application_git' From 0ea12f7b5d900dcd83b7ae28c10e5935af70bf5e Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 11 Apr 2017 21:38:15 -0700 Subject: [PATCH 098/113] Use poise-build-essential. --- Berksfile | 25 ------------------------- poise-application-python.gemspec | 4 ++-- test/cookbook/metadata.rb | 2 +- test/cookbook/recipes/django.rb | 2 +- 4 files changed, 4 insertions(+), 29 deletions(-) delete mode 100644 Berksfile diff --git a/Berksfile b/Berksfile deleted file mode 100644 index 77ce3d7..0000000 --- a/Berksfile +++ /dev/null @@ -1,25 +0,0 @@ -# -# Author:: Noah Kantrowitz -# -# Copyright 2013-2017, Balanced, Inc. -# -# 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. -# - -source 'https://supermarket.chef.io/' -extension 'halite' - -group :test do - cookbook 'application_git', gem: 'poise-application-git' - cookbook 'git' -end diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index 49d4f24..ce606f1 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'poise-python', '~> 1.0' spec.add_dependency 'poise-service', '~> 1.0' - spec.add_development_dependency 'berkshelf', '~> 4.0' spec.add_development_dependency 'poise-boiler', '~> 1.6' - spec.add_development_dependency 'poise-application-git', '~> 1.0' + spec.add_development_dependency 'poise-application-git', '~> 1.2' + spec.add_development_dependency 'poise-build-essential', '~> 1.0' end diff --git a/test/cookbook/metadata.rb b/test/cookbook/metadata.rb index b5ba1a2..149dbeb 100644 --- a/test/cookbook/metadata.rb +++ b/test/cookbook/metadata.rb @@ -17,4 +17,4 @@ name 'application_python_test' depends 'application_git' depends 'application_python' -depends 'build-essential' +depends 'poise-build-essential' diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index b6c2f3f..6e5a59e 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -14,7 +14,7 @@ # limitations under the License. # -include_recipe 'build-essential' +include_recipe 'poise-build-essential' include_recipe 'poise-python' application '/opt/test_django' do From e2ee3f49c443b4f42e0b4e687925d7d1774e029b Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 11 Apr 2017 21:38:55 -0700 Subject: [PATCH 099/113] Use poise-python release. --- Gemfile | 3 ++- test/gemfiles/master.gemfile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 5a2b613..60c6dcd 100644 --- a/Gemfile +++ b/Gemfile @@ -31,8 +31,9 @@ dev_gem 'halite' dev_gem 'poise' dev_gem 'poise-application', path: '../application' dev_gem 'poise-application-git', path: '../application_git' +dev_gem 'poise-archive' dev_gem 'poise-boiler' dev_gem 'poise-languages' dev_gem 'poise-profiler' -dev_gem 'poise-python', github: 'poise/poise-python' +dev_gem 'poise-python' dev_gem 'poise-service' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 7f04ac5..b756fde 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -22,8 +22,9 @@ gem 'ohai', github: 'chef/ohai' gem 'poise', github: 'poise/poise' gem 'poise-application', github: 'poise/application' gem 'poise-application-git', github: 'poise/application_git' +gem 'poise-archive', github: 'poise/poise-archive' gem 'poise-boiler', github: 'poise/poise-boiler' gem 'poise-languages', github: 'poise/poise-languages' gem 'poise-profiler', github: 'poise/poise-profiler' -# gem 'poise-python', github: 'poise/poise-python' +gem 'poise-python', github: 'poise/poise-python' gem 'poise-service', github: 'poise/poise-service' From b57748488cf79d8e78e0aa2446ffffe4fac8361a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 11 Apr 2017 21:40:32 -0700 Subject: [PATCH 100/113] Update test harness. --- .travis.yml | 23 ++++++++++++++++------- test/gemfiles/chef-12.1.gemfile | 3 +-- test/gemfiles/chef-12.10.gemfile | 3 +-- test/gemfiles/chef-12.11.gemfile | 3 +-- test/gemfiles/chef-12.12.gemfile | 3 +-- test/gemfiles/chef-12.13.gemfile | 3 +-- test/gemfiles/chef-12.18.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.19.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-12.2.gemfile | 3 +-- test/gemfiles/chef-12.3.gemfile | 3 +-- test/gemfiles/chef-12.4.gemfile | 4 +--- test/gemfiles/chef-12.5.gemfile | 3 +-- test/gemfiles/chef-12.6.gemfile | 3 +-- test/gemfiles/chef-12.7.gemfile | 3 +-- test/gemfiles/chef-12.8.gemfile | 3 +-- test/gemfiles/chef-12.9.gemfile | 3 +-- test/gemfiles/chef-12.gemfile | 2 +- test/gemfiles/chef-13.0.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-13.gemfile | 19 +++++++++++++++++++ 19 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 test/gemfiles/chef-12.18.gemfile create mode 100644 test/gemfiles/chef-12.19.gemfile create mode 100644 test/gemfiles/chef-13.0.gemfile create mode 100644 test/gemfiles/chef-13.gemfile diff --git a/.travis.yml b/.travis.yml index dba0b5c..d3670b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,15 +4,22 @@ language: ruby env: global: - secure: rz8Ej7Zx5zArH+OwuAsRB8CH0rZVKIAm6nhB29wg73d7FrMv6cWEl5/B2uQqlefqZ1GYosAifhmoW7lVB1S2O9pDPB8wSpr2P9dsaHEupad4jBi6rIufxoCrx3YZIFPcmvL71u2+STi021VQpsXjcwfP6h2i+pVkPXxVr0Ihv3U= - - USE_SYSTEM_GECODE=true -before_install: gem install bundler -bundler_args: '--binstubs=$PWD/bin --jobs 3 --retry 3' +before_install: + - 'if [[ $BUNDLE_GEMFILE == *master.gemfile ]]; then gem update --system; fi' + - gem --version + - gem install bundler + - bundle --version + - 'bundle config --local path ${BUNDLE_PATH:-$(dirname $BUNDLE_GEMFILE)/vendor/bundle}' + - bundle config --local bin $PWD/bin +install: bundle update --jobs=3 --retry=3 script: - ./bin/rake travis matrix: include: - rvm: 2.3.1 gemfile: test/gemfiles/chef-12.gemfile + - rvm: 2.4.1 + gemfile: test/gemfiles/chef-13.gemfile - rvm: 2.1.4 gemfile: test/gemfiles/chef-12.1.gemfile - rvm: 2.1.4 @@ -48,8 +55,10 @@ matrix: - rvm: 2.3.1 gemfile: test/gemfiles/chef-12.17.gemfile - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.18.gemfile + - rvm: 2.3.1 + gemfile: test/gemfiles/chef-12.19.gemfile + - rvm: 2.4.1 + gemfile: test/gemfiles/chef-13.0.gemfile + - rvm: 2.4.1 gemfile: test/gemfiles/master.gemfile -addons: - apt: - packages: - - libgecode-dev diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index f82c240..c7ace12 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.1.2' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.10.gemfile b/test/gemfiles/chef-12.10.gemfile index 5e0b86d..4e96ed4 100644 --- a/test/gemfiles/chef-12.10.gemfile +++ b/test/gemfiles/chef-12.10.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.10.24' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.11.gemfile b/test/gemfiles/chef-12.11.gemfile index 4cd4519..f6f55c6 100644 --- a/test/gemfiles/chef-12.11.gemfile +++ b/test/gemfiles/chef-12.11.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.11.18' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.12.gemfile b/test/gemfiles/chef-12.12.gemfile index 4e89d53..0b673e4 100644 --- a/test/gemfiles/chef-12.12.gemfile +++ b/test/gemfiles/chef-12.12.gemfile @@ -19,5 +19,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.12.15' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.13.gemfile b/test/gemfiles/chef-12.13.gemfile index 192cedc..9cc50eb 100644 --- a/test/gemfiles/chef-12.13.gemfile +++ b/test/gemfiles/chef-12.13.gemfile @@ -19,5 +19,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.13.37' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.18.gemfile b/test/gemfiles/chef-12.18.gemfile new file mode 100644 index 0000000..eef6f42 --- /dev/null +++ b/test/gemfiles/chef-12.18.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.18.31' diff --git a/test/gemfiles/chef-12.19.gemfile b/test/gemfiles/chef-12.19.gemfile new file mode 100644 index 0000000..62c4b98 --- /dev/null +++ b/test/gemfiles/chef-12.19.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 12.19.36' diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index e69d777..157048b 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.2.1' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index e99f51e..963a1f9 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.3.0' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index d742275..e3a9da2 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -20,7 +20,5 @@ gem 'chef', '~> 12.4.3' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' +gem 'chefspec', '< 6' gem 'gh', '0.14.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' -gem 'ridley', '4.4.1' diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index 83a8175..91a0f0d 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.5.1' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index 5aae4fe..2cf21ed 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.6.0' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.7.gemfile b/test/gemfiles/chef-12.7.gemfile index 87dc205..d9a353c 100644 --- a/test/gemfiles/chef-12.7.gemfile +++ b/test/gemfiles/chef-12.7.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.7.2' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.8.gemfile b/test/gemfiles/chef-12.8.gemfile index 34468bd..16834cd 100644 --- a/test/gemfiles/chef-12.8.gemfile +++ b/test/gemfiles/chef-12.8.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.8.1' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.9.gemfile b/test/gemfiles/chef-12.9.gemfile index d98a12f..7e4aea3 100644 --- a/test/gemfiles/chef-12.9.gemfile +++ b/test/gemfiles/chef-12.9.gemfile @@ -20,5 +20,4 @@ gem 'chef', '~> 12.9.41' gem 'rack', '< 2' gem 'foodcritic', '< 8' gem 'fauxhai', '<= 3.9.0' -gem 'nio4r', '< 2' -gem 'buff-extensions', '< 2' +gem 'chefspec', '< 6' diff --git a/test/gemfiles/chef-12.gemfile b/test/gemfiles/chef-12.gemfile index a9effa0..bd22a0f 100644 --- a/test/gemfiles/chef-12.gemfile +++ b/test/gemfiles/chef-12.gemfile @@ -16,4 +16,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', '~> 12.17' +gem 'chef', '~> 12.19' diff --git a/test/gemfiles/chef-13.0.gemfile b/test/gemfiles/chef-13.0.gemfile new file mode 100644 index 0000000..ff571d0 --- /dev/null +++ b/test/gemfiles/chef-13.0.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 13.0.113' diff --git a/test/gemfiles/chef-13.gemfile b/test/gemfiles/chef-13.gemfile new file mode 100644 index 0000000..f7f40e8 --- /dev/null +++ b/test/gemfiles/chef-13.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 13.0' From 6982fb1d7141def5579ec14c953750ff78dd013a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Wed, 12 Apr 2017 15:42:35 -0700 Subject: [PATCH 101/113] Use newer PyPy. --- test/cookbook/recipes/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index 6e5a59e..fda0cba 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -19,7 +19,7 @@ application '/opt/test_django' do git 'https://github.com/poise/test_django.git' - python 'pypy3-5.5' + python 'pypy3-5.7' virtualenv pip_requirements django do From 1f581cf08a3c855c3516c7ba93ab7b0d0fc588eb Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 13 Apr 2017 00:21:02 -0700 Subject: [PATCH 102/113] Use the new restart_delay option because PyPy can take more than 1 second to shut down. --- Gemfile | 2 +- test/cookbook/recipes/django.rb | 4 ++++ test/gemfiles/master.gemfile | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 60c6dcd..3f42884 100644 --- a/Gemfile +++ b/Gemfile @@ -36,4 +36,4 @@ dev_gem 'poise-boiler' dev_gem 'poise-languages' dev_gem 'poise-profiler' dev_gem 'poise-python' -dev_gem 'poise-service' +dev_gem 'poise-service', github: 'poise/poise-service' diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index fda0cba..9f3b4de 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -29,4 +29,8 @@ gunicorn do port 9000 end + # PyPy is a bit slower to shut down. + poise_service_options '/opt/test_django' do + restart_delay 10 + end end diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index b756fde..fe57d7b 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -27,4 +27,4 @@ gem 'poise-boiler', github: 'poise/poise-boiler' gem 'poise-languages', github: 'poise/poise-languages' gem 'poise-profiler', github: 'poise/poise-profiler' gem 'poise-python', github: 'poise/poise-python' -gem 'poise-service', github: 'poise/poise-service' +# gem 'poise-service', github: 'poise/poise-service' From 0f7df279ee97a1e7284b0ffc8ff88d12052deb90 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 13 Apr 2017 10:50:19 -0700 Subject: [PATCH 103/113] Still seeing restart failures. --- test/cookbook/recipes/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cookbook/recipes/django.rb b/test/cookbook/recipes/django.rb index 9f3b4de..c115174 100644 --- a/test/cookbook/recipes/django.rb +++ b/test/cookbook/recipes/django.rb @@ -31,6 +31,6 @@ end # PyPy is a bit slower to shut down. poise_service_options '/opt/test_django' do - restart_delay 10 + restart_delay 30 end end From c3ea8a072f3dcdd7801b887533949ba335f2b35a Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 13 Apr 2017 17:38:00 -0700 Subject: [PATCH 104/113] Fix tests for Chef 13. --- test/spec/resources/gunicorn_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/resources/gunicorn_spec.rb b/test/spec/resources/gunicorn_spec.rb index 77661e5..c50da3b 100644 --- a/test/spec/resources/gunicorn_spec.rb +++ b/test/spec/resources/gunicorn_spec.rb @@ -21,7 +21,7 @@ describe '#default_app_module' do let(:app_state) { {} } let(:files) { [] } - let(:test_resource) { described_class.new(nil, nil) } + let(:test_resource) { described_class.new('/test', nil) } before do allow(test_resource).to receive(:app_state).and_return(app_state) allow(Dir).to receive(:exist?).and_return(!files.empty?) From 217d3aae891e5e44c52701b097d97f5bb807fe0d Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 23 Apr 2017 21:30:01 -0700 Subject: [PATCH 105/113] Update metadata for latest foodcritic. --- poise-application-python.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poise-application-python.gemspec b/poise-application-python.gemspec index ce606f1..8394013 100644 --- a/poise-application-python.gemspec +++ b/poise-application-python.gemspec @@ -26,8 +26,9 @@ Gem::Specification.new do |spec| spec.description = "A Chef cookbook for deploying Python application code." spec.summary = spec.description spec.homepage = 'https://github.com/poise/application_python' - spec.license = 'Apache 2.0' + spec.license = 'Apache-2.0' spec.metadata['halite_name'] = 'application_python' + spec.metadata['platforms'] = 'any' spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } From 1cd9985d039aa4f2d12ae32b3d7045ac6172c0fd Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 23 Apr 2017 21:30:50 -0700 Subject: [PATCH 106/113] Update test harness. --- .gitignore | 4 ++-- .yardopts | 4 ++++ .yo-rc.json | 7 +++++++ Gemfile | 2 +- test/gemfiles/chef-12.1.gemfile | 6 +++--- test/gemfiles/chef-12.10.gemfile | 6 +++--- test/gemfiles/chef-12.11.gemfile | 6 +++--- test/gemfiles/chef-12.12.gemfile | 4 ++-- test/gemfiles/chef-12.13.gemfile | 4 ++-- test/gemfiles/chef-12.2.gemfile | 6 +++--- test/gemfiles/chef-12.3.gemfile | 6 +++--- test/gemfiles/chef-12.4.gemfile | 6 +++--- test/gemfiles/chef-12.5.gemfile | 6 +++--- test/gemfiles/chef-12.6.gemfile | 6 +++--- test/gemfiles/chef-12.7.gemfile | 6 +++--- test/gemfiles/chef-12.8.gemfile | 6 +++--- test/gemfiles/chef-12.9.gemfile | 6 +++--- test/gemfiles/chef-13.0.gemfile | 2 +- test/gemfiles/master.gemfile | 27 +++++++++++++++------------ 19 files changed, 67 insertions(+), 53 deletions(-) create mode 100644 .yo-rc.json diff --git a/.gitignore b/.gitignore index 38f93b5..d83b2bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ +Berksfile.lock Gemfile.lock test/gemfiles/*.lock -Berksfile.lock .kitchen/ .kitchen.local.yml test/docker/ +test/ec2/ coverage/ pkg/ .yardoc/ doc/ - diff --git a/.yardopts b/.yardopts index 1c11d2a..be7cdef 100644 --- a/.yardopts +++ b/.yardopts @@ -1,3 +1,7 @@ --plugin classmethods +--embed-mixin ClassMethods +--hide-api private --markup markdown --hide-void-return +--tag provides:Provides +--tag action:Actions diff --git a/.yo-rc.json b/.yo-rc.json new file mode 100644 index 0000000..9cb8344 --- /dev/null +++ b/.yo-rc.json @@ -0,0 +1,7 @@ +{ + "generator-poise": { + "created": true, + "name": "poise-application-python", + "cookbookName": "application_python" + } +} \ No newline at end of file diff --git a/Gemfile b/Gemfile index 3f42884..77f0b86 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ def dev_gem(name, path: File.join('..', name), github: nil) if File.exist?(path) gem name, path: path elsif github - gem name, github: github + gem name, git: "https://gitub.com/#{github}.git" end end diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index c7ace12..170e314 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.1.2' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.10.gemfile b/test/gemfiles/chef-12.10.gemfile index 4e96ed4..a98cfc0 100644 --- a/test/gemfiles/chef-12.10.gemfile +++ b/test/gemfiles/chef-12.10.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.10.24' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.11.gemfile b/test/gemfiles/chef-12.11.gemfile index f6f55c6..302cf79 100644 --- a/test/gemfiles/chef-12.11.gemfile +++ b/test/gemfiles/chef-12.11.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.11.18' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.12.gemfile b/test/gemfiles/chef-12.12.gemfile index 0b673e4..4724162 100644 --- a/test/gemfiles/chef-12.12.gemfile +++ b/test/gemfiles/chef-12.12.gemfile @@ -17,6 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.12.15' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' diff --git a/test/gemfiles/chef-12.13.gemfile b/test/gemfiles/chef-12.13.gemfile index 9cc50eb..67e00b8 100644 --- a/test/gemfiles/chef-12.13.gemfile +++ b/test/gemfiles/chef-12.13.gemfile @@ -17,6 +17,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.13.37' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index 157048b..3b3d674 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.2.1' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index 963a1f9..8700b6c 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.3.0' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index e3a9da2..00fc198 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -17,8 +17,8 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.4.3' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' gem 'gh', '0.14.0' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index 91a0f0d..d0c73a4 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.5.1' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index 2cf21ed..fdd4417 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.6.0' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.7.gemfile b/test/gemfiles/chef-12.7.gemfile index d9a353c..9c22595 100644 --- a/test/gemfiles/chef-12.7.gemfile +++ b/test/gemfiles/chef-12.7.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.7.2' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.8.gemfile b/test/gemfiles/chef-12.8.gemfile index 16834cd..2b390eb 100644 --- a/test/gemfiles/chef-12.8.gemfile +++ b/test/gemfiles/chef-12.8.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.8.1' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.9.gemfile b/test/gemfiles/chef-12.9.gemfile index 7e4aea3..b67456e 100644 --- a/test/gemfiles/chef-12.9.gemfile +++ b/test/gemfiles/chef-12.9.gemfile @@ -17,7 +17,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.9.41' -gem 'rack', '< 2' -gem 'foodcritic', '< 8' -gem 'fauxhai', '<= 3.9.0' gem 'chefspec', '< 6' +gem 'fauxhai', '<= 3.9.0' +gem 'foodcritic', '< 8' +gem 'rack', '< 2' diff --git a/test/gemfiles/chef-13.0.gemfile b/test/gemfiles/chef-13.0.gemfile index ff571d0..7e864da 100644 --- a/test/gemfiles/chef-13.0.gemfile +++ b/test/gemfiles/chef-13.0.gemfile @@ -16,4 +16,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', '~> 13.0.113' +gem 'chef', '~> 13.0.118' diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index fe57d7b..4c902cb 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -16,15 +16,18 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', github: 'chef/chef' -gem 'halite', github: 'poise/halite' -gem 'ohai', github: 'chef/ohai' -gem 'poise', github: 'poise/poise' -gem 'poise-application', github: 'poise/application' -gem 'poise-application-git', github: 'poise/application_git' -gem 'poise-archive', github: 'poise/poise-archive' -gem 'poise-boiler', github: 'poise/poise-boiler' -gem 'poise-languages', github: 'poise/poise-languages' -gem 'poise-profiler', github: 'poise/poise-profiler' -gem 'poise-python', github: 'poise/poise-python' -# gem 'poise-service', github: 'poise/poise-service' +gem 'chef', git: 'https://github.com/chef/chef.git' +gem 'chefspec', git: 'https://github.com/sethvargo/chefspec.git' +gem 'fauxhai', git: 'https://github.com/customink/fauxhai.git' +gem 'foodcritic', git: 'https://github.com/foodcritic/foodcritic.git' +gem 'halite', git: 'https://github.com/poise/halite.git' +gem 'ohai', git: 'https://github.com/chef/ohai.git' +gem 'poise', git: 'https://github.com/poise/poise.git' +gem 'poise-application', git: 'https://github.com/poise/poise-application.git' +gem 'poise-application-git', git: 'https://github.com/poise/poise-application-git.git' +gem 'poise-archive', git: 'https://github.com/poise/poise-archive.git' +gem 'poise-boiler', git: 'https://github.com/poise/poise-boiler.git' +gem 'poise-languages', git: 'https://github.com/poise/poise-languages.git' +gem 'poise-profiler', git: 'https://github.com/poise/poise-profiler.git' +gem 'poise-python', git: 'https://github.com/poise/poise-python.git' +gem 'poise-service', git: 'https://github.com/poise/poise-service.git' From 78bd6ef34dfc054fdd2125beb5dc9b489d10493e Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 24 Apr 2017 00:26:50 -0700 Subject: [PATCH 107/113] Typo (and de-master). --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 77f0b86..200b1cb 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ def dev_gem(name, path: File.join('..', name), github: nil) if File.exist?(path) gem name, path: path elsif github - gem name, git: "https://gitub.com/#{github}.git" + gem name, git: "https://github.com/#{github}.git" end end @@ -36,4 +36,4 @@ dev_gem 'poise-boiler' dev_gem 'poise-languages' dev_gem 'poise-profiler' dev_gem 'poise-python' -dev_gem 'poise-service', github: 'poise/poise-service' +dev_gem 'poise-service' From 443a480edbf4ddc729e468a3791ee16cf5d85e68 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Mon, 24 Apr 2017 14:24:38 -0700 Subject: [PATCH 108/113] Fix git URLs. --- test/gemfiles/master.gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/gemfiles/master.gemfile b/test/gemfiles/master.gemfile index 4c902cb..182ae64 100644 --- a/test/gemfiles/master.gemfile +++ b/test/gemfiles/master.gemfile @@ -23,8 +23,8 @@ gem 'foodcritic', git: 'https://github.com/foodcritic/foodcritic.git' gem 'halite', git: 'https://github.com/poise/halite.git' gem 'ohai', git: 'https://github.com/chef/ohai.git' gem 'poise', git: 'https://github.com/poise/poise.git' -gem 'poise-application', git: 'https://github.com/poise/poise-application.git' -gem 'poise-application-git', git: 'https://github.com/poise/poise-application-git.git' +gem 'poise-application', git: 'https://github.com/poise/application.git' +gem 'poise-application-git', git: 'https://github.com/poise/application_git.git' gem 'poise-archive', git: 'https://github.com/poise/poise-archive.git' gem 'poise-boiler', git: 'https://github.com/poise/poise-boiler.git' gem 'poise-languages', git: 'https://github.com/poise/poise-languages.git' From 2b122c09ae5a1d5f947ecfb64deb050d618e6e49 Mon Sep 17 00:00:00 2001 From: Martin Cozzi Date: Thu, 11 May 2017 15:03:00 -0700 Subject: [PATCH 109/113] Use ?nil when checking for integer. Fixes #81 --- lib/poise_application_python/resources/django.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/poise_application_python/resources/django.rb b/lib/poise_application_python/resources/django.rb index dbe044c..61dd5d7 100644 --- a/lib/poise_application_python/resources/django.rb +++ b/lib/poise_application_python/resources/django.rb @@ -232,7 +232,7 @@ def parse_database_url(url) db[:USER] = parsed.user if parsed.user && !parsed.user.empty? db[:PASSWORD] = parsed.password if parsed.password && !parsed.password.empty? db[:HOST] = parsed.host if parsed.host && !parsed.host.empty? - db[:PORT] = parsed.port if parsed.port && !parsed.port.empty? + db[:PORT] = parsed.port if parsed.port && !parsed.port.nil? end end From f8965f07e318166622e0e8e22797364b3e7c28eb Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 30 Jul 2017 16:46:00 -0700 Subject: [PATCH 110/113] Fix tests on Chef master for new execute provider implementation. --- test/spec/resources/python_execute_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/spec/resources/python_execute_spec.rb b/test/spec/resources/python_execute_spec.rb index 7b64852..29107f8 100644 --- a/test/spec/resources/python_execute_spec.rb +++ b/test/spec/resources/python_execute_spec.rb @@ -30,7 +30,13 @@ end it do - expect_any_instance_of(described_class::Provider).to receive(:shell_out!).with( + # Check which method to stub. I'm not super proud of this code, sorry. + method_to_stub = if IO.read(described_class::Provider.instance_method(:action_run).source_location.first) =~ /shell_out_with_systems_locale/ + :shell_out_with_systems_locale! + else + :shell_out! + end + expect_any_instance_of(described_class::Provider).to receive(method_to_stub).with( '/python myapp.py', user: 'myuser', group: 'mygroup', From e3d75f59ca3b6bc9a0e0e81a290aa0a3819096e0 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Sun, 13 Aug 2017 23:42:05 -0700 Subject: [PATCH 111/113] Update test harness. --- .travis.yml | 4 ++++ test/gemfiles/chef-12.1.gemfile | 1 + test/gemfiles/chef-12.10.gemfile | 1 + test/gemfiles/chef-12.11.gemfile | 1 + test/gemfiles/chef-12.12.gemfile | 1 + test/gemfiles/chef-12.13.gemfile | 1 + test/gemfiles/chef-12.2.gemfile | 1 + test/gemfiles/chef-12.3.gemfile | 1 + test/gemfiles/chef-12.4.gemfile | 1 + test/gemfiles/chef-12.5.gemfile | 1 + test/gemfiles/chef-12.6.gemfile | 1 + test/gemfiles/chef-12.7.gemfile | 1 + test/gemfiles/chef-12.8.gemfile | 1 + test/gemfiles/chef-12.9.gemfile | 1 + test/gemfiles/chef-13.1.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-13.2.gemfile | 19 +++++++++++++++++++ test/gemfiles/chef-13.gemfile | 2 +- 17 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 test/gemfiles/chef-13.1.gemfile create mode 100644 test/gemfiles/chef-13.2.gemfile diff --git a/.travis.yml b/.travis.yml index d3670b9..18bf4d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,5 +60,9 @@ matrix: gemfile: test/gemfiles/chef-12.19.gemfile - rvm: 2.4.1 gemfile: test/gemfiles/chef-13.0.gemfile + - rvm: 2.4.1 + gemfile: test/gemfiles/chef-13.1.gemfile + - rvm: 2.4.1 + gemfile: test/gemfiles/chef-13.2.gemfile - rvm: 2.4.1 gemfile: test/gemfiles/master.gemfile diff --git a/test/gemfiles/chef-12.1.gemfile b/test/gemfiles/chef-12.1.gemfile index 170e314..83ee246 100644 --- a/test/gemfiles/chef-12.1.gemfile +++ b/test/gemfiles/chef-12.1.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.1.2' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.10.gemfile b/test/gemfiles/chef-12.10.gemfile index a98cfc0..b3f1bce 100644 --- a/test/gemfiles/chef-12.10.gemfile +++ b/test/gemfiles/chef-12.10.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.10.24' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.11.gemfile b/test/gemfiles/chef-12.11.gemfile index 302cf79..e1a1b77 100644 --- a/test/gemfiles/chef-12.11.gemfile +++ b/test/gemfiles/chef-12.11.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.11.18' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.12.gemfile b/test/gemfiles/chef-12.12.gemfile index 4724162..cdbf048 100644 --- a/test/gemfiles/chef-12.12.gemfile +++ b/test/gemfiles/chef-12.12.gemfile @@ -19,4 +19,5 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.12.15' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' diff --git a/test/gemfiles/chef-12.13.gemfile b/test/gemfiles/chef-12.13.gemfile index 67e00b8..76b2217 100644 --- a/test/gemfiles/chef-12.13.gemfile +++ b/test/gemfiles/chef-12.13.gemfile @@ -19,4 +19,5 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.13.37' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' diff --git a/test/gemfiles/chef-12.2.gemfile b/test/gemfiles/chef-12.2.gemfile index 3b3d674..1be9dc1 100644 --- a/test/gemfiles/chef-12.2.gemfile +++ b/test/gemfiles/chef-12.2.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.2.1' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.3.gemfile b/test/gemfiles/chef-12.3.gemfile index 8700b6c..f467b24 100644 --- a/test/gemfiles/chef-12.3.gemfile +++ b/test/gemfiles/chef-12.3.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.3.0' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.4.gemfile b/test/gemfiles/chef-12.4.gemfile index 00fc198..3982e37 100644 --- a/test/gemfiles/chef-12.4.gemfile +++ b/test/gemfiles/chef-12.4.gemfile @@ -19,6 +19,7 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.4.3' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'gh', '0.14.0' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.5.gemfile b/test/gemfiles/chef-12.5.gemfile index d0c73a4..cce7846 100644 --- a/test/gemfiles/chef-12.5.gemfile +++ b/test/gemfiles/chef-12.5.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.5.1' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.6.gemfile b/test/gemfiles/chef-12.6.gemfile index fdd4417..5f699c5 100644 --- a/test/gemfiles/chef-12.6.gemfile +++ b/test/gemfiles/chef-12.6.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.6.0' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.7.gemfile b/test/gemfiles/chef-12.7.gemfile index 9c22595..8eb0df8 100644 --- a/test/gemfiles/chef-12.7.gemfile +++ b/test/gemfiles/chef-12.7.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.7.2' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.8.gemfile b/test/gemfiles/chef-12.8.gemfile index 2b390eb..cf1531f 100644 --- a/test/gemfiles/chef-12.8.gemfile +++ b/test/gemfiles/chef-12.8.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.8.1' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-12.9.gemfile b/test/gemfiles/chef-12.9.gemfile index b67456e..4295ec5 100644 --- a/test/gemfiles/chef-12.9.gemfile +++ b/test/gemfiles/chef-12.9.gemfile @@ -19,5 +19,6 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) gem 'chef', '~> 12.9.41' gem 'chefspec', '< 6' gem 'fauxhai', '<= 3.9.0' +gem 'ffi-yajl', '< 2.3.1' gem 'foodcritic', '< 8' gem 'rack', '< 2' diff --git a/test/gemfiles/chef-13.1.gemfile b/test/gemfiles/chef-13.1.gemfile new file mode 100644 index 0000000..05668a3 --- /dev/null +++ b/test/gemfiles/chef-13.1.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 13.1.31' diff --git a/test/gemfiles/chef-13.2.gemfile b/test/gemfiles/chef-13.2.gemfile new file mode 100644 index 0000000..a466fdb --- /dev/null +++ b/test/gemfiles/chef-13.2.gemfile @@ -0,0 +1,19 @@ +# +# Copyright 2017, 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. +# + +eval_gemfile File.expand_path('../../../Gemfile', __FILE__) + +gem 'chef', '~> 13.2.20' diff --git a/test/gemfiles/chef-13.gemfile b/test/gemfiles/chef-13.gemfile index f7f40e8..3f49de1 100644 --- a/test/gemfiles/chef-13.gemfile +++ b/test/gemfiles/chef-13.gemfile @@ -16,4 +16,4 @@ eval_gemfile File.expand_path('../../../Gemfile', __FILE__) -gem 'chef', '~> 13.0' +gem 'chef', '~> 13.2' From 518beb3102b039d046b19afb3e8d42c4e143de05 Mon Sep 17 00:00:00 2001 From: Bastien Jove Date: Tue, 9 Oct 2018 14:51:27 +0200 Subject: [PATCH 112/113] Fix Issue #86 with chef 14 --- lib/poise_application_python/resources/python_execute.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/poise_application_python/resources/python_execute.rb b/lib/poise_application_python/resources/python_execute.rb index 646a117..c3f445d 100644 --- a/lib/poise_application_python/resources/python_execute.rb +++ b/lib/poise_application_python/resources/python_execute.rb @@ -40,10 +40,10 @@ class Resource < PoisePython::Resources::PythonExecute::Resource def initialize(*args) super # Clear some instance variables so my defaults work. - remove_instance_variable(:@cwd) - remove_instance_variable(:@group) - remove_instance_variable(:@user) - end + remove_instance_variable(:@cwd) if defined?(@cwd) + remove_instance_variable(:@group) if defined?(@group) + remove_instance_variable(:@user) if defined?(@user) + end # #!attribute cwd # Override the default directory to be the app path if unspecified. From 3bcf11c46251126f2a4d9d2ccc289c91ee4c3c23 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 9 Oct 2018 13:56:14 -0700 Subject: [PATCH 113/113] Fix whitespace --- lib/poise_application_python/resources/python_execute.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/poise_application_python/resources/python_execute.rb b/lib/poise_application_python/resources/python_execute.rb index c3f445d..6b79fdf 100644 --- a/lib/poise_application_python/resources/python_execute.rb +++ b/lib/poise_application_python/resources/python_execute.rb @@ -42,8 +42,8 @@ def initialize(*args) # Clear some instance variables so my defaults work. remove_instance_variable(:@cwd) if defined?(@cwd) remove_instance_variable(:@group) if defined?(@group) - remove_instance_variable(:@user) if defined?(@user) - end + remove_instance_variable(:@user) if defined?(@user) + end # #!attribute cwd # Override the default directory to be the app path if unspecified.