Created
March 29, 2012 14:41
-
-
Save miketheman/2238068 to your computer and use it in GitHub Desktop.
CHEF-3010 repro cookbook/recipe
This file contains 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
default['appdeploy']['dir'] = '/srv/myapp' | |
default['app']['dbname'] = 'testdb' | |
default['app']['dbuser'] = 'sa' |
This file contains 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
package 'git' | |
package 'httpd' # for centos | |
# Create a user | |
user "appdeploy" do | |
comment "App Deploy" | |
uid 3001 | |
gid "users" | |
home "/home/appdeploy" | |
end | |
# Deployment dirs | |
["#{node['appdeploy']['dir']}", | |
"#{node['appdeploy']['dir']}/shared", | |
"#{node['appdeploy']['dir']}/shared/config", | |
"#{node['appdeploy']['dir']}/shared/log" | |
].each do |subdir| | |
directory subdir do | |
action :create | |
owner "appdeploy" | |
group "apache" | |
end | |
end | |
template "#{node['appdeploy']['dir']}/shared/deploy-ssh-wrapper" do | |
source "deploy-ssh-wrapper.erb" | |
owner "appdeploy" | |
group "users" | |
mode 0755 | |
variables( | |
:deploy_key => "#{node['appdeploy']['dir']}/shared/id_deploy_appdeploy" | |
) | |
end | |
# The shared config for this thing | |
template "#{node['appdeploy']['dir']}/shared/config/database.yml" do | |
source "database.yml.erb" | |
mode 0440 | |
owner "appdeploy" | |
group "users" | |
variables( | |
:dbname => node['app']['dbname'], | |
:dbuser => node['app']['dbuser'] | |
) | |
end | |
# This is the one that differs between permissions | |
cookbook_file "#{node['appdeploy']['dir']}/shared/id_deploy_appdeploy" do | |
source "id_deploy_appdeploy" | |
owner "apache" # <===== If the permissions are set like this, `deploy` works, `deploy_revision` fails. | |
group "users" | |
mode 0600 | |
action :create | |
end | |
# Try and deploy a private repo | |
deploy_revision "#{node['appdeploy']['dir']}" do | |
repo "git@github.com:MyCorp/privaterepo.git" | |
revision "HEAD" | |
user "appdeploy" | |
group "apache" | |
symlink_before_migrate "config/database.yml" => "database.yml" # This is the shared env config | |
shallow_clone true | |
action :deploy | |
restart_command "touch tmp/restart.txt" | |
ssh_wrapper "#{node['appdeploy']['dir']}/shared/deploy-ssh-wrapper" | |
scm_provider Chef::Provider::Git | |
end |
This file contains 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
#!/usr/bin/env bash | |
# Deploy SSH Wrapper | |
# Rendered by Chef - local changes will be replaced | |
/usr/bin/env ssh -o "StrictHostKeyChecking=no" -i "<%= @deploy_key %>" $1 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment