glennr-ey-scp 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +1 -0
- data/bin/ey-scp +111 -0
- data/ey-scp.gemspec +23 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f1b88585743501001b945f1efbb751708927e64
|
4
|
+
data.tar.gz: 4288ce7ae6aff3cf85bde3490842a85ac9a9ecf6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aad89acd670b85d811d3cb75e1344f95934d5b4ae6d45bf6fe54a1286a276b5668a26601cc0f624e9bd171d8ab20f3860bebc823469fe5b9209bb40417bdb4c9
|
7
|
+
data.tar.gz: 6b52fb9ef20bc53c2bcc9a974fe70cd421077a68a330002b92ddc07efa5199e7fa2f64c6986205ff93a64161bc9f08811644f9c3240f83b82031e4da808a1990
|
data/.gitignore
ADDED
@@ -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
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.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# ey-scp
|
2
|
+
|
3
|
+
Provides a CLI to quickly and painlessly deploy configuration files to multiple
|
4
|
+
instances on EngineYard
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
1. Run
|
9
|
+
|
10
|
+
$ gem install glennr-ey-scp
|
11
|
+
|
12
|
+
Or with bundler
|
13
|
+
|
14
|
+
gem 'glennr-ey-scp'
|
15
|
+
|
16
|
+
2. Make sure that you [have your public key registered with
|
17
|
+
EY](https//support.cloud.engineyard.com/entries/21016528-Add-an-SSH-Key).
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
1. Run
|
22
|
+
|
23
|
+
ey login
|
24
|
+
|
25
|
+
from your project directory.
|
26
|
+
|
27
|
+
2. Use ```ey-scp``` from any directory with the following syntax:
|
28
|
+
|
29
|
+
ey-scp -e ENVIRONMENT [OPTIONS] LOCAL_SOURCE_FILE REMOTE_DESTINATION
|
30
|
+
|
31
|
+
e.g.
|
32
|
+
|
33
|
+
ey-scp -e production --app-servers ~/local/project/config/foo.yml /remote/project/path/config
|
34
|
+
|
35
|
+
### Specifying target instances
|
36
|
+
|
37
|
+
Option | Uploads to instances with roles of
|
38
|
+
------ | ----------------------------------
|
39
|
+
--app-servers | solo, app_master, app
|
40
|
+
--app-master | solo, app_master
|
41
|
+
--db-servers | solo, db_master, db_slave
|
42
|
+
--db-master | solo, db_master
|
43
|
+
--db-slaves | solo, db_slave
|
44
|
+
--util-servers | solo, util
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Right now, we could really use someone to refactor the code so that it's less
|
49
|
+
scripty/hackish.
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/ey-scp
ADDED
@@ -0,0 +1,111 @@
|
|
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
|
+
app_master: {flag: '--app-master', roles: ['solo', 'app_master'], title: 'application master'},
|
18
|
+
db_servers: {flag: '--db-servers', roles: ['solo', 'db_master', 'db_slave'], title: 'database servers'},
|
19
|
+
db_master: {flag: '--db-master', roles: ['solo', 'db_master'], title: 'database master'},
|
20
|
+
db_slaves: {flag: '--db-slaves', roles: ['solo', 'db_slave'], title: 'database slaves'},
|
21
|
+
util_servers: {flag: '--util-servers', roles: ['solo', 'util'], title: 'utility servers'}
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
options = {roles: []}
|
26
|
+
option_parser = OptionParser.new do |opts|
|
27
|
+
opts.banner = "Usage: ey-scp -e ENVIRONMENT [OPTIONS] LOCAL_SOURCE_FILE REMOTE_DESTINATION"
|
28
|
+
|
29
|
+
opts.on("-e", "--environment [ENVIRONMENT]", "environment to deploy to (required)") do |e|
|
30
|
+
options[:environment] = e
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-A", "--all", "deploy to all roles in environment") do |a|
|
34
|
+
options[:roles] << 'all'
|
35
|
+
end
|
36
|
+
|
37
|
+
ROLES.each do |server_type, properties|
|
38
|
+
opts.on( properties[:flag] , "deploy to #{properties[:title]} in environment") do |a|
|
39
|
+
options[:roles] = options[:roles] | properties[:roles]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
44
|
+
puts opts
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
option_parser.parse!
|
49
|
+
|
50
|
+
if( options[:environment].nil? )
|
51
|
+
puts "Environment is required!"
|
52
|
+
puts option_parser.help
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
|
56
|
+
if( options[:roles].empty? )
|
57
|
+
puts 'Warning, no role supplied; assuming all roles.'
|
58
|
+
options[:roles] = ['all']
|
59
|
+
end
|
60
|
+
|
61
|
+
unless( options[:source] = ARGV[0] )
|
62
|
+
puts 'A source file is required!'
|
63
|
+
puts option_parser.help
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
|
67
|
+
unless( options[:destination] = ARGV[1] )
|
68
|
+
puts 'A destination is required!'
|
69
|
+
puts option_parser.help
|
70
|
+
exit 1
|
71
|
+
end
|
72
|
+
|
73
|
+
# get EY API token
|
74
|
+
begin
|
75
|
+
api_token_file = File.open("#{ENV['HOME']}/.eyrc")
|
76
|
+
rescue
|
77
|
+
raise('ERROR: cannot open ~/.eyrc. Run "ey login" in your project directory.')
|
78
|
+
end
|
79
|
+
api_token = YAML.load(api_token_file)['api_token']
|
80
|
+
|
81
|
+
# get environment data
|
82
|
+
conn = Faraday.new( url: 'https://cloud.engineyard.com:443', headers: {'X-EY-Cloud-Token' => api_token} )
|
83
|
+
response = conn.get '/api/v2/environments'
|
84
|
+
environments = JSON.parse(response.body)['environments']
|
85
|
+
|
86
|
+
# parse out server lists
|
87
|
+
environment = environments.select{|env| env['name'] == options[:environment]}.first
|
88
|
+
if( options[:roles].include? 'all' )
|
89
|
+
instances = environment['instances']
|
90
|
+
else
|
91
|
+
instances = environment['instances'].select{ |inst| options[:roles].include?(inst['role']) }
|
92
|
+
end
|
93
|
+
servers = instances.map{ |inst| inst['public_hostname'] }
|
94
|
+
|
95
|
+
failure_count = 0
|
96
|
+
|
97
|
+
puts "\n#{servers.count} servers found..."
|
98
|
+
|
99
|
+
#time to do the copying!
|
100
|
+
servers.each_with_index do |server, index|
|
101
|
+
begin
|
102
|
+
puts "(#{index + 1}/#{servers.count}): Uploading to #{server}..."
|
103
|
+
Net::SCP.upload!(server, 'deploy', options[:source], options[:destination] )
|
104
|
+
rescue Net::SCP::Error => ex
|
105
|
+
STDERR.puts "Error uploading to #{server}: #{ex.message}"
|
106
|
+
failure_count += 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
puts "Finished with #{failure_count} failures."
|
111
|
+
exit failure_count
|
data/ey-scp.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "glennr-ey-scp"
|
4
|
+
spec.version = '0.3.2'
|
5
|
+
spec.authors = ["Steven Dunlap", "Glenn Roberts"]
|
6
|
+
spec.email = ["steven@roadtrippers.com", "glenn@groovehq.com"]
|
7
|
+
spec.description = "Quickly copy files (e.g. YMLs or configuration files) to multiple EngineYard servers"
|
8
|
+
spec.summary = File.open('README.md').read
|
9
|
+
spec.homepage = "http://github.com/groove/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,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glennr-ey-scp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Dunlap
|
8
|
+
- Glenn Roberts
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: json
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.8'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.8'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: net-scp
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.1'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: faraday
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.8'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.8'
|
84
|
+
description: Quickly copy files (e.g. YMLs or configuration files) to multiple EngineYard
|
85
|
+
servers
|
86
|
+
email:
|
87
|
+
- steven@roadtrippers.com
|
88
|
+
- glenn@groovehq.com
|
89
|
+
executables:
|
90
|
+
- ey-scp
|
91
|
+
extensions: []
|
92
|
+
extra_rdoc_files: []
|
93
|
+
files:
|
94
|
+
- ".gitignore"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/ey-scp
|
100
|
+
- ey-scp.gemspec
|
101
|
+
homepage: http://github.com/groove/ey-scp
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.5.1
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: "# ey-scp Provides a CLI to quickly and painlessly deploy configuration
|
125
|
+
files to multiple instances on EngineYard ## Installation 1. Run $ gem install
|
126
|
+
glennr-ey-scp Or with bundler gem 'glennr-ey-scp' 2. Make sure that you [have
|
127
|
+
your public key registered with EY](https//support.cloud.engineyard.com/entries/21016528-Add-an-SSH-Key).
|
128
|
+
\ ## Usage 1. Run ey login from your project directory. 2. Use ```ey-scp```
|
129
|
+
from any directory with the following syntax: ey-scp -e ENVIRONMENT [OPTIONS] LOCAL_SOURCE_FILE
|
130
|
+
REMOTE_DESTINATION e.g. ey-scp -e production --app-servers ~/local/project/config/foo.yml
|
131
|
+
/remote/project/path/config ### Specifying target instances Option | Uploads to
|
132
|
+
instances with roles of ------ | ---------------------------------- --app-servers
|
133
|
+
| solo, app_master, app --app-master | solo, app_master --db-servers | solo, db_master,
|
134
|
+
db_slave --db-master | solo, db_master --db-slaves | solo, db_slave --util-servers
|
135
|
+
| solo, util ## Contributing Right now, we could really use someone to refactor
|
136
|
+
the code so that it's less scripty/hackish. 1. Fork it 2. Create your feature branch
|
137
|
+
(`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add
|
138
|
+
some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create
|
139
|
+
new Pull Request"
|
140
|
+
test_files: []
|