Git Product home page Git Product logo

application's Introduction

Application cookbook

Build Status Gem Version Cookbook Version Coverage Gemnasium License

A Chef cookbook to deploy applications.

Getting Started

The application cookbook provides a central framework to deploy applications using Chef. Generally this will be web applications using things like Rails, Django, or NodeJS, but the framework makes no specific assumptions. The core application resource provides DSL support and helpers, but the heavy lifting is all done in specific plugins detailed below. Each deployment starts with an application resource:

application '/path/to/deploy' do
  owner 'root'
  group 'root'

  # ...
end

The application resource uses the Poise subresource system for plugins. This means you configure the steps of the deployment like normal recipe code inside the application resource, with a few special additions:

application '/path/to/deploy' do
  # Application resource properties.
  owner 'root'
  group 'root'

  # Subresources, like normal recipe code.
  package 'ruby'
  git '/path/to/deploy' do
    repository 'https://github.com/example/myapp.git'
  end
  application_rails '/path/to/deploy' do
    database 'mysql://dbhost/myapp'
  end
end

When evaluating the recipe inside the application resource, it first checks for application_#{resource}, as well as looking for an LWRP of the same name in any cookbook starting with application_. This means that a resource named application_foo can be used as foo inside the application resource:

application '/path/to/deploy' do
  owner 'root'
  group 'root'

  rails '/path/to/deploy' do
    database 'mysql://dbhost/myapp'
  end
end

Additionally if a resource inside the application block doesn't have a name, it uses the same name as the application resource itself:

application '/path/to/deploy' do
  owner 'root'
  group 'root'

  rails do
    database 'mysql://dbhost/myapp'
  end
end

Other than those two special features, the recipe code inside the application resource is processed just like any other recipe.

Available Plugins

  • application_git – Deploy application code from a git repository.
  • application_ruby – Manage Ruby deployments, such as Rails or Sinatra applications.
  • application_python – Manage Python deployments, such as Django or Flask applications.
  • application_javascript – Manage server-side JavaScript deployments using Node.js or io.js.
  • application_javaComing soon!
  • application_goComing soon!
  • application_erlangComing soon!

Requirements

Chef 12 or newer is required.

Resources

application

The application resource has top-level configuration properties for each deployment and acts as a container for other deployment plugin resources.

application '/opt/test_sinatra' do
  git 'https://github.com/example/my_sinatra_app.git'
  bundle_install do
    deployment true
  end
  unicorn do
    port 9000
  end
end

Actions

  • :deploy – Deploy the application. (default)
  • :start - Run :start on all subresources that support it.
  • :stop - Run :stop on all subresources that support it.
  • :restart - Run :restart on all subresources that support it.
  • :reload - Run :reload on all subresources that support it.

Properties

  • path – Path to deploy the application to. (name attribute)
  • environment – Environment variables for all application deployment steps.
  • group – System group to deploy the application as.
  • owner – System user to deploy the application as.
  • action_on_update – Action to run on the application resource when any subresource is updated. (default: restart)
  • action_on_update_immediately – Run the action_on_update notification with :immediately. (default: false)

application_cookbook_file, application_directory, application_file, application_template

The application_cookbook_file, application_directory, application_file, and application_template resources extend the core Chef resources to take some application-level configuration in to account:

application '/opt/myapp' do
  template 'myapp.conf' do
    source 'myapp.conf.erb'
  end
  directory 'logs'
end

If the resource name is a relative path, it will be expanded relative to the application path. If an owner or group is declared for the application, those will be the default user and group for the resource.

All other actions and properties are the same as the similar resource in core Chef.

Examples

Some test recipes are available as examples for common application frameworks:

Upgrading From 4.x

While the overall design of the revamped application resource is similar to the 4.x version, some changes will need to be made. The name property no longer exists, with the name attribute being used as the path to the deployment. The packages property has been removed as this is more easily handled via normal recipe code.

The SCM-related properties like repository and revision are now handled by normal plugins. If you were deploying from a private git repository you will likely want to use the application_git cookbook, otherwise just use the built-in git or svn resources as per normal.

The properties related to the deploy resource like strategy and symlinks have been removed. The deploy resource is no longer used so these aren't relevant. As a side effect of this, you'll likely want to point the upgraded deployment at a new folder or manually clean the current and shared folders from the existing folder. The pseudo-Capistrano layout used by the deploy resource has few benefits in a config-managed world and introduced a lot of complexity and moving pieces that are no longer required.

