Skip to content

Instantly share code, notes, and snippets.

@s2t2
Last active August 29, 2015 14:09
Show Gist options
  • Save s2t2/364f71668b228cd11f4d to your computer and use it in GitHub Desktop.
Save s2t2/364f71668b228cd11f4d to your computer and use it in GitHub Desktop.
configurations
{
"ebs_directory_path":"/___",
"environment_variables":{
"_________":"_________",
"_______":"______"
},
"mysql":{
"server_root_password":"_______",
"data_dir":"_________",
"port":"_____"
},
"rbenv": {
"root_path":"/home/ec2-user/rbenv",
"rubies":["1.9.3-p484"],
"global":"1.9.3-p484",
"gems":{
"1.9.3-p484":[
{"name": "bundler"},
{"name":"rails", "version": "4.0.2"},
{"name": "rake", "version": "10.1.1"}
]
}
},
"applications":{
"__________":{
"code":{
"source_url":"ssh://[email protected]/____/_______",
"destination_path":"/home/ec2-user/_______"
},
"database":{
"name":"_______",
"socket":"/var/lib/mysql/mysql.sock",
"user":"_______",
"user_password":"_______"
},
"cron_tasks":{
"_______:_______":{
"cron_hour":"0,6,12,18",
"cron_minute":"0",
"cron_recipient_email_address":"_______"
}
}
}
},
"run_list":[
"ruby_build",
"rbenv::system",
"mysql::server",
"database::mysql",
"MY_RECIPE::default"
]
}
  1. rails new my_app --database=mysql
  2. replace value of MyApp::Application.config.secret_key_base in config/initializers/secret_token.rb with an environment variable
  3. replace value of database passwords in config/database.yml with an environment variable
  4. edit Gemfile:
gem 'pry', group: [:development, :test]
gem 'rspec-rails', '~> 3.0', group: [:development, :test]
  1. bundle install
  2. rspec --init and/or rails generate rspec:install
  3. configure generators in config/application.rb:
config.generators do |g|
  g.test_framework :rspec
  g.assets = false
  g.helper = false
end

manual server configuration steps from the AWS EC2 console:

  1. create a new aws ec2 elastic ip, MY_ELASTIC_IP
  2. create a new aws ec2 instance, add an EBS drive on /dev/sdb, and choose existing AWS_EC2_GENERATED_KEY.pem or generate a new one
  3. mv Downloads/AWS_EC2_GENERATED_KEY.pem ~/.ssh/ (if applicable)
  4. chmod 400 ~/.ssh/AWS_EC2_GENERATED_KEY.pem (if applicable)
  5. associate the elastic ip with the instance
  6. edit ~/.ssh/config file (see attached ssh_configuration file)
  7. ssh MY_ELASTIC_IP_ADDRESS to test the connection

manual domain nameserver mapping steps (optional):

  1. register a domain, MY_DOMAIN
  2. edit the domain's A NAME pointer to MY_ELASTIC_IP
  3. ssh MY_DOMAIN to test the connection

automated server configuration steps:

  1. write a chef recipe, MY_RECIPE, in a chef repo, MY_CHEF_REPO
  2. add a node to MY_CHEF_REPO/nodes (see attached chef_node_configuration.json* file)
  3. knife solo prepare MY_DOMAIN
  4. knife solo cook MY_DOMAIN
CheckHostIP no
StrictHostKeyChecking no
Host github.com
User MY_EMAIL_ADDRESS
Port 443
Hostname ssh.github.com
Host aws-MY_REGION-elastic
User ec2-user
Hostname MY_ELASTIC_IP_ADDRESS
IdentityFile ~/.ssh/AWS_EC2_GENERATED_KEY.pem
Host MY_DOMAIN
User ec2-user
Hostname MY_DOMAIN
IdentityFile ~/.ssh/AWS_EC2_GENERATED_KEY.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment