homeseed 0.0.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZThkMTQyNTZhOTFlNzk2OTNkNDY4MDk5ZDcwZjQ2NWUzZDg5OTQyMw==
5
+ data.tar.gz: !binary |-
6
+ ZjVjM2YxMTQ4ODYwNWI2N2ZiNDE1NTliM2JhMGEyZjQ1ZTAxMzExOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTNkZjBiMTFkNTQzMmI3NDk5ZWFmMGZkYmFkZmRkMTI1YmVlMzAzZDExZWJl
10
+ YWI5MzExZTZiZGE3MGQxYzRlMmJmZmEwODU2ZTNkZDJhYjBhNzc1YzE5YmVk
11
+ N2Q3ZGNjNjgxYTIzZDU5YTc2M2Y3Mzk2ODVmN2IzNzA4MjQ2MzU=
12
+ data.tar.gz: !binary |-
13
+ NmZkZGQ1ODEwYmNhMTk3MGFmYzczYTNjNTdlYmIyNDQxZTgzYzIzNTFiZTY3
14
+ YzhhNjg2MmM2YzViYWFhYzc1YTNlNDkyNGY2ZTUyMzljN2ZmOGU5ZTVkYjJl
15
+ OGU2MTFjZjliOWZmNmEzNWNkZWYyMjNlY2NjNTUzNmM2MmNmOTg=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in homeseed.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
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/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Homeseed
2
+
3
+ Bash command flattener for remote ssh exec
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'homeseed'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install homeseed
18
+
19
+ ## Usage
20
+
21
+ Examples
22
+
23
+ to install dot profile on server list run
24
+ ```
25
+ homeseed plant -s blackberry,blueberry,raspberry -f config/shick-seed.yml
26
+ ```
27
+
28
+ to update run
29
+ ```
30
+ homeseed plant -s soho -f config/shick-update.yml
31
+ ```
32
+
33
+ ## Contributing
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
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/homeseed ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/homeseed'
4
+ require 'thor'
5
+
6
+ module Homeseed
7
+ class HomeseedCliApp < Thor
8
+ desc 'plant [-s <servers>] [-f <files>] [-u <user>]', ''
9
+ option :servers, required: true, aliases: '-s', desc: 'ssh hostname(s)'
10
+ option :files, required: true, aliases: '-f', desc: 'yml command file(s) to exec'
11
+ option :user, aliases: '-u', desc: 'ssh username', default: ENV['USER']
12
+ method_option :has_password, aliases: '-p', type: :boolean, default: false, desc: 'has password; no ssh keys'
13
+ def plant
14
+ connection = Homeseed::Connection.new options
15
+ connection.ssh_exec
16
+ end
17
+ end
18
+ HomeseedCliApp.start
19
+ end
@@ -0,0 +1,9 @@
1
+ sudo:
2
+ apt-get:
3
+ update:
4
+ - -y
5
+ install:
6
+ - ack-grep -y
7
+ - lynx -y
8
+ - tree -y
9
+ - vim -y
@@ -0,0 +1,17 @@
1
+ git:
2
+ clone:
3
+ - git://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick
4
+ source:
5
+ - "$HOME/.homesick/repos/homeshick/homeshick.sh"
6
+ rm:
7
+ - -rf $HOME/git
8
+ homeshick:
9
+ clone:
10
+ - https://github.com/git/git.git --batch
11
+ - https://github.com/rbuchss/terminator.git --batch
12
+ - https://github.com/rbuchss/vim-4-eva.git --batch
13
+ link:
14
+ - terminator --force
15
+ - vim-4-eva --force
16
+ ln:
17
+ - -s -f $HOME/.homesick/repos/git $HOME/git
@@ -0,0 +1,8 @@
1
+ source:
2
+ - "$HOME/.homesick/repos/homeshick/homeshick.sh"
3
+ homeshick:
4
+ pull:
5
+ - --force --batch
6
+ link:
7
+ - terminator --force
8
+ - vim-4-eva --force
data/homeseed.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'homeseed/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "homeseed"
8
+ spec.version = Homeseed::VERSION
9
+ spec.authors = ["rbuchss"]
10
+ spec.email = ['rbuchss@gmail.com']
11
+ spec.description = "Flattens then SSH execs commands on remote server"
12
+ spec.summary = "Flattened SSH exec"
13
+ spec.homepage = 'http://github.com/rbuchss/homeseed'
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
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake", '~> 10.3'
23
+ spec.add_dependency 'net-ssh', '~> 2.9'
24
+ spec.add_dependency 'highline', '~> 1.6'
25
+ spec.add_dependency 'thor', '~> 0.19'
26
+ end
@@ -0,0 +1,3 @@
1
+ module Homeseed
2
+ VERSION = "0.0.1"
3
+ end
data/lib/homeseed.rb ADDED
@@ -0,0 +1,76 @@
1
+ require "homeseed/version"
2
+ require 'logger'
3
+ require 'net/ssh'
4
+ require 'highline/import'
5
+ require 'yaml'
6
+
7
+ module Homeseed
8
+ class Connection
9
+ def self.logger
10
+ @logger ||= Logger.new(STDOUT)
11
+ end
12
+
13
+ def logger
14
+ self.class.logger
15
+ end
16
+
17
+ def initialize(params={})
18
+ raise unless params[:servers] and params[:files] and params[:user]
19
+ @servers = params[:servers].split(',')
20
+ @files = params[:files].split(',')
21
+ @user = params[:user]
22
+ @has_password = params[:password]
23
+
24
+ @flat_commands = ''
25
+ @files.each do |file|
26
+ yml_commands = YAML.load_file(file)
27
+ commands = []
28
+ self.process_hash(commands, '', yml_commands)
29
+ @flat_commands += commands.join('; ') + ';'
30
+ end
31
+ end
32
+
33
+ def process_hash(commands, current_key, obj)
34
+ if obj.is_a?(Hash)
35
+ obj.each do |new_key, value|
36
+ combined_key = [current_key, new_key].delete_if { |k| k == '' }.join(" ")
37
+ process_hash(commands, combined_key, value)
38
+ end
39
+ else obj.is_a?(Array)
40
+ obj.each do |value|
41
+ combined_key = [current_key, value].delete_if { |k| k == '' }.join(" ")
42
+ commands << combined_key
43
+ end
44
+ end
45
+ end
46
+
47
+ def ssh_exec
48
+ @servers.each do |server|
49
+ logger.info "ssh #{@user}@#{server} exec: #{@flat_commands}"
50
+
51
+ password = @has_password ? ask("Enter password: ") { |q| q.echo = "*" } : ''
52
+ Net::SSH.start(server, @user, password: password) do |ssh|
53
+ ssh.open_channel do |channel|
54
+ channel.exec("bash -l") do |ch, success|
55
+ ch.send_data "#{@flat_commands}\n"
56
+ ch.on_data do |c, data|
57
+ data_lines = data.split(/[\r,\n]/)
58
+ data_lines.each do |data_line|
59
+ logger.info data_line unless data_line == ''
60
+ end
61
+ end
62
+
63
+ ch.on_extended_data do |c, type, data|
64
+ data_lines = data.split(/[\r,\n]/)
65
+ data_lines.each do |data_line|
66
+ logger.error data_line unless data_line == ''
67
+ end
68
+ end
69
+ ch.send_data "exit\n"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: homeseed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - rbuchss
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-08 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: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: net-ssh
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: highline
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.19'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.19'
83
+ description: Flattens then SSH execs commands on remote server
84
+ email:
85
+ - rbuchss@gmail.com
86
+ executables:
87
+ - homeseed
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/homeseed
97
+ - config/setup-linux.yml
98
+ - config/shick-seed.yml
99
+ - config/shick-update.yml
100
+ - homeseed.gemspec
101
+ - lib/homeseed.rb
102
+ - lib/homeseed/version.rb
103
+ homepage: http://github.com/rbuchss/homeseed
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.3.0
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Flattened SSH exec
127
+ test_files: []
128
+ has_rdoc: