Created
March 30, 2011 00:29
-
-
Save tinomen/893643 to your computer and use it in GitHub Desktop.
Altered couchdb recipe for use on EngineYard with chef-solo 0.6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I had to alter the recipe for couchdb available on opscode.com to work on engine yard. (http://community.opscode.com/cookbooks/couchdb) | |
1. EY still uses chef-solo 0.6 which requires the attributes file to be changed. trial and error found a working solution | |
2. EY is on gentoo and the service commands hang. Changed recipe to use the typical init.d path. Updated the init.d script. | |
3. added couchdb.yml template to add file to app_server:/data/[app_name]/shared/config | |
FYI I commented out the reference to the erlang recipe for now as we've added the erlang package to the entire environment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Author:: Joshua Timberman <[email protected]> | |
# Cookbook Name:: couchdb | |
# Attributes:: couchdb | |
# | |
# Copyright 2010, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# set[:couch_db][:src_checksum] = "b74a5bfe13e3457798107509cb533d0e7df276adad526ccd5a381c1271108b1f" | |
# set[:couch_db][:src_version] = "1.0.1" | |
# set[:couch_db][:src_mirror] = "http://archive.apache.org/dist/couchdb/#{couch_db.src_version}/apache-couchdb-#{couch_db.src_version}.tar.gz" | |
# v0.6 | |
couchdb_src_checksum "b74a5bfe13e3457798107509cb533d0e7df276adad526ccd5a381c1271108b1f" | |
couchdb_src_version "1.0.1" | |
# couchdb_src_mirror "http://archive.apache.org/dist/couchdb/#{@node[:couchdb_src_version]}/apache-couchdb-#{@node[:couchdb_src_version]}.tar.gz" | |
couchdb_src_mirror "http://archive.apache.org/dist/couchdb/1.0.1/apache-couchdb-1.0.1.tar.gz" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Author:: Joshua Timberman <[email protected]> | |
# Cookbook Name:: couchdb | |
# Recipe:: default | |
# | |
# Copyright 2008-2009, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# include_recipe "erlang" | |
if ['solo', 'db_master', 'db_slave'].include?(node[:instance_role]) | |
ey_cloud_report "Couchdb" do | |
message "installing #{node[:couchdb_src_version]}" | |
end | |
package "couchdb" do | |
package_name value_for_platform( | |
"openbsd" => { "default" => "apache-couchdb" }, | |
"gentoo" => { "default" => "dev-db/couchdb" }, | |
"default" => "couchdb" | |
) | |
end | |
remote_file "/etc/init.d/couchdb" do | |
owner "root" | |
group "root" | |
mode 0755 | |
source "couchdb.init" | |
backup false | |
action :create | |
end | |
directory "/var/lib/couchdb" do | |
owner "couchdb" | |
group "couchdb" | |
recursive true | |
path value_for_platform( | |
"openbsd" => { "default" => "/var/couchdb" }, | |
"freebsd" => { "default" => "/var/couchdb" }, | |
"gentoo" => { "default" => "/var/couchdb" }, | |
"default" => "/var/lib/couchdb" | |
) | |
end | |
ey_cloud_report "starting couchdb server" do | |
message "starting couchdb" | |
end | |
service "couchdb" do | |
if platform?("centos","redhat","fedora") | |
start_command "/sbin/service couchdb start &> /dev/null" | |
stop_command "/sbin/service couchdb stop &> /dev/null" | |
elsif platform?("gentoo") | |
start_command "/etc/init.d/couchdb start &> /dev/null" | |
stop_command "/etc/init.d/couchdb stop &> /dev/null" | |
end | |
supports [ :restart, :status ] | |
action [ :enable, :start ] | |
end | |
ey_cloud_report "started couchdb server" do | |
message "started couchdb" | |
end | |
end | |
if ['solo', 'app_master', 'app'].include?(node[:instance_role]) | |
ey_cloud_report "Couchdb" do | |
message "building config" | |
end | |
node[:applications].each do |app_name,data| | |
template "/data/#{app_name}/shared/config/couchdb.yml" do | |
owner node[:owner_name] | |
group node[:owner_name] | |
mode 0644 | |
source "couchdb.yml.erb" | |
variables({ | |
:app_name => app_name, | |
:couch_host => node["engineyard"]["environment"]["instances"].select{|hh|hh["name"] == 'util1'}.first["private_hostname"] | |
}) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Author:: Joshua Timberman <[email protected]> | |
# Cookbook Name:: couchdb | |
# Recipe:: source | |
# | |
# Copyright 2010, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
if ['solo', 'db_master', 'db_replica'].include?(node[:instance_role]) | |
ey_cloud_report "Couchdb Source" do | |
message "installing #{node[:couch_db][:version]}" | |
end | |
if node[:platform] == "ubuntu" && node[:platform_version].to_f == 8.04 | |
log "Ubuntu 8.04 does not supply sufficient development libraries via APT to install CouchDB #{node[:couch_db][:src_version]} from source." | |
return | |
end | |
# include_recipe "erlang" | |
couchdb_tar_gz = File.join(Chef::Config[:file_cache_path], "/", "apache-couchdb-#{node[:couch_db][:src_version]}.tar.gz") | |
compile_flags = String.new | |
dev_pkgs = Array.new | |
case node[:platform] | |
when "debian", "ubuntu" | |
dev_pkgs << "libicu-dev" | |
dev_pkgs << "libcurl4-openssl-dev" | |
dev_pkgs << value_for_platform( | |
"debian" => { "default" => "libmozjs-dev" }, | |
"ubuntu" => { | |
"9.04" => "libmozjs-dev", | |
"9.10" => "libmozjs-dev", | |
"default" => "xulrunner-dev" | |
} | |
) | |
dev_pkgs.each do |pkg| | |
package pkg | |
end | |
if node[:platform_version].to_f == 10.04 | |
compile_flags = "--with-js-lib=/usr/lib/xulrunner-devel-1.9.2.8/lib --with-js-include=/usr/lib/xulrunner-devel-1.9.2.8/include" | |
end | |
end | |
remote_file couchdb_tar_gz do | |
checksum node[:couch_db][:src_checksum] | |
source node[:couch_db][:src_mirror] | |
end | |
bash "install couchdb #{node[:couch_db][:src_version]}" do | |
cwd Chef::Config[:file_cache_path] | |
code <<-EOH | |
tar -zxf #{couchdb_tar_gz} | |
cd apache-couchdb-#{node[:couch_db][:src_version]} && ./configure #{compile_flags} && make && make install | |
EOH | |
not_if { ::FileTest.exists?("/usr/local/bin/couchdb") } | |
end | |
user "couchdb" do | |
home "/usr/local/var/lib/couchdb" | |
comment "CouchDB Administrator" | |
supports :manage_home => false | |
system true | |
end | |
%w{ var/lib/couchdb var/log/couchdb var/run etc/couchdb }.each do |dir| | |
directory "/usr/local/#{dir}" do | |
owner "couchdb" | |
group "couchdb" | |
mode "0770" | |
end | |
end | |
cookbook_file "/etc/init.d/couchdb" do | |
source "couchdb.init" | |
owner "root" | |
group "root" | |
mode "0755" | |
end | |
service "couchdb" do | |
supports [ :restart, :status ] | |
action [:enable, :start] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
production: http://<%= @couch_host %>:5984/<%= @app_name %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# 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. | |
### BEGIN INIT INFO | |
# Provides: couchdb | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Apache CouchDB init script | |
# Description: Apache CouchDB init script for the database server. | |
### END INIT INFO | |
SCRIPT_OK=0 | |
SCRIPT_ERROR=1 | |
DESCRIPTION="database server" | |
NAME=couchdb | |
SCRIPT_NAME=`basename $0` | |
COUCHDB=/usr/bin/couchdb | |
COUCHDB_USER=couchdb | |
COUCHDB_GROUP=couchdb | |
CONFIGURATION_FILE=/etc/couchdb/couchdb.conf | |
RUN_DIR=/var/run/couchdb | |
PIDFILE=/var/run/couchdb/couchdb.pid | |
LSB_LIBRARY=/lib/lsb/init-functions | |
LOG=/var/log/couchdb/couch.log | |
COUCHDB_STDOUT_FILE="$LOG" | |
COUCHDB_STDERR_FILE="$LOG" | |
if test ! -x $COUCHDB; then | |
exit $SCRIPT_ERROR | |
fi | |
if test -r $CONFIGURATION_FILE; then | |
. $CONFIGURATION_FILE | |
fi | |
if test -r $LOG; then | |
chown $COUCHDB_USER:$COUCHDB_GROUP $LOG | |
fi | |
log_daemon_msg () { | |
# Dummy function to be replaced by LSB library. | |
echo $@ | |
} | |
log_end_msg () { | |
# Dummy function to be replaced by LSB library. | |
if test "$1" != "0"; then | |
echo "Error with $DESCRIPTION: $NAME" | |
fi | |
return $1 | |
} | |
if test -r $LSB_LIBRARY; then | |
. $LSB_LIBRARY | |
fi | |
start_couchdb () { | |
# Start Apache CouchDB as a background process. | |
command="$COUCHDB -p $PIDFILE -b" | |
if test -n "$COUCHDB_STDOUT_FILE"; then | |
command="$command -o $COUCHDB_STDOUT_FILE" | |
fi | |
if test -n "$COUCHDB_STDERR_FILE"; then | |
command="$command -e $COUCHDB_STDERR_FILE" | |
fi | |
if test -n "$COUCHDB_RESPAWN_TIMEOUT"; then | |
command="$command -r $COUCHDB_RESPAWN_TIMEOUT" | |
fi | |
if test -n "$COUCHDB_OPTIONS"; then | |
command="$command $COUCHDB_OPTIONS" | |
fi | |
mkdir -p "$RUN_DIR" | |
if test -n "$COUCHDB_USER"; then | |
chown $COUCHDB_USER "$RUN_DIR" | |
if su $COUCHDB_USER -c "$command" > /dev/null; then | |
return $SCRIPT_OK | |
else | |
return $SCRIPT_ERROR | |
fi | |
else | |
if $command > /dev/null; then | |
return $SCRIPT_OK | |
else | |
return $SCRIPT_ERROR | |
fi | |
fi | |
} | |
stop_couchdb () { | |
# Stop the running Apache CouchDB process. | |
command="$COUCHDB -p $PIDFILE -d" | |
if test -n "$COUCHDB_OPTIONS"; then | |
command="$command $COUCHDB_OPTIONS" | |
fi | |
if test -n "$COUCHDB_USER"; then | |
if su $COUCHDB_USER -c "$command" > /dev/null; then | |
return $SCRIPT_OK | |
else | |
return $SCRIPT_ERROR | |
fi | |
else | |
if $command > /dev/null; then | |
return $SCRIPT_OK | |
else | |
return $SCRIPT_ERROR | |
fi | |
fi | |
} | |
display_status () { | |
# Display the status of the running Apache CouchDB process. | |
$COUCHDB -s -p $PIDFILE | |
} | |
parse_script_option_list () { | |
# Parse arguments passed to the script and take appropriate action. | |
case "$1" in | |
start) | |
log_daemon_msg "Starting $DESCRIPTION" $NAME | |
if start_couchdb; then | |
log_end_msg $SCRIPT_OK | |
else | |
log_end_msg $SCRIPT_ERROR | |
fi | |
;; | |
stop) | |
log_daemon_msg "Stopping $DESCRIPTION" $NAME | |
if stop_couchdb; then | |
log_end_msg $SCRIPT_OK | |
else | |
log_end_msg $SCRIPT_ERROR | |
fi | |
;; | |
restart|force-reload) | |
log_daemon_msg "Restarting $DESCRIPTION" $NAME | |
if stop_couchdb; then | |
if start_couchdb; then | |
log_end_msg $SCRIPT_OK | |
else | |
log_end_msg $SCRIPT_ERROR | |
fi | |
else | |
log_end_msg $SCRIPT_ERROR | |
fi | |
;; | |
status) | |
display_status | |
;; | |
*) | |
cat << EOF >&2 | |
Usage: $SCRIPT_NAME {start|stop|restart|force-reload|status} | |
EOF | |
exit $SCRIPT_ERROR | |
;; | |
esac | |
} | |
parse_script_option_list $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment