Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
fix: node['applications'] are back
Browse files Browse the repository at this point in the history
Unfortunatelly during the setup phase, OpsWorks deploys all applications
in given stack - there is no way to assign some applications to some
layers only. This parameter resolves this issue (and thus - should be
kept) by filtering supported applications in given layer, to only listed
in it. Notice, that with this option enabled, it won't be possible to
deploy to a given layer an application which is not listed in it.

Resolves #55
  • Loading branch information
ajgon committed Oct 26, 2016
1 parent 4293bff commit 5fc42c3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 20 deletions.
58 changes: 42 additions & 16 deletions docs/source/attributes.rst
Expand Up @@ -14,8 +14,31 @@ Attributes
| so for example ``app['framework']['adapter']`` actually means
| ``node['deploy'][<application_shortname>]['framework']['adapter']``.
Stack attributes
----------------

These attributes are used on Stack/Layer level globally to configure
the opsworks_ruby cookbook itself. They should'nt be used under
``node['deploy'][<application_shortname>]`` (notice lack of the ``app[]``
convention).

- ``node['applications']``

- An array of application shortnames which should be deployed to given layer.
If set, only applications witch ``deploy`` flag set (on OpsWorks side) included
in this list will be deployed. If not set, all ``deploy`` application will be
supported. This parameter mostly matters during the setup phase, since all
application in given stack are deployed to the given layer. Using this paramter
you can narrow the list to application which you actually intend to use.
**Important** thing is, that when you try to do a manual deploy from OpsWorks
of an application, not included in this list - it will be skipped, as this list
takes precedence over anything else.

Application attributes
----------------------

global
------
~~~~~~

| Global parameters apply to the whole application, and can be used by
any section
Expand All @@ -29,7 +52,7 @@ global
in Rails) actions in the project (server, worker, etc.)

database
--------
~~~~~~~~

| Those parameters will be passed without any alteration to the
``database.yml``
Expand Down Expand Up @@ -67,7 +90,7 @@ database
the ``database.yml``

scm
---
~~~

| Those parameters can also be determined from OpsWorks application, and
usually
Expand Down Expand Up @@ -113,7 +136,7 @@ scm
also be fetched.

framework
---------
~~~~~~~~~

| Pre-optimalization for specific frameworks (like migrations, cache etc.).
| Currently ``hanami.rb`` and ``Rails`` are supported.
Expand Down Expand Up @@ -146,7 +169,7 @@ framework
- A command which will be invoked to precompile assets.

padrino
~~~~~~~
^^^^^^^

| For Padrino, slight adjustments needs to be made. Since there are many database
| adapters supported, instead of creating configuration for each one, the
Expand All @@ -163,7 +186,7 @@ padrino
}
rails
~~~~~
^^^^^

- ``app['framework']['envs_in_console']``

Expand All @@ -176,7 +199,7 @@ rails
it as a first step in your debugging process.

appserver
---------
~~~~~~~~~

| Configuration parameters for the ruby application server. Currently ``Puma``,
| ``Thin`` and ``Unicorn`` are supported.
Expand Down Expand Up @@ -220,7 +243,7 @@ appserver
serve exactly one client at a time.

unicorn
~~~~~~~
^^^^^^^

- |app['appserver']['backlog']|_

Expand All @@ -245,7 +268,7 @@ unicorn
- **Default:** ``5``

puma
~~~~
^^^^

- |app['appserver']['log_requests']|_

Expand All @@ -261,7 +284,7 @@ puma
- **Default:** ``0``

thin
~~~~
^^^^

- ``app['appserver']['max_connections']``

Expand All @@ -280,7 +303,7 @@ thin
- **Default:** ``4``

webserver
---------
~~~~~~~~~

| Webserver configuration. Proxy passing to application is handled out-of-the-box.
| Currently Apache2 and nginx is supported.
Expand Down Expand Up @@ -315,7 +338,7 @@ webserver
application needs a support for those browsers, set this parameter to ``true``.

apache
~~~~~~
^^^^^^

- ``app['webserver']['extra_config']``

Expand Down Expand Up @@ -346,7 +369,7 @@ apache
- **Default**: ``60``

nginx
~~~~~
^^^^^

- ``app['webserver']['build_type']``

Expand Down Expand Up @@ -402,8 +425,11 @@ nginx
| as well (notice that ``node['deploy'][<application_shortname>]`` logic
| doesn't apply here.)
worker
~~~~~~

sidekiq
~~~~~~~
^^^^^^^

- ``app['worker']['config']``

Expand All @@ -412,14 +438,14 @@ sidekiq
`sidekiq.yml config file`_.

delayed\_job
~~~~~~~~~~~~
^^^^^^^^^^^^

- ``app['worker']['queues']``

- Array of queues which should be processed by delayed\_job

resque
~~~~~~
^^^^^^

- ``app['worker']['workers']``

Expand Down
7 changes: 7 additions & 0 deletions docs/source/troubleshooting.rst
Expand Up @@ -15,5 +15,12 @@ By default webserver is configured to follow strict SSL security standards, `cov
old browsers (like IE < 9 or Android < 2.2) wouldn't work with this configuration very well. If your application needs
a support for those browsers, set ``app['webserver']['ssl_for_legacy_browsers']`` to true.

Some applications on my Layer deploys, some of them not
-------------------------------------------------------

Check the ``node['applications']`` parameter in :ref:`Attributes` section.
If set, it narrows down the list of applications allowed to deploy, to its value.
If not sure what to do - try to remove from your Stack/Layer config and see if this helps.

.. _covered in this article: https://cipherli.st/

8 changes: 8 additions & 0 deletions libraries/helpers.rb
Expand Up @@ -80,4 +80,12 @@ def perform_bundle_install(shared_path, envs = {})

def prepare_recipe
node.default['deploy'] = Hash[applications.map { |app| [app['shortname'], {}] }].merge(node['deploy'] || {})
apps_not_included.each do |app_for_removal|
node.rm('deploy', app_for_removal)
end
end

def apps_not_included
return [] if node['applications'].blank?
node['deploy'].keys.select { |app_name| !node['applications'].include?(app_name) }
end
10 changes: 6 additions & 4 deletions spec/unit/recipes/deploy_spec.rb
Expand Up @@ -155,14 +155,16 @@
end.not_to raise_error
end

it 'app[\'deploy\'] = false' do
it 'node[\'applications\']' do
stub_search(:aws_opsworks_app, '*:*').and_return([
aws_opsworks_app.merge(shortname: 'a1'),
aws_opsworks_app.merge(shortname: 'a2', deploy: false)
aws_opsworks_app.merge(shortname: 'a1', deploy: true),
aws_opsworks_app.merge(shortname: 'a2', deploy: false),
aws_opsworks_app.merge(shortname: 'a3', deploy: true)
])
chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node|
solo_node.set['lsb'] = node['lsb']
solo_node.set['deploy'] = { 'a1' => {}, 'a2' => {} }
solo_node.set['deploy'] = { 'a1' => {}, 'a2' => {}, 'a3' => {} }
solo_node.set['applications'] = %w(a1 a2)
end.converge(described_recipe)
service = chef_run.service('puma_a1')

Expand Down

0 comments on commit 5fc42c3

Please sign in to comment.