SUPPORT 0.0.1pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +27 -0
  2. data/.rspec +6 -0
  3. data/.ruby-version +1 -0
  4. data/.rvmrc +17 -0
  5. data/Berksfile +11 -0
  6. data/Capfile +3 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +22 -0
  9. data/Procfile +1 -0
  10. data/README.md +112 -0
  11. data/Rakefile +8 -0
  12. data/SUPPORT.gemspec +43 -0
  13. data/Vagrantfile +6 -0
  14. data/bin/support +0 -0
  15. data/chef/.chef/bootstrap/chef-solo.erb +27 -0
  16. data/chef/.chef/knife.rb +8 -0
  17. data/chef/.gitignore +1 -0
  18. data/chef/README +3 -0
  19. data/chef/custom_cookbooks/radar-console/CHANGELOG.md +12 -0
  20. data/chef/custom_cookbooks/radar-console/README.md +12 -0
  21. data/chef/custom_cookbooks/radar-console/metadata.rb +6 -0
  22. data/chef/custom_cookbooks/radar-console/recipes/default.rb +8 -0
  23. data/chef/roles/README +1 -0
  24. data/chef/roles/apache2.rb +10 -0
  25. data/chef/roles/mysql.rb +18 -0
  26. data/chef/roles/passenger.rb +17 -0
  27. data/chef/roles/rvm.rb +10 -0
  28. data/chef/server_app.json +1 -0
  29. data/chef/server_db.json +1 -0
  30. data/chef/server_staging.json +1 -0
  31. data/chef/solo.rb +5 -0
  32. data/config/deploy.rb +62 -0
  33. data/config/deploy/production.rb +3 -0
  34. data/config/deploy/server_app.rb +5 -0
  35. data/config/deploy/server_db.rb +4 -0
  36. data/config/deploy/server_staging.rb +5 -0
  37. data/config/deploy/staging.rb +2 -0
  38. data/config/support.toml.example +25 -0
  39. data/lib/SUPPORT.rb +12 -0
  40. data/lib/SUPPORT/config.rb +7 -0
  41. data/lib/SUPPORT/server.rb +64 -0
  42. data/lib/SUPPORT/version.rb +3 -0
  43. data/lib/tasks/config.rake +9 -0
  44. data/lib/tasks/setup.rake +19 -0
  45. data/spec/lib/SUPPORT/server_spec.rb +61 -0
  46. data/spec/lib/support_spec.rb +11 -0
  47. data/spec/spec_helper.rb +16 -0
  48. metadata +389 -0
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .vagrant
6
+ .yardoc
7
+ Berksfile.lock
8
+ Gemfile.lock
9
+ *~
10
+ *#
11
+ .#*
12
+ \#*#
13
+ .*.sw[a-z]
14
+ *.un~
15
+ chef/cookbooks
16
+ *.tar.gz
17
+ InstalledFiles
18
+ _yardoc
19
+ coverage
20
+ doc/
21
+ lib/bundler/man
22
+ pkg
23
+ rdoc
24
+ spec/reports
25
+ test/tmp
26
+ test/version_tmp
27
+ tmp
data/.rspec ADDED
@@ -0,0 +1,6 @@
1
+ --color
2
+ --format nested
3
+ #--format progress
4
+ #--require emoji-rspec
5
+ #--format hearts
6
+ #--format NyanCatFormatter
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p392
data/.rvmrc ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+
3
+ environment_id="$(cat .ruby-version)@support"
4
+ # insert the word 'use' after --create as this triggers verbose mode.
5
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
6
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
7
+ then
8
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
9
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
10
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
11
+ else
12
+ # If the environment file has not yet been created, use the RVM CLI to select.
13
+ rvm --create "$environment_id" || {
14
+ echo "Failed to create RVM environment '${environment_id}'."
15
+ return 1
16
+ }
17
+ fi
data/Berksfile ADDED
@@ -0,0 +1,11 @@
1
+ site :opscode
2
+
3
+ # Base Blocks
4
+ cookbook "ohai"
5
+ cookbook "openssl"
6
+ cookbook "database"
7
+ cookbook "rvm", git: "git://github.com/fnichol/chef-rvm.git"
8
+ cookbook "rvm_passenger", git: "git://github.com/fnichol/chef-rvm_passenger.git"
9
+
10
+ # Weird Blocks
11
+ cookbook "radar-console", path: "chef/custom_cookbooks/radar-console"
data/Capfile ADDED
@@ -0,0 +1,3 @@
1
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2
+ Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
3
+ load 'config/deploy'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in SUPPORT.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Steven Haddox
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Procfile ADDED
@@ -0,0 +1 @@
1
+ vm: vagrant up
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # SUPPORT:
2
+
3
+ **S**etting **U**p & **P**rovisioning **P**ragmatic **O**SS **R**uby **T**echnologies
4
+
5
+ ## About:
6
+
7
+ SUPPORT is a CLI gem that enables simple Capistrano enabled Berkshelf Chef cookbook deploys by packaging the source code to common OSS Ruby and Agile management projects and providing cookbooks that install those projects & packages from source (without sudo privileges when possible).
8
+ SUPPORT is only possible because of the amazing OSS tools that power it.
9
+
10
+ SUPPORT uses:
11
+
12
+ * [chef](http://www.opscode.com/chef/)
13
+ * [berkshelf](http://berkshelf.com/)
14
+ * Tutorials from [Atomic Object](http://atomicobject.com):
15
+ * [Chef Solo with Capistrano](http://spin.atomicobject.com/2012/12/18/chef-solo-with-capistrano/)
16
+ * [Chef Solo with Capistrano and Berkshelf](http://spin.atomicobject.com/2013/01/03/berks-simplifying-chef-solo-cookbook-management-with-berkshelf/)
17
+
18
+ SUPPORT provides packaging and deployment for the following projects:
19
+
20
+ #### Provisioning:
21
+
22
+ * [Chef Server](http://docs.opscode.com/#the-chef-server)
23
+
24
+ #### Git:
25
+
26
+ * [GitLab HQ](https://github.com/gitlabhq/gitlabhq)
27
+
28
+ #### Continuous Integration:
29
+
30
+ * [GitLab CI](https://github.com/gitlabhq/gitlab-ci)
31
+ * [Jenkins](http://jenkins-ci.org)
32
+ * [Travis CI](https://travis-ci.org)
33
+
34
+ #### Ruby:
35
+
36
+ * [Gem in a Box](https://github.com/cwninja/geminabox)
37
+ * [RVM::FW](https://github.com/stevenhaddox/rvm_fw)
38
+
39
+ #### Errors:
40
+
41
+ * [Errbit](https://github.com/errbit/errbit)
42
+
43
+ #### Logs:
44
+
45
+ * [Logstash](http://logstash.net)
46
+ * [Kibana](http://kibana.org)
47
+
48
+ #### E-Mail / SMTP:
49
+
50
+ * [Mailcatcher](http://mailcatcher.me)
51
+
52
+ #### Agile Project Management:
53
+
54
+ * [ChiliProject](https://www.chiliproject.org)
55
+ * [Fulcrum](https://github.com/malclocke/fulcrum)
56
+ * [Redmine](http://www.redmine.org)
57
+
58
+ #### Metrics:
59
+
60
+ * [FnordMetric](https://github.com/paulasmuth/fnordmetric)
61
+
62
+ #### Security:
63
+
64
+ * [Snorby](https://snorby.org)
65
+
66
+ ## Usage:
67
+
68
+ SUPPORT allows you to setup a configuration file (`config/support_recipes.toml`) that specifies which tools you'd like to run on your SUPPORT server. To find out which OSS projects are available run:
69
+
70
+ $ support available
71
+
72
+ To list the packages you've configured for your server run:
73
+
74
+ $ support ready
75
+
76
+ To download the source code for all of the projects you've selected as well as their dependencies you simply run:
77
+
78
+ $ support package
79
+
80
+ This will result in a file in your current directory named `support_drop.tgz`.
81
+
82
+ Copy this file to your internal LAN (this automatically includes the support gem and it's depdency gems).
83
+
84
+ From within your network where you'll be running your deploy you need to do a few things:
85
+
86
+ 1. Setup ssh key-based authentication on your SUPPORT enabled server.
87
+ 2. Create a Capistrano configuration in `config/deploy/support.rb` (you can use `config/deploy/support.rb.example` as a guideline).
88
+ 3. Install the `SUPPORT` gem locally:
89
+
90
+ $ bundle install --local
91
+
92
+ 4. Prepare to deploy your SUPPORT drop. In order to do this you'll have to work through some issues as you try to run your deploy and make changes to your environment (hopefully these will be minimal as SUPPORT tries not to assume any more privileges than absolutely required). These custom commands that need to be run should be created in the `custom_commands.rb` (#TODO: Figure out the real name & location of this file) file so that they are easily repeatable. This file is automically processed at the beginning of each SUPPORT drop and allows you to ensure a consistent environment should you SUPPORT environment expand to additional servers in the future.
93
+ 5. Deploy your customized SUPPORT drop to your SUPPORT server:
94
+
95
+ $ support drop
96
+
97
+ 6. Fix any configuration errors by adding the needed commands as described in step 4 and rerun step 5 until it's working properly.
98
+
99
+ ## Notes
100
+
101
+ Chef configuration information in [/chef](chef).
102
+
103
+ Capistrano configuration information in [/config](config).
104
+
105
+ ## Test Suite
106
+
107
+ To run the test suite ensure you have a Vagrant instance running via `vagrant up` and that you've customized [config/support.toml.example](config/support.toml.example) in `config/support.toml` for your environment.
108
+
109
+ ```bash
110
+ $ bundle install
111
+ $ bundle exec rake
112
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new
4
+ task :default => :spec
5
+ task :test => :spec
6
+
7
+ # import all .rake files under lib/tasks
8
+ Dir.glob('lib/tasks/*.rake').each { |r| import r }
data/SUPPORT.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'SUPPORT/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "SUPPORT"
8
+ spec.version = SUPPORT::VERSION
9
+ spec.authors = ["Steven Haddox"]
10
+ spec.email = ["steven@haddox.us"]
11
+ spec.description = %q{SUPPORT: Setting Up & Provisioning Pragmatic OSS Ruby Technologies}
12
+ spec.summary = %q{SUPPORT provides a CLI to select & download OSS code, dependencies, and chef cookbooks to stand up a standalone Ruby "support" server.}
13
+ spec.homepage = "https://github.com/stevenhaddox/SUPPORT"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.bindir = "bin"
21
+ spec.executables = "support"
22
+
23
+ spec.add_runtime_dependency("gli", "~> 2.5")
24
+
25
+ spec.add_runtime_dependency("awesome_print", "~> 1.1")
26
+ spec.add_runtime_dependency("berkshelf", "~> 1.2")
27
+ spec.add_runtime_dependency("capistrano", "~> 2.14")
28
+ spec.add_runtime_dependency("capistrano-ext", "~> 1.2")
29
+ spec.add_runtime_dependency("chef", "~> 11.4")
30
+ spec.add_runtime_dependency("memoize", "~> 1.3")
31
+ spec.add_runtime_dependency("net-ssh-simple", "~> 1.6")
32
+ spec.add_runtime_dependency("rvm-capistrano", "~> 1.2")
33
+ spec.add_runtime_dependency("toml", "~> 0.0")
34
+
35
+ spec.add_development_dependency("aruba", "~> 0.5")
36
+ spec.add_development_dependency("bundler", "~> 1.3")
37
+ spec.add_development_dependency("capybara", "~> 2.0")
38
+ spec.add_development_dependency("cucumber", "~> 1.2")
39
+ spec.add_development_dependency("emoji-rspec")
40
+ spec.add_development_dependency("nyan-cat-formatter")
41
+ spec.add_development_dependency("rake", "~> 10.0")
42
+ spec.add_development_dependency("rspec", "~> 2.13")
43
+ end
data/Vagrantfile ADDED
@@ -0,0 +1,6 @@
1
+ Vagrant::Config.run do |config|
2
+ config.vm.box = "centos-5.9-x86-64-minimal.box"
3
+ config.vm.box_url = "http://tag1consulting.com/files/centos-5.9-x86-64-minimal.box"
4
+ config.vm.network :hostonly, "33.33.33.10"
5
+ config.vm.share_folder "v-cookbooks", "/cookbooks", "."
6
+ end
data/bin/support ADDED
File without changes
@@ -0,0 +1,27 @@
1
+ bash -c '
2
+ <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
3
+
4
+ exists() {
5
+ if command -v $1 &>/dev/null
6
+ then
7
+ return 0
8
+ else
9
+ return 1
10
+ fi
11
+ }
12
+
13
+ install_sh="http://opscode.com/chef/install.sh"
14
+ version_string="<%= "-v #{knife_config[:bootstrap_version]}" if knife_config[:bootstrap_version] %>"
15
+
16
+ if ! exists /usr/bin/chef-client; then
17
+ if exists wget; then
18
+ bash <(wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh} -O -) ${version_string}
19
+ else
20
+ if exists curl; then
21
+ bash <(curl -L <%= "--proxy=on " if knife_config[:bootstrap_proxy] %> ${install_sh}) ${version_string}
22
+ fi
23
+ fi
24
+ fi
25
+
26
+ mkdir -p /etc/chef
27
+ '
@@ -0,0 +1,8 @@
1
+ log_level :info
2
+ log_location STDOUT
3
+ client_key "#{File.dirname(__FILE__)}/vagrant.pem"
4
+ validation_client_name "chef-validator"
5
+ validation_key "#{File.dirname(__FILE__)}/validation.pem"
6
+ cache_type "BasicFile"
7
+ cache_options( :path => "#{File.dirname(__FILE__)}/checksums" )
8
+ cookbook_path "#{File.dirname(__FILE__)}/../cookbooks"
data/chef/.gitignore ADDED
@@ -0,0 +1 @@
1
+ puppet.tgz
data/chef/README ADDED
@@ -0,0 +1,3 @@
1
+ The JSON files contain specialized run-lists for each server.
2
+
3
+ solo.rb holds configuration information for Chef.
@@ -0,0 +1,12 @@
1
+ # CHANGELOG for radar-console
2
+
3
+ This file is used to list changes made in each version of radar-console.
4
+
5
+ ## 0.1.0:
6
+
7
+ * Initial release of radar-console
8
+
9
+ - - -
10
+ Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
11
+
12
+ The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
@@ -0,0 +1,12 @@
1
+ Description
2
+ ===========
3
+
4
+ Requirements
5
+ ============
6
+
7
+ Attributes
8
+ ==========
9
+
10
+ Usage
11
+ =====
12
+
@@ -0,0 +1,6 @@
1
+ maintainer "YOUR_COMPANY_NAME"
2
+ maintainer_email "YOUR_EMAIL"
3
+ license "All rights reserved"
4
+ description "Installs/Configures radar-console"
5
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
6
+ version "0.1.0"
@@ -0,0 +1,8 @@
1
+ #
2
+ # Cookbook Name:: radar-console
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2012, YOUR_COMPANY_NAME
6
+ #
7
+ # All rights reserved - Do Not Redistribute
8
+ #
data/chef/roles/README ADDED
@@ -0,0 +1 @@
1
+ Definitions of various roles for use in run-lists.
@@ -0,0 +1,10 @@
1
+ name "apache2"
2
+ description "Systems that serve HTTP and HTTPS"
3
+ override_attributes(
4
+ "apache" => { "listen_ports" => [ "80","443" ] }
5
+ )
6
+ run_list(
7
+ "recipe[apache2::default]",
8
+ "recipe[apache2::mod_ssl]",
9
+ "recipe[apache2::mod_expires]"
10
+ )
@@ -0,0 +1,18 @@
1
+ name "mysql"
2
+ description "MySQL Install"
3
+ run_list(
4
+ "recipe[mysql::server]",
5
+ "recipe[mysql::client]"
6
+ )
7
+ override_attributes(
8
+ :mysql => {
9
+ :server_root_password => "abc123",
10
+ :tunable => {
11
+ :innodb_buffer_pool_size => "256M",
12
+ :innodb_log_buffer_size => "8M",
13
+ :innodb_log_file_size => "64M",
14
+ :innodb_additional_mem_pool_size => "16M",
15
+ :max_allowed_packet => "128M"
16
+ }
17
+ }
18
+ )
@@ -0,0 +1,17 @@
1
+ name "passenger"
2
+ description "Passegner Install"
3
+ run_list(
4
+ "role[apache2]",
5
+ "role[rvm]",
6
+ "recipe[rvm_passenger::apache2]",
7
+ )
8
+ override_attributes(
9
+ :rvm_passenger => {
10
+ :version => "3.0.17",
11
+ :rvm_ruby => "ruby-1.9.3-p194@passenger",
12
+ :passenger_max_pool_size => "4",
13
+ :passenger_min_instances => "4",
14
+ :rails_framework_spawner_idle_time => "0",
15
+ :rails_app_spawner_idle_time => "0"
16
+ }
17
+ )
data/chef/roles/rvm.rb ADDED
@@ -0,0 +1,10 @@
1
+ name "rvm"
2
+ description "RVM Install"
3
+ run_list(
4
+ "recipe[rvm::system]"
5
+ )
6
+ override_attributes(
7
+ :rvm => {
8
+ :default_ruby => "ruby-1.9.3-p194",
9
+ }
10
+ )
@@ -0,0 +1 @@
1
+ { "run_list": [ "role[rvm]","role[passenger]" ] }
@@ -0,0 +1 @@
1
+ { "run_list": [ "role[mysql]" ] }
@@ -0,0 +1 @@
1
+ { "run_list": [ "role[mysql]","role[rvm]","role[passenger]" ] }
data/chef/solo.rb ADDED
@@ -0,0 +1,5 @@
1
+ root = File.absolute_path(File.dirname(__FILE__))
2
+
3
+ file_cache_path root
4
+ cookbook_path root + '/cookbooks'
5
+ role_path root + '/roles'
data/config/deploy.rb ADDED
@@ -0,0 +1,62 @@
1
+ require "bundler/capistrano"
2
+ require 'rvm/capistrano'
3
+ require 'capistrano/ext/multistage'
4
+ set :stages, %w(production staging server_app)
5
+ set :default_stage, "staging"
6
+
7
+ default_run_options[:pty] = true
8
+ ssh_options[:forward_agent] = true
9
+
10
+ set :rvm_string, "ruby-1.9.3-p194"
11
+ set :rvm_type, :system
12
+
13
+ set :application, "Chef Solo Pattern"
14
+ set :repository, "git@github.com:kuleszaj/chef-solo-pattern.git"
15
+ set :deploy_to, "/var/www/chef-solo-pattern"
16
+ set :branch, "master"
17
+
18
+
19
+ set :scm, :git
20
+ set :scm_verbose, true
21
+ # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
22
+
23
+ set :deploy_via, :remote_cache
24
+ set :use_sudo, true
25
+ set :keep_releases, 3
26
+ set :user, "atomic"
27
+
28
+ namespace :deploy do
29
+ task :start do ; end
30
+ task :stop do ; end
31
+
32
+ task :restart, :roles => :app, :except => { :no_release => true } do
33
+ run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
34
+ end
35
+
36
+ end
37
+
38
+ namespace :bootstrap do
39
+ task :default do
40
+ system("knife bootstrap -d chef-solo -x #{user} --sudo #{server_ip}")
41
+ end
42
+ end
43
+
44
+ namespace :berks do
45
+ task :install do
46
+ system("berks install --path chef/cookbooks")
47
+ end
48
+ end
49
+
50
+ namespace :chef do
51
+ task :default do
52
+ find_and_execute_task("berks:install")
53
+ system("tar czf 'chef.tar.gz' -C chef/ .")
54
+ upload("chef.tar.gz","/home/#{user}",:via => :scp)
55
+ run("rm -rf /home/#{user}/chef")
56
+ run("mkdir -p /home/#{user}/chef")
57
+ run("tar xzf 'chef.tar.gz' -C /home/#{user}/chef")
58
+ sudo("/bin/bash -c 'cd /home/#{user}/chef && #{chef_binary} -c solo.rb -j #{stage}.json'")
59
+ run("rm -rf /home/#{user}/chef.tar.gz")
60
+ run("rm -rf /home/#{user}/chef")
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ server "10.0.0.1", :app, :web
2
+ server "10.0.0.2", :db, primary:true, :no_release => true
3
+ set :rails_env, "production"
@@ -0,0 +1,5 @@
1
+ set :chef_binary, "/usr/bin/chef-solo"
2
+ set :default_shell, "bash"
3
+ set :user, "atomic"
4
+ server "10.0.0.1", :chef, :no_release => :true
5
+ set :server_ip, "10.0.0.1"
@@ -0,0 +1,4 @@
1
+ set :chef_binary, "/usr/bin/chef-solo"
2
+ set :user, "atomic"
3
+ server "10.0.0.2", :chef, :no_release => :true
4
+ set :server_ip, "10.0.0.2"
@@ -0,0 +1,5 @@
1
+ set :chef_binary, "/usr/bin/chef-solo"
2
+ set :default_shell, "bash"
3
+ set :user, "atomic"
4
+ server "198.61.216.178", :chef, :no_release => :true
5
+ set :server_ip, "198.61.216.178"
@@ -0,0 +1,2 @@
1
+ server "10.0.0.3", :app, :web, :db, primary:true
2
+ set :rails_env, "staging"
@@ -0,0 +1,25 @@
1
+ pubkey_path = "$HOME/.ssh/id_dsa.pub"
2
+
3
+ [servers]
4
+
5
+ [servers.primary]
6
+ ip = "33.33.33.10"
7
+ port = "22"
8
+ hostname = "vagrant.vm"
9
+ user = "vagrant"
10
+ password = "vagrant"
11
+
12
+ # Add as many servers as you need Capistrano to work on
13
+ # [servers.chef_server]
14
+ # ip = "33.33.33.11"
15
+ # port = "22"
16
+ # hostname = "vagrant.vm"
17
+ # user = "vagrant"
18
+ # password = "vagrant"
19
+ #
20
+ # [servers.logs]
21
+ # ip = "33.33.33.12"
22
+ # port = "22"
23
+ # hostname = "vagrant.vm"
24
+ # user = "vagrant"
25
+ # password = "vagrant"
data/lib/SUPPORT.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "SUPPORT/version"
2
+ require 'toml'
3
+ require 'SUPPORT/server'
4
+
5
+ module SUPPORT
6
+
7
+ def self.config
8
+ @config_file_path ||= File.exist?('config/support.toml') ? 'config/support.toml' : 'config/support.toml.example'
9
+ @config ||= TOML.load_file(@config_file_path)
10
+ end
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'toml'
2
+ module SUPPORT
3
+ class Config
4
+ config_file_path = File.exist?('config/support.toml') ? 'config/support.toml' : 'config/support.toml.example'
5
+ CONFIG ||= TOML.load_file(config_file_path)
6
+ end
7
+ end
@@ -0,0 +1,64 @@
1
+ require 'net/ssh/simple'
2
+ module SUPPORT
3
+ class Server
4
+ attr_accessor :role, :ip, :port, :hostname, :user, :password
5
+
6
+ def initialize(role="primary")
7
+ server ||= SUPPORT.config["servers"]["#{role}"]
8
+ @role = role
9
+ @ip = server["ip"]
10
+ @port = server["port"]
11
+ @user = server["user"]
12
+ @password = server["password"]
13
+ @hostname = server["hostname"]
14
+ server
15
+ end
16
+
17
+ def hostname
18
+ host = @hostname
19
+ host ||= ip
20
+ end
21
+
22
+ def exec(&block)
23
+ begin
24
+ # attempt key-based, passwordless authentication
25
+ # prompts for password if key-based auth not configured
26
+ Net::SSH::Simple.ssh(hostname, yield, {:user => @user, :port => @port})
27
+ rescue => e
28
+ puts "SSH key-based auth or stdin password failed. Attempting with configuration password..."
29
+ Net::SSH::Simple.ssh(hostname, yield, {:user => @user, :password => @password, :port => @port})
30
+ end
31
+ end
32
+
33
+ def scp(local_file, remote_file=nil)
34
+ remote_file ||= local_file
35
+ begin
36
+ Net::SSH::Simple.scp_put(hostname, local_file, remote_file, {:user => @user, :port => @port})
37
+ rescue => e
38
+ puts "SCP with key-based auth or stdin password failed. Attempting with configuration password..."
39
+ Net::SSH::Simple.scp_put(hostname, local_file, remote_file, {:user => @user, :password => @password, :port => @port})
40
+ end
41
+ end
42
+
43
+ def setup
44
+
45
+ end
46
+
47
+ def eval_pubkey_path
48
+ `ls "#{SUPPORT.config["pubkey_path"]}"`.rstrip
49
+ end
50
+
51
+ def scp_pubkey
52
+ scp(eval_pubkey_path, "id_dsa.pub")
53
+ response = exec do
54
+ "if grep -f \"$HOME/id_dsa.pub\" $HOME/.ssh/authorized_keys
55
+ then
56
+ echo 'SSH pubkey already in authorized_keys!'
57
+ else
58
+ cat $HOME/id_dsa.pub >> $HOME/.ssh/authorized_keys
59
+ rm $HOME/id_dsa.pub
60
+ fi"
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,3 @@
1
+ module SUPPORT
2
+ VERSION = "0.0.1pre"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'SUPPORT'
2
+ require 'awesome_print'
3
+
4
+ namespace :support do
5
+ desc "Output current configuration"
6
+ task :config do
7
+ ap SUPPORT.config
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require 'SUPPORT'
2
+ require 'awesome_print'
3
+
4
+ namespace :support do
5
+ desc "Initialize a new SUPPORT Server"
6
+ task :setup, :server_name do |t, args|
7
+ args.with_defaults(:server_name => "primary")
8
+ server = SUPPORT::Server.new(args[:server_name])
9
+ puts "[#{server.hostname}]"
10
+ puts " Copying SSH Key..."
11
+ response = server.scp_pubkey
12
+ if response.success == true
13
+ puts " >> SSH Key successfully uploaded."
14
+ else
15
+ puts " >> There was an error uploading your SSH Key."
16
+ raise ap response
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Server" do
4
+ before :each do
5
+ @server = SUPPORT::Server.new('primary')
6
+ end
7
+
8
+ describe ".initialize" do
9
+ it "should init attributes from config" do
10
+ config_server = SUPPORT.config["servers"]["primary"]
11
+ @server.ip.should == config_server["ip"]
12
+ @server.port.should == config_server["port"]
13
+ @server.user.should == config_server["user"]
14
+ @server.password = config_server["password"]
15
+ @server.hostname = config_server["hostname"]
16
+ end
17
+ end
18
+
19
+ describe ".exec" do
20
+ it "should authenticate to the specified remote server" do
21
+ server_response = @server.exec{''}
22
+ server_response.stdout.should == ""
23
+ server_response.success.should == true
24
+ server_response.exit_code.should == 0
25
+ end
26
+
27
+ it "should run a command block remotely on the server" do
28
+ server_response = @server.exec{'hostname'}
29
+ server_response.stdout.should == "vagrant-c5-x86_64\n"
30
+ server_response.success.should == true
31
+ server_response.exit_code.should == 0
32
+ end
33
+ end
34
+
35
+ describe ".scp" do
36
+ it "should copy a local file to the server" do
37
+ `rm /tmp/SUPPORT_tmp.txt`
38
+ `touch /tmp/SUPPORT_tmp.txt`
39
+ server_response = @server.scp("/tmp/SUPPORT_tmp.txt")
40
+ server_response.success.should == true
41
+ end
42
+ end
43
+
44
+ describe ".eval_pubkey_path" do
45
+ it "should have access to the pubkey location" do
46
+ SUPPORT.config["pubkey_path"].should == "$HOME/.ssh/id_dsa.pub"
47
+ end
48
+
49
+ it "should eval the pubkey to expand the file's path" do
50
+ @server.eval_pubkey_path.should == "#{`echo $HOME`.rstrip}"+"/.ssh/id_dsa.pub"
51
+ end
52
+ end
53
+
54
+ describe ".scp_pubkey" do
55
+ it "should copy the pubkey to the remote server" do
56
+ @server.scp_pubkey
57
+ server_response = @server.exec{"cat /home/#{@server.user}/.ssh/authorized_keys"}
58
+ server_response.stdout.should include(`cat #{@server.eval_pubkey_path}`)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe SUPPORT do
4
+
5
+ describe "#config" do
6
+ it "should load the values from config/support.toml" do
7
+ SUPPORT.config.should == TOML.load_file('config/support.toml.example')
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'SUPPORT'
4
+
5
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+ end
metadata ADDED
@@ -0,0 +1,389 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SUPPORT
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1pre
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Steven Haddox
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gli
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.5'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.5'
30
+ - !ruby/object:Gem::Dependency
31
+ name: awesome_print
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: berkshelf
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ - !ruby/object:Gem::Dependency
63
+ name: capistrano
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.14'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.14'
78
+ - !ruby/object:Gem::Dependency
79
+ name: capistrano-ext
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.2'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.2'
94
+ - !ruby/object:Gem::Dependency
95
+ name: chef
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '11.4'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '11.4'
110
+ - !ruby/object:Gem::Dependency
111
+ name: memoize
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.3'
126
+ - !ruby/object:Gem::Dependency
127
+ name: net-ssh-simple
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.6'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '1.6'
142
+ - !ruby/object:Gem::Dependency
143
+ name: rvm-capistrano
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '1.2'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '1.2'
158
+ - !ruby/object:Gem::Dependency
159
+ name: toml
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: '0.0'
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '0.0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: aruba
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: '0.5'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: '0.5'
190
+ - !ruby/object:Gem::Dependency
191
+ name: bundler
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: '1.3'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '1.3'
206
+ - !ruby/object:Gem::Dependency
207
+ name: capybara
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: '2.0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: '2.0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: cucumber
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ~>
228
+ - !ruby/object:Gem::Version
229
+ version: '1.2'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: '1.2'
238
+ - !ruby/object:Gem::Dependency
239
+ name: emoji-rspec
240
+ requirement: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ type: :development
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ - !ruby/object:Gem::Dependency
255
+ name: nyan-cat-formatter
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ type: :development
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ - !ruby/object:Gem::Dependency
271
+ name: rake
272
+ requirement: !ruby/object:Gem::Requirement
273
+ none: false
274
+ requirements:
275
+ - - ~>
276
+ - !ruby/object:Gem::Version
277
+ version: '10.0'
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ none: false
282
+ requirements:
283
+ - - ~>
284
+ - !ruby/object:Gem::Version
285
+ version: '10.0'
286
+ - !ruby/object:Gem::Dependency
287
+ name: rspec
288
+ requirement: !ruby/object:Gem::Requirement
289
+ none: false
290
+ requirements:
291
+ - - ~>
292
+ - !ruby/object:Gem::Version
293
+ version: '2.13'
294
+ type: :development
295
+ prerelease: false
296
+ version_requirements: !ruby/object:Gem::Requirement
297
+ none: false
298
+ requirements:
299
+ - - ~>
300
+ - !ruby/object:Gem::Version
301
+ version: '2.13'
302
+ description: ! 'SUPPORT: Setting Up & Provisioning Pragmatic OSS Ruby Technologies'
303
+ email:
304
+ - steven@haddox.us
305
+ executables:
306
+ - support
307
+ extensions: []
308
+ extra_rdoc_files: []
309
+ files:
310
+ - .gitignore
311
+ - .rspec
312
+ - .ruby-version
313
+ - .rvmrc
314
+ - Berksfile
315
+ - Capfile
316
+ - Gemfile
317
+ - LICENSE.txt
318
+ - Procfile
319
+ - README.md
320
+ - Rakefile
321
+ - SUPPORT.gemspec
322
+ - Vagrantfile
323
+ - bin/support
324
+ - chef/.chef/bootstrap/chef-solo.erb
325
+ - chef/.chef/knife.rb
326
+ - chef/.gitignore
327
+ - chef/README
328
+ - chef/custom_cookbooks/radar-console/CHANGELOG.md
329
+ - chef/custom_cookbooks/radar-console/README.md
330
+ - chef/custom_cookbooks/radar-console/metadata.rb
331
+ - chef/custom_cookbooks/radar-console/recipes/default.rb
332
+ - chef/roles/README
333
+ - chef/roles/apache2.rb
334
+ - chef/roles/mysql.rb
335
+ - chef/roles/passenger.rb
336
+ - chef/roles/rvm.rb
337
+ - chef/server_app.json
338
+ - chef/server_db.json
339
+ - chef/server_staging.json
340
+ - chef/solo.rb
341
+ - config/deploy.rb
342
+ - config/deploy/production.rb
343
+ - config/deploy/server_app.rb
344
+ - config/deploy/server_db.rb
345
+ - config/deploy/server_staging.rb
346
+ - config/deploy/staging.rb
347
+ - config/support.toml.example
348
+ - lib/SUPPORT.rb
349
+ - lib/SUPPORT/config.rb
350
+ - lib/SUPPORT/server.rb
351
+ - lib/SUPPORT/version.rb
352
+ - lib/tasks/config.rake
353
+ - lib/tasks/setup.rake
354
+ - spec/lib/SUPPORT/server_spec.rb
355
+ - spec/lib/support_spec.rb
356
+ - spec/spec_helper.rb
357
+ homepage: https://github.com/stevenhaddox/SUPPORT
358
+ licenses:
359
+ - MIT
360
+ post_install_message:
361
+ rdoc_options: []
362
+ require_paths:
363
+ - lib
364
+ required_ruby_version: !ruby/object:Gem::Requirement
365
+ none: false
366
+ requirements:
367
+ - - ! '>='
368
+ - !ruby/object:Gem::Version
369
+ version: '0'
370
+ segments:
371
+ - 0
372
+ hash: -1957658828000991751
373
+ required_rubygems_version: !ruby/object:Gem::Requirement
374
+ none: false
375
+ requirements:
376
+ - - ! '>'
377
+ - !ruby/object:Gem::Version
378
+ version: 1.3.1
379
+ requirements: []
380
+ rubyforge_project:
381
+ rubygems_version: 1.8.23
382
+ signing_key:
383
+ specification_version: 3
384
+ summary: SUPPORT provides a CLI to select & download OSS code, dependencies, and chef
385
+ cookbooks to stand up a standalone Ruby "support" server.
386
+ test_files:
387
+ - spec/lib/SUPPORT/server_spec.rb
388
+ - spec/lib/support_spec.rb
389
+ - spec/spec_helper.rb