Update application_ruby cookbook
This commit is contained in:
parent
1ce7c21c86
commit
b7e395f122
2
Batali
2
Batali
@ -17,7 +17,7 @@ Batali.define do
|
|||||||
cookbook 'poise-ruby-build', '~> 1.1.0'
|
cookbook 'poise-ruby-build', '~> 1.1.0'
|
||||||
cookbook 'application', '~> 5.2.0'
|
cookbook 'application', '~> 5.2.0'
|
||||||
cookbook 'application_javascript'
|
cookbook 'application_javascript'
|
||||||
cookbook 'application_ruby'
|
cookbook 'application_ruby', '~> 4.1.0'
|
||||||
cookbook 'application_git', '~> 1.1.0' # 1.2.0 doesn't work with knife-solo
|
cookbook 'application_git', '~> 1.1.0' # 1.2.0 doesn't work with knife-solo
|
||||||
cookbook 'users', '~> 5.0.0'
|
cookbook 'users', '~> 5.0.0'
|
||||||
cookbook 'sudo', '~> 3.4.0'
|
cookbook 'sudo', '~> 3.4.0'
|
||||||
|
@ -813,10 +813,6 @@
|
|||||||
{
|
{
|
||||||
"name": "application_ruby",
|
"name": "application_ruby",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
[
|
|
||||||
"poise-service",
|
|
||||||
"~> 1.0"
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
"poise",
|
"poise",
|
||||||
"~> 2.0"
|
"~> 2.0"
|
||||||
@ -828,13 +824,17 @@
|
|||||||
[
|
[
|
||||||
"poise-ruby",
|
"poise-ruby",
|
||||||
"~> 2.1"
|
"~> 2.1"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"poise-service",
|
||||||
|
"~> 1.0"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"version": "4.0.1",
|
"version": "4.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "Batali::Source::Site",
|
"type": "Batali::Source::Site",
|
||||||
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application_ruby/versions/4.0.1/download",
|
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/application_ruby/versions/4.1.0/download",
|
||||||
"version": "4.0.1"
|
"version": "4.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
# Application_Ruby Changelog
|
# Application_Ruby Changelog
|
||||||
|
|
||||||
|
## v4.1.0
|
||||||
|
|
||||||
|
* Add an `application_puma` resource to run a Puma application server.
|
||||||
|
* Add support for `:initializer` style secrets for the `application_rails` resource.
|
||||||
|
* Chef 13 support.
|
||||||
|
|
||||||
## v4.0.1
|
## v4.0.1
|
||||||
|
|
||||||
* Correct `gem_binary` results for `application_ruby`.
|
* Correct `gem_binary` results for `application_ruby`.
|
||||||
|
@ -33,7 +33,7 @@ end
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Chef 12 or newer is required.
|
Chef 12.1 or newer is required.
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
@ -53,6 +53,34 @@ end
|
|||||||
|
|
||||||
All actions and properties are the same as the [`bundle_install` resource](https://github.com/poise/poise-ruby#bundle_install).
|
All actions and properties are the same as the [`bundle_install` resource](https://github.com/poise/poise-ruby#bundle_install).
|
||||||
|
|
||||||
|
### `application_puma`
|
||||||
|
|
||||||
|
The `application_puma` resource creates a service for `puma`.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
application '/srv/myapp' do
|
||||||
|
puma do
|
||||||
|
port 8000
|
||||||
|
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)*
|
||||||
|
* `port` – Port to listen on. *(default: 80)*
|
||||||
|
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
||||||
|
* `user` – User to run the service as. *(default: application owner)*
|
||||||
|
|
||||||
### `application_rackup`
|
### `application_rackup`
|
||||||
|
|
||||||
The `application_rackup` resource creates a service for `rackup`.
|
The `application_rackup` resource creates a service for `rackup`.
|
||||||
@ -102,6 +130,8 @@ end
|
|||||||
#### Properties
|
#### Properties
|
||||||
|
|
||||||
* `path` – Base path for the application. *(name attribute)*
|
* `path` – Base path for the application. *(name attribute)*
|
||||||
|
* `app_module` – Top-level application module. Only needed for the :initializer
|
||||||
|
style of secret token configuration. *(default: auto-detect)*
|
||||||
* `database` – Database settings for Rails. See [the database section
|
* `database` – Database settings for Rails. See [the database section
|
||||||
below](#database-parameters) for more information. *(option collector)*
|
below](#database-parameters) for more information. *(option collector)*
|
||||||
* `migrate` – Run database migrations. *(default: false)*
|
* `migrate` – Run database migrations. *(default: false)*
|
||||||
@ -218,7 +248,7 @@ end
|
|||||||
* `config_path` – Path to a Thin configuration file.
|
* `config_path` – Path to a Thin configuration file.
|
||||||
* `port` – Port to listen on. *(default: 80)*
|
* `port` – Port to listen on. *(default: 80)*
|
||||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
* `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)*
|
||||||
|
|
||||||
### `application_unicorn`
|
### `application_unicorn`
|
||||||
|
|
||||||
@ -246,7 +276,7 @@ end
|
|||||||
* `path` – Base path for the application. *(name attribute)*
|
* `path` – Base path for the application. *(name attribute)*
|
||||||
* `port` – Port to listen on. *(default: 80)*
|
* `port` – Port to listen on. *(default: 80)*
|
||||||
* `service_name` – Name of the service to create. *(default: auto-detect)*
|
* `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)*
|
||||||
|
|
||||||
## Sponsors
|
## Sponsors
|
||||||
|
|
||||||
@ -256,7 +286,7 @@ The Poise test server infrastructure is sponsored by [Rackspace](https://rackspa
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright 2015, Noah Kantrowitz
|
Copyright 2015-2017, Noah Kantrowitz
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -15,6 +15,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
require 'poise_application_ruby/resources/bundle_install'
|
require 'poise_application_ruby/resources/bundle_install'
|
||||||
|
require 'poise_application_ruby/resources/puma'
|
||||||
require 'poise_application_ruby/resources/rackup'
|
require 'poise_application_ruby/resources/rackup'
|
||||||
require 'poise_application_ruby/resources/rails'
|
require 'poise_application_ruby/resources/rails'
|
||||||
require 'poise_application_ruby/resources/ruby'
|
require 'poise_application_ruby/resources/ruby'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
# 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_ruby/service_mixin'
|
||||||
|
|
||||||
|
module PoiseApplicationRuby
|
||||||
|
module Resources
|
||||||
|
# (see Puma::Resource)
|
||||||
|
# @since 4.1.0
|
||||||
|
module Puma
|
||||||
|
# An `application_puma` resource to manage a puma web application
|
||||||
|
# server.
|
||||||
|
#
|
||||||
|
# @since 4.1.0
|
||||||
|
# @provides application_puma
|
||||||
|
# @action enable
|
||||||
|
# @action disable
|
||||||
|
# @action start
|
||||||
|
# @action stop
|
||||||
|
# @action restart
|
||||||
|
# @action reload
|
||||||
|
# @example
|
||||||
|
# application '/srv/myapp' do
|
||||||
|
# git '...'
|
||||||
|
# bundle_install
|
||||||
|
# puma do
|
||||||
|
# port 8080
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
class Resource < Chef::Resource
|
||||||
|
include PoiseApplicationRuby::ServiceMixin
|
||||||
|
provides(:application_puma)
|
||||||
|
|
||||||
|
# @!attribute port
|
||||||
|
# Port to bind to.
|
||||||
|
attribute(:port, kind_of: [String, Integer], default: 80)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Provider for `application_puma`.
|
||||||
|
#
|
||||||
|
# @since 4.1.0
|
||||||
|
# @see Resource
|
||||||
|
# @provides application_puma
|
||||||
|
class Provider < Chef::Provider
|
||||||
|
include PoiseApplicationRuby::ServiceMixin
|
||||||
|
provides(:application_puma)
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Find the path to the config.ru. If the resource path was to a
|
||||||
|
# directory, apparent /config.ru.
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
def configru_path
|
||||||
|
@configru_path ||= if ::File.directory?(new_resource.path)
|
||||||
|
::File.join(new_resource.path, 'config.ru')
|
||||||
|
else
|
||||||
|
new_resource.path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set service resource options.
|
||||||
|
def service_options(resource)
|
||||||
|
super
|
||||||
|
resource.ruby_command("puma --port #{new_resource.port} #{configru_path}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -18,6 +18,7 @@ require 'chef/provider'
|
|||||||
require 'chef/resource'
|
require 'chef/resource'
|
||||||
|
|
||||||
require 'poise_application_ruby/app_mixin'
|
require 'poise_application_ruby/app_mixin'
|
||||||
|
require 'poise_application_ruby/error'
|
||||||
|
|
||||||
|
|
||||||
module PoiseApplicationRuby
|
module PoiseApplicationRuby
|
||||||
@ -47,6 +48,11 @@ module PoiseApplicationRuby
|
|||||||
provides(:application_rails)
|
provides(:application_rails)
|
||||||
actions(:deploy)
|
actions(:deploy)
|
||||||
|
|
||||||
|
# @!attribute app_module
|
||||||
|
# Top-level application module. Only needed for the :initializer style
|
||||||
|
# of secret token configuration, and generally auto-detected.
|
||||||
|
# @return [String, false, nil]
|
||||||
|
attribute(:app_module, kind_of: [String, FalseClass, NilClass], default: lazy { default_app_module })
|
||||||
# @!attribute database
|
# @!attribute database
|
||||||
# Option collector attribute for Rails database configuration.
|
# Option collector attribute for Rails database configuration.
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
@ -84,14 +90,20 @@ module PoiseApplicationRuby
|
|||||||
# Secret token for Rails session verification and other purposes. On
|
# Secret token for Rails session verification and other purposes. On
|
||||||
# Rails 4.2 this will be used for secret_key_base. If not set, no
|
# Rails 4.2 this will be used for secret_key_base. If not set, no
|
||||||
# secrets configuration is written.
|
# secrets configuration is written.
|
||||||
# @return [String]
|
# @return [String, false, nil]
|
||||||
attribute(:secret_token, kind_of: [String, FalseClass])
|
attribute(:secret_token, kind_of: [String, FalseClass, NilClass])
|
||||||
# @!attribute secrets_config
|
# @!attribute secrets_config
|
||||||
# Template content attribute for the contents of secrets.yml. Only
|
# Template content attribute for the contents of secrets.yml. Only
|
||||||
# used when secrets_mode is :yaml.
|
# used when secrets_mode is :yaml.
|
||||||
# @todo Redo this doc to cover the actual attributes created.
|
# @todo Redo this doc to cover the actual attributes created.
|
||||||
# @return [Poise::Helpers::TemplateContent]
|
# @return [Poise::Helpers::TemplateContent]
|
||||||
attribute(:secrets_config, template: true, default_source: 'secrets.yml.erb', default_options: lazy { default_secrets_options })
|
attribute(:secrets_config, template: true, default_source: 'secrets.yml.erb', default_options: lazy { default_secrets_options })
|
||||||
|
# @!attribute secrets_initializer
|
||||||
|
# Template content attribute for the contents of secret_token.rb. Only
|
||||||
|
# used when secrets_mode is :initializer.
|
||||||
|
# @todo Redo this doc to cover the actual attributes created.
|
||||||
|
# @return [Poise::Helpers::TemplateContent]
|
||||||
|
attribute(:secrets_initializer, template: true, default_source: 'secret_token.rb.erb', default_options: lazy { default_secrets_options })
|
||||||
# @!attribute secrets_mode
|
# @!attribute secrets_mode
|
||||||
# Secrets configuration mode. Set to `:yaml` to generate a Rails 4.2
|
# Secrets configuration mode. Set to `:yaml` to generate a Rails 4.2
|
||||||
# secrets.yml. Set to `:initializer` to update
|
# secrets.yml. Set to `:initializer` to update
|
||||||
@ -140,21 +152,33 @@ module PoiseApplicationRuby
|
|||||||
#
|
#
|
||||||
# @return [Symbol]
|
# @return [Symbol]
|
||||||
def default_secrets_mode
|
def default_secrets_mode
|
||||||
::File.exists?(::File.join(path, 'config', 'initializers', 'secret_token.rb')) ? :initialize : :yaml
|
::File.exists?(::File.join(path, 'config', 'initializers', 'secret_token.rb')) ? :initializer : :yaml
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default template variables for the secrets.yml.
|
# Default template variables for the secrets.yml and secret_token.rb.
|
||||||
#
|
#
|
||||||
# @return [Hash<Symbol, Object>]
|
# @return [Hash<Symbol, Object>]
|
||||||
def default_secrets_options
|
def default_secrets_options
|
||||||
{
|
{
|
||||||
config: {
|
yaml_config: {
|
||||||
rails_env => {
|
rails_env => {
|
||||||
'secret_key_base' => secret_token,
|
'secret_key_base' => secret_token,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
secret_token: secret_token,
|
||||||
|
app_module: if secrets_mode == :initializer
|
||||||
|
raise Error.new("Unable to extract app module for #{self}, please set app_module property") if !app_module || app_module.empty?
|
||||||
|
app_module
|
||||||
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Default application module name.
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
def default_app_module
|
||||||
|
IO.read(::File.join(path, 'config', 'initializers', 'secret_token.rb'))[/(\w+)::Application\.config\.secret_token/, 1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Provider for `application_rails`.
|
# Provider for `application_rails`.
|
||||||
@ -205,6 +229,8 @@ module PoiseApplicationRuby
|
|||||||
write_secrets_yml
|
write_secrets_yml
|
||||||
when :initializer
|
when :initializer
|
||||||
write_secrets_initializer
|
write_secrets_initializer
|
||||||
|
else
|
||||||
|
raise Error.new("Unknown secrets mode #{new_resource.secrets_mode.inspect}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -215,13 +241,19 @@ module PoiseApplicationRuby
|
|||||||
group new_resource.parent.group
|
group new_resource.parent.group
|
||||||
mode '640'
|
mode '640'
|
||||||
content new_resource.secrets_config_content
|
content new_resource.secrets_config_content
|
||||||
|
sensitive true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# In-place update a config/initializers/secret_token.rb file.
|
# In-place update a config/initializers/secret_token.rb file.
|
||||||
def write_secrets_initializer
|
def write_secrets_initializer
|
||||||
# @todo Implement initalizer-style secret support.
|
file ::File.join(new_resource.path, 'config', 'initializers', 'secret_token.rb') do
|
||||||
raise NotImplementedError.new('Sorry, intializer-style secrets loading is not yet supported.')
|
user new_resource.parent.owner
|
||||||
|
group new_resource.parent.group
|
||||||
|
mode '640'
|
||||||
|
content new_resource.secrets_initializer_content
|
||||||
|
sensitive true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Precompile assets using the rake task.
|
# Precompile assets using the rake task.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -39,6 +39,7 @@ module PoiseApplicationRuby
|
|||||||
module Provider
|
module Provider
|
||||||
include PoiseApplication::ServiceMixin::Provider
|
include PoiseApplication::ServiceMixin::Provider
|
||||||
include PoiseApplicationRuby::AppMixin::Provider
|
include PoiseApplicationRuby::AppMixin::Provider
|
||||||
|
include PoiseRuby::RubyCommandMixin::Provider
|
||||||
include PoiseRuby::BundlerMixin
|
include PoiseRuby::BundlerMixin
|
||||||
|
|
||||||
# Set up the service for running Ruby stuff.
|
# Set up the service for running Ruby stuff.
|
||||||
@ -48,10 +49,17 @@ module PoiseApplicationRuby
|
|||||||
self_ = self
|
self_ = self
|
||||||
# Create a new singleton method that fills in Python for you.
|
# Create a new singleton method that fills in Python for you.
|
||||||
resource.define_singleton_method(:ruby_command) do |val|
|
resource.define_singleton_method(:ruby_command) do |val|
|
||||||
path = self_.new_resource.app_state_environment_ruby['PATH']
|
path = self_.new_resource.app_state_environment_ruby['PATH'] || ENV['PATH']
|
||||||
cmd = if self_.new_resource.parent_bundle
|
cmd = if self_.new_resource.parent_bundle
|
||||||
bundle_exec_command(val, path: path)
|
bundle_exec_command(val, path: path)
|
||||||
else
|
else
|
||||||
|
# Insert the gem executable directory at the front of the path.
|
||||||
|
gem_environment = self_.send(:ruby_shell_out!, self_.new_resource.gem_binary, 'environment')
|
||||||
|
matches = gem_environment.stdout.scan(/EXECUTABLE DIRECTORY: (.*)$/).first
|
||||||
|
if matches
|
||||||
|
Chef::Log.debug("[#{new_resource}] Prepending gem executable directory #{matches.first} to existing $PATH (#{path})")
|
||||||
|
path = "#{matches.first}:#{path}"
|
||||||
|
end
|
||||||
"#{self_.new_resource.ruby} #{PoiseLanguages::Utils.absolute_command(val, path: path)}"
|
"#{self_.new_resource.ruby} #{PoiseLanguages::Utils.absolute_command(val, path: path)}"
|
||||||
end
|
end
|
||||||
resource.command(cmd)
|
resource.command(cmd)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -15,5 +15,5 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
module PoiseApplicationRuby
|
module PoiseApplicationRuby
|
||||||
VERSION = '4.0.1'
|
VERSION = '4.1.0'
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2015, Noah Kantrowitz
|
# Copyright 2015-2017, Noah Kantrowitz
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
File diff suppressed because one or more lines are too long
3
cookbooks/application_ruby/templates/secret_token.rb.erb
Normal file
3
cookbooks/application_ruby/templates/secret_token.rb.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Generated by Chef for <%= @new_resource.to_s %>
|
||||||
|
|
||||||
|
<%= @app_module %>::Application.config.secret_token = <%= @secret_token.inspect %>
|
@ -1,3 +1,3 @@
|
|||||||
# Generated by Chef for <%= @new_resource.to_s %>
|
# Generated by Chef for <%= @new_resource.to_s %>
|
||||||
|
|
||||||
<%= @config.to_yaml %>
|
<%= @yaml_config.to_yaml %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user