Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AllowOverride All #344

Open
wants to merge 55 commits into
base: release-chef-11.10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
ba22728
Bump version to 3428 for next dev cycle.
jarv-aws Sep 16, 2015
4c66499
Fix s3_file with `_` in bucket name
workeitel Oct 6, 2015
a1e7ca6
Use path style addressing only for buckets with underscore.
workeitel Oct 14, 2015
c8152b9
AllowOverride All
wwwjscom Oct 19, 2015
6a1a3c7
Add postgresql to the Gemfile db adapter detection logic
jarv-aws Oct 19, 2015
8559e72
Adding delayed jobs cookbook
wwwjscom Oct 20, 2015
338a70d
fixed typo
wwwjscom Oct 20, 2015
3e43103
Updating cookbooks to support rails with pg
jarv-aws Oct 20, 2015
3297c85
Adding changelog header for 3428
jarv-aws Oct 28, 2015
fd88557
Bump version to 3429 for next dev cycle.
jarv-aws Oct 30, 2015
5cf9e47
Enable retry for all kind of Exceptions
workeitel Oct 30, 2015
4148e0a
Add a 5 second sleep between each retry in s3_file cookbook.
workeitel Oct 30, 2015
5519e23
Update changelog
jbraeuer Nov 17, 2015
545c2dc
Bump version to 3430 for next dev cycle.
jbraeuer Nov 19, 2015
d45990c
Adding changelog header for 3430
Nov 25, 2015
150ff89
Bump version to 3431 for next dev cycle.
Nov 25, 2015
d4aaf44
Updating README.md for Chef 12
jarv-aws Dec 3, 2015
05165ed
Update Node.js cookbook default
jbraeuer Dec 8, 2015
9341de0
Mention Node.js version 0.12.9 in the changelog
githuesch Dec 9, 2015
22ec96b
Add Not-customizable disclaimer.
jbraeuer Dec 15, 2015
fde0fc1
Add chef service resource compatibility for CentOS 7.2
workeitel Dec 16, 2015
550a065
Updating the postgresql cookbook with defaults for the package version
jarv-aws Dec 16, 2015
db08e27
Bump opsworks-ruby version
workeitel Dec 17, 2015
1ae7b2e
Use a fixed rack version otherwise passenger will use a latest rack v…
Dec 21, 2015
8e1777a
Install fixed rack version for unicorn
Dec 21, 2015
36a916a
Adding changelog header for 3431
Dec 22, 2015
e135ce1
Bump version to 3432 for next dev cycle.
Dec 22, 2015
26f209f
Fix typo
Dec 23, 2015
c5de5f1
Update initramfs after raid array creation
jarv-aws Jan 6, 2016
21aea0d
Don't fail if a volume has no mount point
workeitel Jan 11, 2016
e6caf07
Fix regex for s3 virtual host style addressing to match new eu-centra…
workeitel Jan 13, 2016
b826296
Always pass the base url for s3 file resource
workeitel Jan 13, 2016
191a0f7
Update s3_file to 2.6.6, git: 23c88744be6069455a39a1bc7b88e44169fe8718
workeitel Jan 13, 2016
e38bc31
Enable retry for all kind of Exceptions
workeitel Oct 30, 2015
be528e0
Add a 5 second sleep between each retry in s3_file cookbook.
workeitel Oct 30, 2015
8dca2e5
Improve URL generation by using region and improving virtual domain s…
workeitel Jan 11, 2016
95ea555
Always do a unicorn restart to avoid downtime during deploys.
jarv-aws Jan 12, 2016
eca32c6
Improve error message if asset is not found
workeitel Jan 18, 2016
0034a35
Add link to documentation to error message if asset download fail
workeitel Jan 18, 2016
0fcb6e8
Replace backticks with propper mixlib shellout
workeitel Jan 18, 2016
f6a16a6
Update cookbooks for setup
Jan 14, 2016
7dd557e
Adding changelog header for 3432
Jan 20, 2016
ae6b7ff
Fixing changelog for # v3432 2016-01-20
Jan 20, 2016
c05fb91
Bump version to 3433 for next dev cycle.
Jan 21, 2016
a156041
Retry achive download three times
workeitel Feb 2, 2016
f35454f
Remove compile_time from s3_file::dependencies
Feb 3, 2016
dae1b1d
Add compatibility with chef-sugar for detecting compile_time method
workeitel Feb 4, 2016
52f3c57
Don't wait for bind mounts if not running on ec2
workeitel Feb 8, 2016
17d3f28
Fix typo in infrastructure_class check for deploy dir
workeitel Feb 15, 2016
4030965
Update nodejs default version
Feb 18, 2016
a49009c
Update rubygems.org download URL
workeitel Feb 27, 2016
25ffea3
AllowOverride All
wwwjscom Oct 19, 2015
86a0d2b
Adding delayed jobs cookbook
wwwjscom Oct 20, 2015
49f751e
fixed typo
wwwjscom Oct 20, 2015
b914d40
Merge branch 'patch-1' of github.com:wwwjscom/opsworks-cookbooks into…
wwwjscom Mar 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# v3432 2016-01-20
- Improve handling of special characters in bucket names
- Update s3_file to version 2.6.6
- Skip mounting of volumes with no specified mount point
- Always restart Unicorn instead of a stop and start to prevent downtime during deploys
- Always update custom cookbook for setup command
- After creating RAID arrays update initramfs to prevent device mapping issues on reboot

# v3431 2015-12-22
- Fixed passenger and unicorn gem installation issue
- Updating the default 2.0, 2.1 and 2.2 versions of Ruby to 2.0.0p648, 2.1.8 and 2.2.4
- Allow postgres package names to set in custom JSON.
- Update the Node.js default version to 0.12.9

# v3430 2015-11-25
# v3429 2015-11-19
- Improve robustness of s3_file resource (retries, caught exceptions).

# v3428 2015-10-28
- Adding postgres adapter detection based on the Gemfile, fixes https://github.com/aws/opsworks-cookbooks/issues/136

# v3427 2015-09-11
- Updating the default 2.0, 2.1 and 2.2 versions of Ruby to 2.0.0p647, 2.1.7 and 2.2.3

Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
opsworks-cookbooks
==================

**These are the standard Chef cookbooks used by AWS OpsWorks.**
**This repo contains cookbooks used by AWS OpsWorks for Chef versions 11.10, 11.4 and 0.9.**

To get started with AWS OpsWorks cookbooks for all versions of Chef see the [cookbook documentation](https://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook.html).

If you want to override any template (like the Rails database.yml or the Apache
vhost definition), this is the place to look for the originals.

Branches for current Chef versions
Chef version 12
------------------------------------

**For Chef 12.2 Windows and Chef 12 Linux there are no built-in cookbooks**

Chef versions 11.10, 11.4 and 0.9
----------------------------------

These branches are currently used by OpsWorks on your instance.
These branches contain the cookbooks that are used by official OpsWorks releases:

- **Chef 11.10**: [release-chef-11.10](https://github.com/aws/opsworks-cookbooks/tree/release-chef-11.10)
- **Chef 11.4**: [release-chef-11.4](https://github.com/aws/opsworks-cookbooks/tree/release-chef-11.4)
- **Chef 0.9**: [release-chef-0.9](https://github.com/aws/opsworks-cookbooks/tree/release-chef-0.9)
- **Chef 11.4**: [release-chef-11.4](https://github.com/aws/opsworks-cookbooks/tree/release-chef-11.4) (deprecated)
- **Chef 0.9**: [release-chef-0.9](https://github.com/aws/opsworks-cookbooks/tree/release-chef-0.9) (deprecated)

Upcoming changes
----------------

These branches reflect the upcoming changes for the next release.
These branches reflect the upcoming changes for the next release:

- **Chef 11.10**: [master-chef-11.10](https://github.com/aws/opsworks-cookbooks/tree/master-chef-11.10)
- **Chef 11.4**: [master-chef-11.4](https://github.com/aws/opsworks-cookbooks/tree/master-chef-11.4)
- **Chef 0.9**: [master-chef-0.9](https://github.com/aws/opsworks-cookbooks/tree/master-chef-0.9)

- **Chef 11.4**: [master-chef-11.4](https://github.com/aws/opsworks-cookbooks/tree/master-chef-11.4) (deprecated)
- **Chef 0.9**: [master-chef-0.9](https://github.com/aws/opsworks-cookbooks/tree/master-chef-0.9) (deprecated)

The `master` branch is no longer used since AWS OpsWorks supports multiple
configuration managers now.
The `master` branch is not used since AWS OpsWorks supports multiple configuration managers.

See also <https://aws.amazon.com/opsworks/>

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3427
3433
2 changes: 1 addition & 1 deletion deploy/attributes/rails_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
normal[:opsworks][:rails_stack][:recipe] = "unicorn::rails"
normal[:opsworks][:rails_stack][:needs_reload] = true
normal[:opsworks][:rails_stack][:service] = 'unicorn'
normal[:opsworks][:rails_stack][:restart_command] = '../../shared/scripts/unicorn clean-restart'
normal[:opsworks][:rails_stack][:restart_command] = "../../shared/scripts/unicorn restart"
else
raise "Unknown stack: #{node[:opsworks][:rails_stack][:name].inspect}"
end
Expand Down
1 change: 1 addition & 0 deletions deploy/definitions/opsworks_deploy_dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
done
EOH
ignore_failure true
only_if { infrastructure_class?("ec2") }
end
end
end
Expand Down
1 change: 1 addition & 0 deletions deploy/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
depends "opsworks_java"
depends "php"
depends "mysql"
depends "opsworks_postgresql"
depends "opsworks_nodejs"
depends "opsworks_aws_flow_ruby"

Expand Down
7 changes: 7 additions & 0 deletions deploy/recipes/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
next
end

case deploy[:database][:type]
when "mysql"
include_recipe "mysql::client_install"
when "postgresql"
include_recipe "opsworks_postgresql::client_install"
end

opsworks_deploy_dir do
user deploy[:user]
group deploy[:group]
Expand Down
28 changes: 22 additions & 6 deletions ebs/recipes/raids.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package 'mdadm'
package 'lvm2'
require "mkmf"

execute 'Load device mapper kernel module' do
command 'modprobe dm-mod'
Expand Down Expand Up @@ -71,15 +72,30 @@
pass 0
end

template 'mdadm configuration' do
execute "update initramfs" do
command value_for_platform_family(
"rhel" => "dracut -H -f /boot/initramfs-#{node["kernel"]["release"]}.img #{node["kernel"]["release"]}",
"debian" => "update-initramfs -u"
)
only_if do
value_for_platform_family(
"rhel" => find_executable0("dracut"),
"debian" => find_executable0("update-initramfs")
)
end
action :nothing
end

template "mdadm configuration" do
path value_for_platform(
['centos','redhat','fedora','amazon'] => {'default' => '/etc/mdadm.conf'},
'default' => '/etc/mdadm/mdadm.conf'
["centos","redhat","fedora","amazon"] => {"default" => "/etc/mdadm.conf"},
"default" => "/etc/mdadm/mdadm.conf"
)
source 'mdadm.conf.erb'
source "mdadm.conf.erb"
mode 0644
owner 'root'
group 'root'
owner "root"
group "root"
notifies :run, "execute[update initramfs]", :immediately
end

template 'rc.local script' do
Expand Down
5 changes: 5 additions & 0 deletions ebs/recipes/volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
mode "0755"
end

if options[:mount_point].nil? || options[:mount_point].empty?
log "skip mounting volume #{device} because no mount_point specified"
next
end

mount options[:mount_point] do
action [:mount, :enable]
fstype options[:fstype]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#
# This template can not be customized.
#
check process opsworks-agent with pidfile "<%= node[:opsworks_agent][:shared_dir] %>/pid/opsworks-agent.pid"
start program = "/etc/init.d/opsworks-agent start"
stop program = "/etc/init.d/opsworks-agent stop"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#
# This template can not be customized.
#
check process opsworks-agent with pidfile "<%= node[:opsworks_agent][:shared_dir] %>/pid/opsworks-agent.pid"
start program = "/etc/init.d/opsworks-agent start"
stop program = "/etc/init.d/opsworks-agent stop"
Expand Down
5 changes: 5 additions & 0 deletions opsworks_commons/libraries/monkey_patch_provider_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def patch_platform(pf)
pf[:redhat][:default][:service] = Chef::Provider::Service::Systemd
pf[:redhat]["< 7"] ||= {}
pf[:redhat]["< 7"][:service] = Chef::Provider::Service::Redhat

pf[:centos][:default][:service] = Chef::Provider::Service::Systemd
pf[:centos]["< 7"] ||= {}
pf[:centos]["< 7"][:service] = Chef::Provider::Service::Redhat

pf
end
end
Expand Down
18 changes: 14 additions & 4 deletions opsworks_commons/providers/assets_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ def local_asset
asset_basedir = "#{download_basedir}/#{@new_resource.asset}"
::FileUtils.mkdir_p asset_basedir

local_asset_path = `#{downloader_script} -r #{@new_resource.max_fetch_retries} -u #{asset_url} -d "#{asset_basedir}"`.chomp
cmd = Mixlib::ShellOut.new("#{downloader_script} -r #{@new_resource.max_fetch_retries} -u #{asset_url} -d '#{asset_basedir}'")
cmd.run_command
local_asset_path = cmd.stdout.chomp
STDERR.puts cmd.stderr

if $?.success? &&
if !cmd.error? &&
::File.file?(local_asset_path) &&
::File.fnmatch("#{asset_basedir}.*", ::File.dirname(local_asset_path))

Expand All @@ -85,7 +88,14 @@ def local_asset
::FileUtils.rm_rf(Dir["#{asset_basedir}.*"], :verbose => true) rescue Chef::Log.error "Couldn't cleanup downloaded assets for #{@new_resource.name}."
elsif @new_resource.ignore_failure
Chef::Log.error "Failed to download asset #{asset_name} for #{@new_resource.name} with url #{asset_url}."
elsif !@new_resource.ignore_failure
raise Chef::Exceptions::ResourceNotFound, "Failed to download asset #{@new_resource.asset} for #{@new_resource.name} with url #{asset_url}."
else
msg = ["Failed to download asset #{@new_resource.asset} for #{@new_resource.name} with url #{asset_url}."]

if cmd.stderr.include?("403 Forbidden")
msg << "The asset is probably not available for your operating system (#{node[:platform]} #{node[:platform_version]})."
msg << "Please have a look what versions are supported for this operating system at:"
msg << "http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os-linux.html"
end
fail Chef::Exceptions::ResourceNotFound, msg.join("\n")
end
end
6 changes: 5 additions & 1 deletion opsworks_custom_cookbooks/recipes/load.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if node[:opsworks_custom_cookbooks][:enabled]
include_recipe "opsworks_custom_cookbooks::checkout"
if node[:opsworks][:activity] == "setup"
include_recipe "opsworks_custom_cookbooks::update"
else
include_recipe "opsworks_custom_cookbooks::checkout"
end
else
directory node[:opsworks_custom_cookbooks][:destination] do
action :delete
Expand Down
4 changes: 4 additions & 0 deletions opsworks_delayed_job/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.6 (in progress)
---
* Restart workers directly rather than with `node[:opsworks][:rails_stack][:restart_command]`. Fixes [#9](https://github.com/joeyAghion/opsworks_delayed_job/issues/9) ([#10](https://github.com/joeyAghion/opsworks_delayed_job/pull/10)). Note that this may break timing of Chef deploy hooks.
* Change default path for delayed_job executable from `script` to `bin` ([#11](https://github.com/joeyAghion/opsworks_delayed_job/pull/11)). Set `node[:delayed_job][:path_to_script]` to `script` to achieve old behavior.
20 changes: 20 additions & 0 deletions opsworks_delayed_job/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2013-2015 Joey Aghion, Artsy

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
68 changes: 68 additions & 0 deletions opsworks_delayed_job/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
opsworks_delayed_job
====================

These recipes set up an [AWS OpsWorks](http://aws.amazon.com/opsworks/) instance to run [delayed_job](https://github.com/collectiveidea/delayed_job) workers for a Rails application.


Configuration Examples
----------------------

By default, **4** delayed_job workers will be configured. To customize this, you may override the `delayed_job.pool_size` attribute in your stack's custom JSON:

{
"delayed_job": { "pool_size": 6 }
}

Specify an alternate `delayed_job` script location by overriding the `delayed_job.path_to_script` attribute in your stack's custom JSON. The default, `bin` was added in Rails 4. For pre-Rails 4 projects, set it to `script`:

{
"delayed_job": { "pool_size": 3, "path_to_script": "script" }
}

By default, workers will read from all queues. You can also specify custom `queues` parameters by adding attributes corresponding to each instance name and worker process. A special `default` pool can be specified to supply configuration for instances that don't otherwise appear in the JSON:

{
"delayed_job": {
"YOUR_APP_NAME": {
"pools": {
"worker1": {
"0": { "queues": "highpriority,images" },
"1": { "queues": "emails" },
"2": { "queues": "images" }
},
"default": {
"0": { "queues": "emails" },
"1": { "queues": "emails" },
"2": { "queues": "emails" }
}
}
}
}
}


OpsWorks Set-Up
---------------

Create a custom layer for the delayed_job instances. Add the `AWS-OpsWorks-Rails-App-Server` security group to the layer, so that the instances have the usual cache and database access. Then, assign this cookbook's custom chef recipes to OpsWorks events as follows:

* **Setup**: `opsworks_delayed_job::setup`
* **Configure**: `opsworks_delayed_job::configure`
* **Deploy**: `opsworks_delayed_job::deploy`
* **Undeploy**: `opsworks_delayed_job::undeploy`
* **Shutdown**: `opsworks_delayed_job::stop`


Changes
---

Defaults have changed with the current release. See the [CHANGELOG](CHANGELOG.md) for details.


To Do
-----

* Attributes should be better structured (allowing customization without requiring all worker processes to be listed).


&copy; 2013-2015 Joey Aghion, Artsy. [MIT License](LICENSE).
29 changes: 29 additions & 0 deletions opsworks_delayed_job/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include_attribute "deploy"

default[:delayed_job] = {}
default[:delayed_job][:pool_size] = 4

case node[:platform_family]
when 'rhel', 'fedora', 'suse'
default[:monit][:includes_dir] = '/etc/monit.d'
else
default[:monit][:includes_dir] = '/etc/monit/conf.d'
end

node[:deploy].each do |application, deploy|

default[:delayed_job][application] = {}
default[:delayed_job][application][:path_to_script] = node[:delayed_job][:path_to_script] || 'bin'
default[:delayed_job][application][:pools] = {}

# Default to node[:delayed_job][:pool_size] workers, each with empty ({}) config.
default[:delayed_job][application][:pools][:default] = Hash[node[:delayed_job][:pool_size].times.map{|i| [i.to_s, {}] }]

# Use node[:delayed_job][application][:pools][HOSTNAME] if provided.
default[:delayed_job][application][:pool] = node[:delayed_job][application][:pools][node[:opsworks][:instance][:hostname]] || node[:delayed_job][application][:pools][:default]
Chef::Log.debug("Set delayed_job attributes for #{application} to #{node[:delayed_job][application].to_hash.inspect}")

default[:delayed_job][application][:restart_command] = "sudo monit restart -g delayed_job_#{application}_group"

end

14 changes: 14 additions & 0 deletions opsworks_delayed_job/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name "opsworks_delayed_job"
maintainer "Artsy"
maintainer_email "it@artsymail.com"
license "MIT"
description "Configure and deploy background job workers."
version "0.6"

recipe 'opsworks_delayed_job::setup', 'Set up delayed_job worker.'
recipe 'opsworks_delayed_job::configure', 'Configure delayed_job worker.'
recipe 'opsworks_delayed_job::deploy', 'Deploy delayed_job worker.'
recipe 'opsworks_delayed_job::undeploy', 'Undeploy delayed_job worker.'
recipe 'opsworks_delayed_job::stop', 'Stop delayed_job worker.'

depends 'deploy'
Loading