With the removal of the deploy resource, the callback properties and commands are no longer used as well. Subresources no longer use the complex actions-as-callbacks arrangement as existed before, instead following normal Chef recipe flow. Individual subresources may need to be tweaked to work with newer versions of the cookbooks they come from, though most have stayed similar in overall approach.

Database Migrations and Chef

Several of the web application deployment plugins include optional support to run database migrations from Chef. For "toy" applications where the app and database run together on a single machine, this is fine and is a nice time saver. For anything more complex I highly recommend not running database migrations from Chef. Some initial operations like creating the database and/or database user are more reasonable as they tend to be done only once and by their nature the application does not yet have users so some level of eventual consistency is more acceptable. With migrations on a production application, I encourage using Chef and the application cookbooks to handle deploying the code and writing configuration files, but use something more specific to run the actual migration task. Fabric, Capistrano, and Rundeck are all good choices for this orchestration tooling.

Migrations can generally be applied idempotently but they have unique constraints (pun definitely intended) that make them tricky in a Chef-like, convergence-based system. First and foremost is that many table alterations lock the table for updating for at least some period of time. That can mean that while staging the new code or configuration data can happen within a window, the migration itself needs to be run in careful lockstep with the rest of the deployment process (eg. moving things in and out of load balancers). Beyond that, while most web frameworks have internal idempotence checks for migrations, running the process on two servers at the same time can have unexpected effects.

Overall migrations are best thought of as a procedural step rather than a declaratively modeled piece of the system.

Application Signals and Updates

The application resource exposes start, stop, restart, and reload actions which will dispatch to any subresources attached to the application. This allows for generic application-level restart or reload signals that will work with any type of deployment.

Additionally the action_on_update property is used to set a default notification so any subresource that updates will trigger an application restart or reload. This can be disabled by setting action_on_update false if you want to take manual control of service restarts.

Sponsors

Development sponsored by Chef Software, Symonds & Son, and Orion.

The Poise test server infrastructure is sponsored by Rackspace.

License

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. 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.

application's People

Contributors

albandiguer avatar bfritz avatar bmironenko avatar cap10morgan avatar chrisroberts avatar coderanger avatar eczajk1 avatar erikfrey avatar ezotrank avatar grantr avatar guilhem avatar hungryblank avatar iafonov avatar jcoleman avatar josephholsten avatar jregeimbal avatar jschneiderhan avatar kesor avatar kevinreedy avatar lamont-granquist avatar nathenharvey avatar schisamo avatar sethvargo avatar tojofo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

application's Issues

unable to deploy rails application

Hi,
I have been attempting to setup a chef recipe which installs ruby using bundle_install and then uses the application_ruby cookbook to configure the application.
I have the following error :
NameError : No resource found for bundle install

metadata.rb is missing

Hello,

Since there has not been a release of this cookbook in over a year, we have been using what is in the development git repository since keep_releases is broken in the officially released application cookbook on supermarket.

It seems that in a recent commit, metadata.rb has been removed and is breaking Berkshelf's dependency resolution when pointed at the repo. Can it be replaced, and can we possibly get some new tagged releases out? :)

Guideline request - difference from artifact-cookbook and deploy_revision

I'm trying to find out how this cookbook differs (or overlaps) with the artifact-cookbook and the Chef built in deploy_revision logic.

Can you provide a bit of explanation please?

I want to move towards a managed LWRP setup for deploying packaged code or binary distributions (such as WAR files) and so far I've done all of the work manually (eg copying files around, cleaning up releases myself, updating symlinks myself, etc). I'd like to know how to choose which cookbook to use.

uninitialized error

I keep getting this error and I'm not sure how to fix it.
I'm running on Chef 12.13.37
this is with app

cookbook 'application', '~> 5.2.0'
cookbook 'application_git', '~> 1.2.0'
NameError
---------
uninitialized constant Chef::Provider::ApplicationCookbook
 
