ey-scp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (10) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +20 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +39 -0
  7. data/Rakefile +1 -0
  8. data/bin/ey-scp +97 -0
  9. data/ey-scp.gemspec +23 -0
  10. metadata +133 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be56694762720df74c94fe1bed7521337650eaff
4
+ data.tar.gz: 43cc9443e1e20571772485c009b01af9d9bd828b
5
+ SHA512:
6
+ metadata.gz: cacfcd5686046c0c79fc7a33dcee62102d01a1c72112eefc6d440795583210b119d369362659bf932f7e12f1f30bf1359b51be635350a6d38928c3dbea1a6ab3
7
+ data.tar.gz: 315002c101086afe9e998908fc913f426bc95c512868f6fb66bbd8b007c27f2b405e31d05f7f29dd9253e02c9fc744fd6137f1ecbbdee742df5968a05894c3d2
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ Gemfile.lock
6
+ InstalledFiles
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+
17
+ # YARD artifacts
18
+ _yardoc
19
+ .yardoc
20
+ _yardoc
21
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ey-scp.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Roadtrippers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Steven Dunlap
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.
@@ -0,0 +1,39 @@
1
+ # ey-scp
2
+
3
+ Rubygem to quickly and painlessly deploy configuration files to multiple
4
+ instances on EngineYard
5
+
6
+ ## Installation
7
+
8
+ 1. Run
9
+
10
+ $ gem install ey-scp
11
+
12
+ 2. Make sure that you [have your public key registered with
13
+ EY](https//support.cloud.engineyard.com/entries/21016528-Add-an-SSH-Key).
14
+
15
+ ## Usage
16
+
17
+ 1. Run
18
+ ey login
19
+
20
+ from your project directory.
21
+
22
+ 2. Use the ```ey-scp``` from any directory with the following syntax:
23
+
24
+ ey-scp -e ENVIRONMENT [OPTIONS] LOCAL_SOURCE_FILE REMOTE_DESTINATION
25
+
26
+ e.g.
27
+
28
+ ey-scp -e production --app-servers ~/local/project/config/foo.yml /remote/project/path/config
29
+
30
+ ## Contributing
31
+
32
+ Right now, we could really use someone to refactor the code so that it's less
33
+ scripty/hackish.
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ # created by Steven Dunlap of Roadtrippers
3
+ # licensed under MIT, see LICENSE.md for information
4
+ # absolutely no warranty provided
5
+
6
+ # right now this is pretty hacked together; maybe someday we'll clean it up
7
+
8
+ require 'pp'
9
+ require 'yaml'
10
+ require 'faraday'
11
+ require 'json'
12
+ require 'optparse'
13
+ require 'net/scp'
14
+
15
+ ROLES = {
16
+ app_servers: {flag: '--app-servers', roles: ['solo', 'app', 'app_master'], title: 'application servers'},
17
+ db_servers: {flag: '--db-servers', roles: ['solo', 'db_master', 'db_slave'], title: 'database servers'},
18
+ db_master: {flag: '--db-master', roles: ['solo', 'db_master'], title: 'database master'},
19
+ db_slaves: {flag: '--db-slaves', roles: ['solo', 'db_slave'], title: 'database slaves'}
20
+ }
21
+
22
+
23
+ options = {roles: []}
24
+ option_parser = OptionParser.new do |opts|
25
+ opts.banner = "Usage: ey-scp -e ENVIRONMENT [OPTIONS] LOCAL_SOURCE_FILE REMOTE_DESTINATION"
26
+
27
+ opts.on("-e", "--environment [ENVIRONMENT]", "environment to deploy to (required)") do |e|
28
+ options[:environment] = e
29
+ end
30
+
31
+ opts.on("-A", "--all", "deploy to all roles in environment") do |a|
32
+ options[:roles] << 'all'
33
+ end
34
+
35
+ ROLES.each do |server_type, properties|
36
+ opts.on( properties[:flag] , "deploy to #{properties[:title]} in environment") do |a|
37
+ options[:roles] = options[:roles] | properties[:roles]
38
+ end
39
+ end
40
+
41
+ opts.on_tail("-h", "--help", "Show this message") do
42
+ puts opts
43
+ exit
44
+ end
45
+ end
46
+ option_parser.parse!
47
+
48
+ if( options[:environment].nil? )
49
+ puts "Environment is required!"
50
+ puts option_parser.help
51
+ exit 1
52
+ end
53
+
54
+ if( options[:roles].empty? )
55
+ puts 'Warning, no role supplied; assuming all roles.'
56
+ options[:roles] = ['all']
57
+ end
58
+
59
+ unless( options[:source] = ARGV[0] )
60
+ puts 'A source file is required!'
61
+ puts option_parser.help
62
+ exit 1
63
+ end
64
+
65
+ unless( options[:destination] = ARGV[1] )
66
+ puts 'A destination is required!'
67
+ puts option_parser.help
68
+ exit 1
69
+ end
70
+
71
+ # get EY API token
72
+ begin
73
+ api_token_file = File.open("#{ENV['HOME']}/.eyrc")
74
+ rescue
75
+ raise('ERROR: cannot open ~/.eyrc. Run "ey login" in your project directory.')
76
+ end
77
+ api_token = YAML.load(api_token_file)['api_token']
78
+
79
+ # get environment data
80
+ conn = Faraday.new( url: 'https://cloud.engineyard.com:443', headers: {'X-EY-Cloud-Token' => api_token} )
81
+ response = conn.get '/api/v2/environments'
82
+ environments = JSON.parse(response.body)['environments']
83
+
84
+ # parse out server lists
85
+ environment = environments.select{|env| env['name'] == options[:environment]}.first
86
+ if( options[:roles].include? 'all' )
87
+ instances = environment['instances']
88
+ else
89
+ instances = environment['instances'].select{ |inst| options[:roles].include?(inst['role']) }
90
+ end
91
+ servers = instances.map{ |inst| inst['public_hostname'] }
92
+
93
+ #time to do the copying!
94
+ servers.each do |server|
95
+ puts "Uploading to #{server}..."
96
+ Net::SCP.upload!(server, 'deploy', options[:source], options[:destination] )
97
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "ey-scp"
4
+ spec.version = '0.1.0'
5
+ spec.authors = ["Steven Dunlap"]
6
+ spec.email = ["steven@roadtrippers.com"]
7
+ spec.description = "Quickly deploy config files (e.g. YMLs) to all EngineYard servers"
8
+ spec.summary = File.open('README.md').read
9
+ spec.homepage = "http://github.com/roadtrippers/ey-scp"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_development_dependency "bundler", "~> 1.3"
18
+ spec.add_development_dependency "rake"
19
+
20
+ spec.add_dependency 'json', '~> 1.8'
21
+ spec.add_dependency 'net-scp', '~> 1.1'
22
+ spec.add_dependency 'faraday', '~> 0.8'
23
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ey-scp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Dunlap
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: net-scp
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
83
+ description: Quickly deploy config files (e.g. YMLs) to all EngineYard servers
84
+ email:
85
+ - steven@roadtrippers.com
86
+ executables:
87
+ - ey-scp
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/ey-scp
98
+ - ey-scp.gemspec
99
+ homepage: http://github.com/roadtrippers/ey-scp
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.1.5
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: "# ey-scp Rubygem to quickly and painlessly deploy configuration files to
123
+ multiple instances on EngineYard ## Installation 1. Run $ gem install ey-scp
124
+ \ 2. Make sure that you [have your public key registered with EY](https//support.cloud.engineyard.com/entries/21016528-Add-an-SSH-Key).
125
+ \ ## Usage 1. Run ey login from your project directory. 2. Use the ```ey-scp```
126
+ from any directory with the following syntax: ey-scp -e ENVIRONMENT [OPTIONS] LOCAL_SOURCE_FILE
127
+ REMOTE_DESTINATION e.g. ey-scp -e production --app-servers ~/local/project/config/foo.yml
128
+ /remote/project/path/config ## Contributing Right now, we could really use someone
129
+ to refactor the code so that it's less scripty/hackish. 1. Fork it 2. Create your
130
+ feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit
131
+ -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`)
132
+ 5. Create new Pull Request"
133
+ test_files: []