prepp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 447bbb35513d7c7dea77a84e78709c164da19ce0
4
+ data.tar.gz: b7542c7c37ea7341d571c25d3e1884154f980203
5
+ SHA512:
6
+ metadata.gz: 38e81cf6a053a0a0c7940e2fc724b17b60a43d66b0d5dfadabc789fb60790f63b48b55b79e260fdee7f99aac37ab1974d07da0f1ccf2ab8064c00945c141f35b
7
+ data.tar.gz: e8e4021db2092dddf32844a46b896a5e65efdc017cf1fc91e7c677f12f8151a61c5d633a136d7c31365ce4c1b535315901fda6cf4246f4e9d23ce55d869026b6
@@ -0,0 +1,21 @@
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
18
+
19
+
20
+ .ruby-version
21
+ .ruby-gemset
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prepp.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 the-architect
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,29 @@
1
+ # Prepp
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'prepp'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install prepp
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO.md ADDED
@@ -0,0 +1,10 @@
1
+ TODO
2
+
3
+ - improve documentation
4
+ - show live output from connection
5
+ - run provisioning in parallel
6
+ - run provisioning in the background
7
+ - add some helpers
8
+ - setup plugin infrastructure
9
+ - setup most commonly used packages
10
+
@@ -0,0 +1,14 @@
1
+ require_relative '../lib/prepp'
2
+
3
+ recipe do
4
+ target 'localhost', 'vagrant', password: 'vagrant', port: 2222
5
+
6
+ package :update_apt_list do
7
+ execute 'sudo apt-get update'
8
+ end
9
+
10
+ package :list_home_dir do
11
+ verify 'id -u vagrant'
12
+ execute 'ls -la /home/vagrant'
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'prepp/version'
2
+ require_relative 'prepp/recipe'
3
+ require_relative 'prepp/commands/command'
4
+ require_relative 'prepp/core_ext/object'
5
+
@@ -0,0 +1,38 @@
1
+ module Prepp
2
+ class Command
3
+
4
+ def initialize(name, *dependencies, &block)
5
+ @name = name.to_sym
6
+ @dependencies = *dependencies
7
+ @execute = []
8
+ @verifiers = []
9
+
10
+ @results = []
11
+
12
+ instance_eval(&block)
13
+ end
14
+
15
+ attr_accessor :results
16
+
17
+ def execute(command = nil, &block)
18
+ @execute << (block_given? ? instance_eval(&block) : command)
19
+ end
20
+
21
+ def verify(command = nil, &block)
22
+ @verifiers << (block_given? ? instance_eval(&block) : command)
23
+ end
24
+
25
+ def to_s
26
+ build_ssh_command
27
+ end
28
+
29
+ private
30
+
31
+ def build_ssh_command
32
+ [].tap do |cmd|
33
+ cmd << @verifiers.join(' && ') unless @verifiers.empty?
34
+ cmd << @execute.join(' && ') unless @execute.empty?
35
+ end.join(' && ')
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,6 @@
1
+ class Object
2
+ # only minimally invade the Object class to have a nice little wrapper call around the Recipe class
3
+ def recipe(&block)
4
+ Prepp::Recipe.new(&block)
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'commands/command'
2
+ require_relative 'target'
3
+
4
+ module Prepp
5
+ class Recipe
6
+ def initialize(&block)
7
+ @commands = []
8
+ @targets = []
9
+
10
+ instance_eval(&block)
11
+ execute
12
+ end
13
+
14
+ def package(name, *dependencies, &block)
15
+ @commands << Command.new(name, *dependencies, &block)
16
+ end
17
+
18
+ def target(host, user, options={})
19
+ @targets << Target.new(host, user, options)
20
+ end
21
+
22
+ private
23
+
24
+ def execute
25
+ @targets.each{|t| t.execute @commands }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ require 'net/ssh'
2
+
3
+ module Prepp
4
+ class Target < Struct.new(:host, :user, :options)
5
+ def connection
6
+ @connection ||= Net::SSH.start(host, user, options)
7
+ end
8
+
9
+ def execute(commands)
10
+ commands.each do |cmd|
11
+ cmd.results << connection.exec!(cmd.to_s)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Prepp
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prepp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'prepp'
8
+ spec.version = Prepp::VERSION
9
+ spec.authors = ['the-architect']
10
+ spec.email = ['marcel.scherf@epicteams.com']
11
+ spec.description = %q{Simplified SSH provisioning}
12
+ spec.summary = %q{Simplified SSH provisioning}
13
+ spec.homepage = 'https://github.com/prepp/prepp'
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'
23
+ spec.add_dependency 'net-ssh', '>= 2.7.0'
24
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prepp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - the-architect
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-06 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: net-ssh
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.7.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.0
55
+ description: Simplified SSH provisioning
56
+ email:
57
+ - marcel.scherf@epicteams.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - TODO.md
68
+ - examples/simple.rb
69
+ - lib/prepp.rb
70
+ - lib/prepp/commands/command.rb
71
+ - lib/prepp/core_ext/object.rb
72
+ - lib/prepp/recipe.rb
73
+ - lib/prepp/target.rb
74
+ - lib/prepp/version.rb
75
+ - prepp.gemspec
76
+ homepage: https://github.com/prepp/prepp
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.1.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Simplified SSH provisioning
100
+ test_files: []