Cookbook Trace:
---------------
/var/chef/runs/0cb47e0c-a8f5-468e-ba5f-c83c8784a522/local-mode-cache/cache/cookbooks/application/providers/default.rb:21:in `class_from_file'

14:  # Unless required by applicable law or agreed to in writing, software
15:  # distributed under the License is distributed on an "AS IS" BASIS,
16:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17:  # See the License for the specific language governing permissions and
18:  # limitations under the License.
19:  #
20:  
21>> include ApplicationCookbook::ProviderBase
22:  
23:  action :deploy do
24:  
25:    before_compile
26:  
27:    before_deploy
28:  
29:    run_deploy

NoMethodError: undefined method `to_sym' for nil:NilClass

details TK, but this morning we generated this stacktrace:

Generated at 2017-01-10 12:09:17 -0800
NoMethodError: undefined method `to_sym' for nil:NilClass
Did you mean?  to_s
/var/cache/chef/cookbooks/poise/files/halite_gem/poise/helpers/resource_subclass.rb:38:in `subclass_providers!'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:43:in `<class
:Resource>'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:39:in `<modul
e:ApplicationCookbookFile>'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:24:in `<modul
e:Resources>'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:21:in `<modul
e:PoiseApplication>'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:20:in `<top (
required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources.rb:18:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/var/cache/chef/cookbooks/application/files/halite_gem/poise_application/cheftie.rb:17:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/var/cache/chef/cookbooks/application/libraries/default.rb:19:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:191:in `load'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:191:in `block in load_libraries_from_cookbook'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:188:in `each'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:188:in `load_libraries_from_cookbook'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:99:in `block in compile_libraries'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:98:in `each'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:98:in `compile_libraries'
/usr/lib/ruby/vendor_ruby/chef/run_context/cookbook_compiler.rb:71:in `compile'
/usr/lib/ruby/vendor_ruby/chef/run_context.rb:96:in `load'
/usr/lib/ruby/vendor_ruby/chef/policy_builder/expand_node_object.rb:87:in `setup_run_context'
/usr/lib/ruby/vendor_ruby/chef/client.rb:256:in `setup_run_context'
/usr/lib/ruby/vendor_ruby/chef/client.rb:454:in `run'
/usr/lib/ruby/vendor_ruby/chef/application.rb:271:in `block in fork_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application.rb:259:in `fork'
/usr/lib/ruby/vendor_ruby/chef/application.rb:259:in `fork_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application.rb:225:in `block in run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/local_mode.rb:39:in `with_server_connectivity'
/usr/lib/ruby/vendor_ruby/chef/application.rb:213:in `run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:402:in `block in interval_run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:392:in `loop'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:392:in `interval_run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:382:in `run_application'
/usr/lib/ruby/vendor_ruby/chef/application.rb:60:in `run'
/usr/bin/chef-client:26:in `<main>'
[2017-01-10T12:16:14-08:00] INFO: Forking chef instance to converge...
[2017-01-10T12:16:14-08:00] INFO: *** Chef 12.3.0 ***
[2017-01-10T12:16:14-08:00] INFO: Chef-client pid: 13011
[2017-01-10T12:16:18-08:00] INFO: Run List is [role[tomato]]
[2017-01-10T12:16:18-08:00] INFO: Run List expands to [apt, avahi, chef-client, sudo, poise-python, ntp, postfix, slackmail,
undef-base-cb::users, undef-sensu, undef-sensu::ntp, chef-splunk, undef-base-cb::splunk, undef-sensu::splunk, nginx, undef-ba
se-cb, undef-sensu::master, undef-sensu::rabbitmq, undef-sensu::redis, redisio, redisio::enable]
[2017-01-10T12:16:18-08:00] INFO: Starting Chef Run for tomato
[2017-01-10T12:16:18-08:00] INFO: Running start handlers
[2017-01-10T12:16:18-08:00] INFO: Start handlers complete.
[2017-01-10T12:16:20-08:00] INFO: Loading cookbooks [[email protected], [email protected], [email protected], [email protected], cron
@3.0.0, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], poise
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], ap
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], application_
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
.0, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected].
0, [email protected], [email protected], [email protected], [email protected], [email protected]]

================================================================================
Recipe Compile Error in /var/cache/chef/cookbooks/application/libraries/default.rb
================================================================================

NoMethodError
-------------
undefined method `to_sym' for nil:NilClass
Did you mean?  to_s

Cookbook Trace:
---------------
  /var/cache/chef/cookbooks/poise/files/halite_gem/poise/helpers/resource_subclass.rb:38:in `subclass_providers!'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:43:in `<
class:Resource>'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:39:in `<
module:ApplicationCookbookFile>'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:24:in `<
module:Resources>'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:21:in `<
module:PoiseApplication>'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources/application_cookbook_file.rb:20:in `<
top (required)>'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/resources.rb:18:in `<top (required)>'
  /var/cache/chef/cookbooks/application/files/halite_gem/poise_application/cheftie.rb:17:in `<top (required)>'
  /var/cache/chef/cookbooks/application/libraries/default.rb:19:in `<top (required)>'

Relevant File Content:
----------------------
/var/cache/chef/cookbooks/poise/files/halite_gem/poise/helpers/resource_subclass.rb:

 31:            resource_name ||= self.resource_name
 32:            superclass_resource_name ||= if superclass.respond_to?(:resource_name)
 33:              superclass.resource_name
 34:            elsif superclass.respond_to?(:dsl_name)
 35:              superclass.dsl_name
 36:            else
 37:              raise Poise::Error.new("Unable to determine superclass resource name for #{superclass}. Please specify n
ame manually via subclass_providers!('name').")
 38>>           end.to_sym
 39:            # Deal with the node maps.
 40:            node_maps = {}
 41:            node_maps['handler map'] = Chef.provider_handler_map if defined?(Chef.provider_handler_map)
 42:            node_maps['priority map'] = Chef.provider_priority_map if defined?(Chef.provider_priority_map)
 43:            # Patch anything in the descendants tracker.
 44:            Chef::Provider.descendants.each do |provider|
 45:              node_maps["#{provider} node map"] = provider.node_map if defined?(provider.node_map)
 46:            end if defined?(Chef::Provider.descendants)
 47:            node_maps.each do |map_name, node_map|


[2017-01-10T12:16:20-08:00] ERROR: Running exception handlers
[2017-01-10T12:16:20-08:00] ERROR: Exception handlers complete
[2017-01-10T12:16:20-08:00] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
[2017-01-10T12:16:20-08:00] INFO: Sending resource update report (run-id: c1467eec-7c4c-4d44-a09c-2685816bb1b0)
[2017-01-10T12:16:21-08:00] ERROR: undefined method `to_sym' for nil:NilClass
Did you mean?  to_s
[2017-01-10T12:16:21-08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Deploying app from a subdirectory?

Hello,
Our app is not at the "root" of the code repository, is there a way to handle that with this cookbook?
Currently our application is deployed with

application 'app' do

  path _path
  owner _owner
  group _group
  deploy_key _pkey
  rollback_on_error true

  # repository "[email protected]:code/full.git"
  # revision "master"

  symlinks 'log' => 'log', 'node_modules' => 'node_modules'

  # packages %w( git )
  action :deploy
end

But the code we'd like to deploy is not at the root of github.com:code/full but rather inside a subdirectory called app.

Is there a way to tell this cookbook to only take the content of the subdirectory and put it in path ?

Status of this cookbook/documentation

This cookbook looks comprehensive but is no longer maintained? Or is the documentation not up-to-date? I noticed that many of the examples don't work. For example snippet below does not work. git needs to be path. And bundle_install is not a resource!? unicorn also does not exist!?

application '/opt/test_sinatra' do
  git 'https://github.com/example/my_sinatra_app.git'
  bundle_install do
    deployment true
  end
  unicorn do
    port 9000
  end
end

Cannot deploy nodejs application with error "NoMethodError: undefined method `owner' for Chef::Resource::DeployRevision"

Dear guy,

I cannot deploy a nodejs app with application & application_nodejs cookbook.

My environment :

  1. Chef 11.12.2
  2. Application : 4.1.4
  3. Application_nodejs : 2.0.1
  4. Ubuntu 12.04 LTS

Full error :
"[2014-06-02T10:51:51+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-06-02T10:51:51+00:00] ERROR: Running exception handlers
[2014-06-02T10:51:51+00:00] ERROR: Exception handlers complete
[2014-06-02T10:51:51+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-06-02T10:51:51+00:00] ERROR: deploy_revision[xxxx](/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb line 123) had an error: NoMethodError: undefined method `owner' for Chef::Resource::DeployRevision
[2014-06-02T10:51:51+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)"

Any idea?

Regards,
Phung Le.

Cookbook failing to compile with chef-client 14.5.33

I have this cookbook in my list of dependencies for a run list that is failing with the following message during my chef-client runs:

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/application/libraries/default.rb
================================================================================

FrozenError
-----------
can't modify frozen Array

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/subresources/container.rb:220:in `included'
  /var/chef/cache/cookbooks/poise/files/halite_gem/poise/resource.rb:51:in `include'
  /var/chef/cache/cookbooks/poise/files/halite_gem/poise/resource.rb:51:in `poise_subresource_container'
  /var/chef/cache/cookbooks/poise/files/halite_gem/poise.rb:93:in `block in Poise'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources/application.rb:45:in `include'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources/application.rb:45:in `<class:Resource>'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources/application.rb:44:in `<module:Application>'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources/application.rb:27:in `<module:Resources>'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources/application.rb:24:in `<module:PoiseApplication>'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources/application.rb:23:in `<top (required)>'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/resources.rb:17:in `<top (required)>'
  /var/chef/cache/cookbooks/application/files/halite_gem/poise_application/cheftie.rb:17:in `<top (required)>'
  /var/chef/cache/cookbooks/application/libraries/default.rb:19:in `<top (required)>'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/subresources/container.rb:

213:                @container_default
214:              end
215:            end
216:
217:            def included(klass)
218:              super
219:              klass.extend(ClassMethods)
220>>             klass.const_get(:HIDDEN_IVARS) << :@subcontexts
221:              klass.const_get(:FORBIDDEN_IVARS) << :@subcontexts
222:            end
223:          end
224:
225:          extend ClassMethods
226:        end
227:      end
228:    end
229:  end

Additional information:
-----------------------
      Ruby objects are often frozen to prevent further modifications
      when they would negatively impact the process (e.g. values inside
      Ruby's ENV class) or to prevent polluting other objects when default
      values are passed by reference to many instances of an object (e.g.
      the empty Array as a Chef resource default, passed by reference
      to every instance of the resource).

      Chef uses Object#freeze to ensure the default values of properties
      inside Chef resources are not modified, so that when a new instance
      of a Chef resource is created, and Object#dup copies values by
      reference, the new resource is not receiving a default value that
      has been by a previous instance of that resource.

      Instead of modifying an object that contains a default value for all
      instances of a Chef resource, create a new object and assign it to
      the resource's parameter, e.g.:

      fruit_basket = resource(:fruit_basket, 'default')

      # BAD: modifies 'contents' object for all new fruit_basket instances
      fruit_basket.contents << 'apple'

      # GOOD: allocates new array only owned by this fruit_basket instance
      fruit_basket.contents %w(apple)


System Info:
------------
chef_version=14.5.33
platform=oracle
platform_version=6.10
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/usr/bin/chef-client
executable=/opt/chef/bin/chef-client


Running handlers:
Running handlers complete
Chef Client failed. 0 resources updated in 07 seconds

shallow_clone default causing difficulty with newer versions of git

I experienced the same issue as #49, but it isn't specific to Ubuntu, but is caused by using a newer version of git.

In order to sync a different branch than the one that is checked out I had to set shallow_clone to false before checking it out (on my existing node I deleted cached_copy to ensure that this happened when I ran chef-client).

When shallow_clone is not set to false, it can't sync to a revision that isn't merged to the revision that's checked out (in this case it's master).

On the deploy cookbook, shallow_clone defaults to false. I think it would be easier to use this application cookbook with newer distros if shallow_clone also defaulted to false.

path is not the "name-attribute" anymore

Got this error with latest supermarket version:

    ArgumentError
    -------------
    You must supply a name when declaring a directory resource

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/application/providers/default.rb:75:in `before_deploy'
    /var/chef/cache/cookbooks/application/providers/default.rb:27:in `block in class_from_file

Please update documentation.

fix by setting path attribute explicitly

Git behavior regarding new commits in the production branch

Hi!

I'm trying to find some information about how this cookbook behaves when specifying a git repo. My desired behaviour would be to do an initial checkout when deploying a new server, but not checking out again automatically. I'm afraid of having an automatic, non authorized deploy to production if someone by mistake pushes something to the production branch. Also, if this cookbook deploys automatically, my CI tests will not make much sense.

Can someone explain me how this cookbook behaves in this situation? Thanks!

before_symlink in new version 5.x

According to the README it says that since version 5.x the deploy properties have been removed.
Is there a way to achieve something like before_symlink in 5.x?

I had a few steps running 'before' the application does the final 'symlink' and not quite sure how I could achieve this with the new version.

Incompatibility with Ubuntu 14.04

I have been testing version 4.1.4 of this cookbook on Ubuntu 14.04 and I continue to get the following error whenever I try to deploy a branch that is out of sync with master:

==> default: ---- Begin output of git checkout -b deploy 031023767ab6c625443ef5c271986c70d8368da0 ----
==> default: STDOUT: 
==> default: STDERR: fatal: reference is not a tree: 031023767ab6c625443ef5c271986c70d8368da0
==> default: ---- End output of git checkout -b deploy 031023767ab6c625443ef5c271986c70d8368da0 ----
==> default: Ran git checkout -b deploy 031023767ab6c625443ef5c271986c70d8368da0 returned 128

If I merge the branch into master, and then try and redploy that same branch, the error goes away.

If I keep the branch out of sync, and revert back to an Ubuntu 12.04 OS, the problem never occurs.

Here is the cookbook I have written to test:

https://github.com/duro/application-cookbook-test

It is pointed at a private repo that is basically just a README that has a master and dev branch, with dev 1 commit ahead of master. The key embedded is a read only deploy key, so feel free to use it to test.

Faster deployments with git-based approach

There is a better (== much faster) approach do deploying, using git tags, instead of releases directories. See more here http://blog.codeclimate.com/blog/2013/10/02/high-speed-rails-deploys-with-git/ and here http://factore.ca/blog/278-how-we-reduced-rails-deploy-times-to-under-one-second-with-plain-git

Are there any plans or thoughts on implementing this approach? Currently I hacked around with this small utility method:

def files_changed?(repository, path_to_previous_revision, files)
  `cd #{repository} && git log HEAD...$(cat #{path_to_previous_revision}) -- #{files} | wc -l`.to_i > 0
end

that is then used in deployment callbacks as only_if guard. But it's kind of messy and still, it's not really git-tags solution. What do you think about?

Notifications don't work for the application resource

Hi,

I'm using the application resource to deploy code and unfortunately I'm not able to use either notifies or subscribes whenever new code is deployed. I can see that new code is being pulled down, but it will never notify another resource about.

Has anyone else experienced this?

Thanks!

  application 'nodejs application' do
    path node['path']
    owner node['app_user']
    group node['app_user']
    repository node['git_repo']
    revision node['git_rev']
    notifies :restart, "service[application]", :delayed
  end

Using ~/foo as application path creates /~/foo directory (linux)

Resources are copied to //foo
e.g. /
/foo/id_deploy (if using a deploy key for a git repo)

Expected behavior is to copy data to chef user's home folder (probably /root/ if chef running as root).

HOWEVER
some code and scripts interprets '~/' correctly and then gets upset because it cannot find resources e.g.
git ssh wrapper looks for keys in /root/foo/id_deploy ... which does not exist

[Chef 12.0] Cannot find a provider for deploy_revision[application] on ubuntu version 12.04

This looks to be related with the changes in Chef 12 regarding recipe DSL and providers.

================================================================================       
  Error executing action `deploy` on resource 'deploy_revision[nodejs application]'       
  ================================================================================       

  ArgumentError       
  -------------       
  Cannot find a provider for deploy_revision[nodejs application] on ubuntu version 12.04       

  Cookbook Trace:       
  ---------------       
  /tmp/kitchen/cache/cookbooks/application/libraries/default.rb:144:in `deploy_provider'       
  /tmp/kitchen/cache/cookbooks/application/libraries/default.rb:152:in `release_path'       
  /tmp/kitchen/cache/cookbooks/nodestack/recipes/application_nodejs.rb:93:in `block (3 levels) in from_file'       
  /tmp/kitchen/cache/cookbooks/application/libraries/default.rb:189:in `safe_recipe_eval'       
         /tmp/kitchen/cache/cookbooks/application/libraries/default.rb:165:in `callback'
         /tmp/kitchen/cache/cookbooks/application/providers/default.rb:193:in `run_actions_with_context'
         /tmp/kitchen/cache/cookbooks/application/providers/default.rb:172:in `block (2 levels) in run_deploy'

Support resource 'guards'?

This would be fantastic to have, and seems to make sense to me as one typically trying to abide by most Foodcritic rules:

application 'whatever' do
  only_if ...
end

How do you use this cookbook?

Hey Noah,

Big fan of your blog, man.

I know this cookbook is in the middle of a rewrite. I've been following posting and github issues for both this project and the application_ruby cookbook over the last month or so, and I'm still not seeing much about how to USE these new cookbooks.

Any ETA on when the project will be complete? Do you need any help writing docs?

Regards,
Joe Reid

find_matching_role only searches top-level roles

I want to have a role defining a group of application_server-roles. But then the load_balancer is not picking up the nodes as find_matching_role only searches for "role:" instead of "roles:".

Could this be changed?

SVN authentication support

Can you add official svn authentication support to application?
I can't find an easy way to pass svn_username and svn_password to application's deploy_revision resource.

uninitialized constant Chef::DSL

Hiya, first off, thanks for the cookbook, ruby_application looks awesome.

I'm fairly new to Chef, but I seem to be getting an odd error with the latest version of application/application_ruby when I'm following this guide:
http://www.concreteinteractive.com/how-to-deploy-a-rails-application-anywhere-with-chef/

The stacktrace from the error I'm getting is:

➜  chef-repo git:(master) ✗ vagrant up            
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-chef-1/chef-solo-3/roles
[default] -- /tmp/vagrant-chef-1/chef-solo-2/cookbooks
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] -- /tmp/vagrant-chef-1/chef-solo-4/data_bags
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2014-01-18T03:53:39+00:00] INFO: *** Chef 10.14.2 ***
[2014-01-18T03:53:40+00:00] INFO: Setting the run_list to ["recipe[dev-chatter]"] from JSON
[2014-01-18T03:53:40+00:00] INFO: Run List is [recipe[dev-chatter]]
[2014-01-18T03:53:40+00:00] INFO: Run List expands to [dev-chatter]
[2014-01-18T03:53:40+00:00] INFO: Starting Chef Run for precise64
[2014-01-18T03:53:40+00:00] INFO: Running start handlers
[2014-01-18T03:53:40+00:00] INFO: Start handlers complete.

================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/resources/default.rb
================================================================================

NameError
---------
uninitialized constant Chef::DSL

Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/resources/default.rb:23:in `class_from_file'

Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/resources/default.rb:

  1:  #
  2:  # Author:: Noah Kantrowitz <[email protected]>
  3:  # Cookbook Name:: application
  4:  # Resource:: default
  5:  #
  6:  # Copyright:: 2011-2012, Opscode, Inc <[email protected]>
  7:  #
  8:  # Licensed under the Apache License, Version 2.0 (the "License");
  9:  # you may not use this file except in compliance with the License.

[2014-01-18T03:53:40+00:00] ERROR: Running exception handlers
[2014-01-18T03:53:40+00:00] ERROR: Exception handlers complete
[2014-01-18T03:53:40+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-01-18T03:53:40+00:00] FATAL: NameError: uninitialized constant Chef::DSL
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

The versions after running the librarian-chef are:

➜  chef-repo git:(master) ✗ librarian-chef install                                            
Installing apache2 (1.8.14)
Installing application (4.1.4)
Installing logrotate (1.4.0)
Installing build-essential (1.4.2)
Installing passenger_apache2 (2.1.2)
Installing yum (3.0.4)
Installing yum-epel (0.2.0)
Installing runit (1.5.8)
Installing unicorn (1.3.0)
Installing application_ruby (3.0.2)
Installing apt (2.3.4)
Installing ruby_build (0.8.0)
Installing user (0.3.0)

System settings:

➜  chef-repo git:(master) ✗ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]

➜  chef-repo git:(master) ✗ gem -v librarian-chef
2.0.14

➜  chef-repo git:(master) ✗ vagrant -v
Vagrant 1.4.3

To get around this bug, I've downgraded application and application_ruby, so it works with these versions:

Installing apache2 (1.8.14)
Installing application (3.0.0)
Installing logrotate (1.4.0)
Installing build-essential (1.4.2)
Installing passenger_apache2 (2.1.2)
Installing yum (3.0.4)
Installing yum-epel (0.2.0)
Installing runit (1.5.8)
Installing unicorn (1.3.0)
Installing application_ruby (2.1.4)
Installing apt (2.3.4)
Installing ruby_build (0.8.0)
Installing user (0.3.0)

Can you do a release please.

I need the deploy_key feature which has been updated in documentation but to not released yet (which was fun to figure out).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.