More Related Content Similar to How SmartLogic Uses Chef-Dan Ivovich Similar to How SmartLogic Uses Chef-Dan Ivovich (20) More from SmartLogic (20) How SmartLogic Uses Chef-Dan Ivovich13. Chef%Setup%(Berksfile)
source 'https://supermarket.getchef.com'
cookbook 'annoyances', '~> 0.0.2'
cookbook 'build-essential'
cookbook 'firewall', '>= 0.8'
cookbook 'git', '~> 3.0'
cookbook 'hostname', '~> 0.0.4'
cookbook 'hostsfile', '~> 1.0'
cookbook 'imagemagick', '~> 0.2'
cookbook 'monit', '~> 0.7'
cookbook 'mysql'
cookbook 'newrelic'
cookbook 'nginx', '~> 2.7'
cookbook 'openssl', '~> 1.1'
cookbook 'openssh', '~> 1.2'
cookbook 'postgresql', '~> 3.4'
cookbook 'rbenv'
cookbook 'redisio', '~> 1.4'
cookbook 'sudo', '~> 1.1'
cookbook 'ufw'
cookbook 'users_solo', '~> 1.0'
cookbook 'xml'
cookbook 'github_keys', github: 'smartlogic/github_keys-cookbook'
cookbook 'wuphf', path: './site-cookbooks/wuphf'
14. One$Chef$Cookbook$to$RULE$THEM$ALL
cookbook 'wuphf', path: './site-cookbooks/wuphf'
Place&all&the&work&our&app&needs&done&in&a&single&
cookbook&with&recipies&for&each&major&component
1. wuphf::setup
2. wuphf::db
3. wuphf::redis
4. wuphf::web
5. wuphf::app
6. wuphf::worker
We#can#use#these#recipes#in#each#environment#as#we#
need#to.
21. wuphf::db
Make%sure%the%applica/on%database%user%and%schema%
exists
connection_info = {
:host => "127.0.0.1",
:port => 5432,
:username => 'postgres',
:password => node['postgresql']['password']['postgres']
}
postgresql_database_user node['wuphf']['database_user'] do
connection connection_info
password node['wuphf']['database_password']
action :create
end
postgresql_database node['wuphf']['database'] do
connection connection_info
encoding 'UTF8'
owner node['wuphf']['database_user']
action :create
end
44. Beta%Web/App/Worker%(10.0.0.2)
"firewall" : {
"rules" : [
{ "http" : { "port" : "80" } }
]
},
Beta%DB/Redis%(10.0.0.3)
"firewall" : {
"rules" : [
{ "psql" : { "port" : "5432", "source": "10.0.0.2/32" } },
{ "redis" : { "port" : "6379", "source": "10.0.0.2/32" } }
]
},
46. Prod%DB/Redis%(10.0.0.7)
"firewall" : {
"rules" : [
{ "psql" : { "port" : "5432", "source": "10.0.0.5/32" } },
{ "psql" : { "port" : "5432", "source": "10.0.0.6/32" } },
{ "redis" : { "port" : "6379", "source": "10.0.0.5/32" } },
{ "redis" : { "port" : "6379", "source": "10.0.0.6/32" } },
]
},
48. Beta%DB/Redis%(10.0.0.3)%(Addi3ons)
"postgresql" : {
"config" : {
"listen_addresses" : "localhost, 10.0.0.3"
},
"pg_hba" : [
{ "type" : "local", "db" : "all", "user" : "postgres", "addr" : null, "method" : "ident"},
{ "type" : "local", "db" : "all", "user" : "all", "addr" : null, "method" : "ident"},
{ "type" : "host", "db" : "all", "user" : "all", "addr" : "127.0.0.1/32", "method" : "md5"},
{ "type" : "hostssl", "db" : "all", "user" : "wuphf", "addr" : "10.0.0.2/32", "method" : "md5"},
{ "type" : "host", "db" : "all", "user" : "all", "addr" : "::1/128", "method" : "md5"}
],
"config_pgtune" : {
"db_type" : "web",
"max_connections" : "400"
}
},
49. Prod%DB/Redis%(10.0.0.7)%(Addi4ons)
"postgresql" : {
"pg_hba" : [
{ "type" : "hostssl", "db" : "all", "user" : "wuphf", "addr" : "10.0.0.5/32", "method" : "md5"},
{ "type" : "hostssl", "db" : "all", "user" : "wuphf", "addr" : "10.0.0.6/32", "method" : "md5"},
],
},
50. Wuphf
Staging'(10.0.0.1)
"wuphf" : {
"environment" : "staging",
"database" : "wuphf_staging",
"env_settings" : {
"AWS_ACCESS_KEY" : "AWS_ACCESS_KEY",
"AWS_SECRET_ACCESS_KEY" : "AWS_SECRET_ACCESS_KEY",
"FACEBOOK_APP_ID" : "FACEBOOK_APP_ID",
"FACEBOOK_APP_SECRET" : "FACEBOOK_APP_SECRET",
"NEW_RELIC_LICENSE_KEY" : "NEW_RELIC_LICENSE_KEY",
"TWITTER_CONSUMER_KEY" : "TWITTER_KEY",
"TWITTER_CONSUMER_SECRET" : "TWITTER_SECRET",
"TWILIO_API_KEY" : "TWILIO_API_KEY",
"REDIS_PROVIDER" : "REDIS_URL",
"REDIS_URL" : "redis://localhost:6379",
"RACK_ENV" : "staging",
"RAILS_ENV" : "staging"
}
},
51. Beta%Web/App/Worker%(10.0.0.2)
"wuphf" : {
"environment" : "beta",
"database" : "wuphf_beta",
"hosts" : {
"db1" : "10.0.0.3"
},
"env_settings" : {
"AWS_ACCESS_KEY" : "AWS_ACCESS_KEY",
"AWS_SECRET_ACCESS_KEY" : "AWS_SECRET_ACCESS_KEY",
"FACEBOOK_APP_ID" : "FACEBOOK_APP_ID",
"FACEBOOK_APP_SECRET" : "FACEBOOK_APP_SECRET",
"NEW_RELIC_LICENSE_KEY" : "NEW_RELIC_LICENSE_KEY",
"TWITTER_CONSUMER_KEY" : "TWITTER_KEY",
"TWITTER_CONSUMER_SECRET" : "TWITTER_SECRET",
"TWILIO_API_KEY" : "TWILIO_API_KEY",
"REDIS_PROVIDER" : "REDIS_URL",
"REDIS_URL" : "redis://10.0.0.3:6379",
"RACK_ENV" : "beta",
"RAILS_ENV" : "beta"
}
},
52. Prod%Web/App%(10.0.0.5)
"wuphf" : {
"environment" : "production",
"database" : "wuphf_production",
"hosts" : {
"db1" : "10.0.0.7",
"worker1" : "10.0.0.6"
},
"env_settings" : {
"AWS_ACCESS_KEY" : "AWS_ACCESS_KEY",
"AWS_SECRET_ACCESS_KEY" : "AWS_SECRET_ACCESS_KEY",
"FACEBOOK_APP_ID" : "FACEBOOK_APP_ID",
"FACEBOOK_APP_SECRET" : "FACEBOOK_APP_SECRET",
"NEW_RELIC_LICENSE_KEY" : "NEW_RELIC_LICENSE_KEY",
"TWITTER_CONSUMER_KEY" : "TWITTER_KEY",
"TWITTER_CONSUMER_SECRET" : "TWITTER_SECRET",
"TWILIO_API_KEY" : "TWILIO_API_KEY",
"REDIS_PROVIDER" : "REDIS_URL",
"REDIS_URL" : "redis://10.0.0.7:6379",
"RACK_ENV" : "production",
"RAILS_ENV" : "production"
}
},
53. Prod%Worker%(10.0.0.6)
"wuphf" : {
"environment" : "production",
"database" : "wuphf_production",
"hosts" : {
"db1" : "10.0.0.7",
"web1" : "10.0.0.5",
},
"env_settings" : {
"AWS_ACCESS_KEY" : "AWS_ACCESS_KEY",
"AWS_SECRET_ACCESS_KEY" : "AWS_SECRET_ACCESS_KEY",
"FACEBOOK_APP_ID" : "FACEBOOK_APP_ID",
"FACEBOOK_APP_SECRET" : "FACEBOOK_APP_SECRET",
"NEW_RELIC_LICENSE_KEY" : "NEW_RELIC_LICENSE_KEY",
"TWITTER_CONSUMER_KEY" : "TWITTER_KEY",
"TWITTER_CONSUMER_SECRET" : "TWITTER_SECRET",
"TWILIO_API_KEY" : "TWILIO_API_KEY",
"REDIS_PROVIDER" : "REDIS_URL",
"REDIS_URL" : "redis://10.0.0.7:6379",
"RACK_ENV" : "production",
"RAILS_ENV" : "production"
}
},